ROOT  6.06/09
Reference Guide
TProofOutputFile.h
Go to the documentation of this file.
1 // @(#)root/proof:$Id$
2 // Author: Long Tran-Thanh 14/09/07
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TProofOutputFile
13 #define ROOT_TProofOutputFile
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TProofOutputFile //
19 // //
20 // Small class to steer the merging of files produced on workers //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #ifndef ROOT_TNamed
25 #include "TNamed.h"
26 #endif
27 
28 class TCollection;
29 class TString;
30 class TList;
31 class TFile;
32 class TFileCollection;
33 class TFileMerger;
34 
35 class TProofOutputFile : public TNamed {
36 
37 friend class TProof;
38 friend class TProofPlayer;
39 friend class TProofPlayerRemote;
40 
41 public:
42  enum ERunType { kMerge = 1, // Type of run: merge or dataset creation
43  kDataset = 2};
44  enum ETypeOpt { kRemote = 1, // Merge from original copies
45  kLocal = 2, // Make local copies before merging
46  kCreate = 4, // Create dataset
47  kRegister = 8, // Register dataset
48  kOverwrite = 16, // Force dataset replacement during registration
49  kVerify = 32}; // Verify the registered dataset
50 
51 private:
52  TProofOutputFile(const TProofOutputFile&); // Not implemented
53  TProofOutputFile& operator=(const TProofOutputFile&); // Not implemented
54 
55  TString fDir; // name of the directory to be exported
56  TString fRawDir; // name of the local directory where to create the file
58  TString fOptionsAnchor; // options and anchor string including delimiters, e.g. "?myopts#myanchor"
61  TString fLocalHost; // Host where the file was created
62  Bool_t fIsLocal; // kTRUE if the file is in the sandbox
64  ERunType fRunType; // Type of run (see enum ERunType)
65  UInt_t fTypeOpt; // Option (see enum ETypeOpt)
66  Bool_t fMergeHistosOneGo; // If true merge histos in one go (argument to TFileMerger)
67 
68  TFileCollection *fDataSet; // Instance of the file collection in 'dataset' mode
69  TFileMerger *fMerger; // Instance of the file merger in 'merge' mode
70 
71  void Init(const char *path, const char *dsname);
72  void SetFileName(const char* name) { fFileName = name; }
73  void SetDir(const char* dir, Bool_t raw = kFALSE) { if (raw) { fRawDir = dir; } else { fDir = dir; } }
74  void SetMerged(Bool_t merged = kTRUE) { fMerged = merged; }
75  void SetWorkerOrdinal(const char* ordinal) { fWorkerOrdinal = ordinal; }
76 
77  void AddFile(TFileMerger *merger, const char *path);
78  void NotifyError(const char *errmsg);
79  void Unlink(const char *path);
80 
81 protected:
82 
83 public:
84  enum EStatusBits {
86  kRetrieve = BIT(17), // If set, the file is copied to the final destination via the client
87  kSwapFile = BIT(18) // Set when the represented file is the result of the automatic
88  // save-to-file functionality
89  };
90  TProofOutputFile() : fDir(), fRawDir(), fFileName(), fOptionsAnchor(), fOutputFileName(),
91  fWorkerOrdinal(), fLocalHost(), fIsLocal(kFALSE), fMerged(kFALSE),
92  fRunType(kMerge), fTypeOpt(kRemote), fMergeHistosOneGo(kFALSE),
93  fDataSet(0), fMerger(0) { }
94  TProofOutputFile(const char *path, const char *option = "M", const char *dsname = 0);
95  TProofOutputFile(const char *path, ERunType type, UInt_t opt = kRemote, const char *dsname = 0);
96  virtual ~TProofOutputFile();
97 
98  const char *GetDir(Bool_t raw = kFALSE) const { return (raw) ? fRawDir : fDir; }
101  const char *GetFileName() const { return fFileName; }
102  const char *GetLocalHost() const { return fLocalHost; }
103  const char *GetOptionsAnchor() const { return fOptionsAnchor; }
104  const char *GetOutputFileName() const { return fOutputFileName; }
105  const char *GetWorkerOrdinal() const { return fWorkerOrdinal; }
106 
107  ERunType GetRunType() const { return fRunType; }
108  UInt_t GetTypeOpt() const { return fTypeOpt; }
109  Bool_t IsMerge() const { return (fRunType == kMerge) ? kTRUE : kFALSE; }
110  Bool_t IsMerged() const { return fMerged; }
111  Bool_t IsRegister() const { return ((fTypeOpt & kRegister) || (fTypeOpt & kVerify)) ? kTRUE : kFALSE; }
112 
116 
117  Int_t AdoptFile(TFile *f); // Adopt a TFile already open
118  TFile* OpenFile(const char *opt); // Open a file with the specified name in fFileName1
119  Long64_t Merge(TCollection *list);
120  void Print(Option_t *option = "") const;
121  void SetOutputFileName(const char *name);
122  void ResetFileCollection() { fDataSet = 0; }
123 
124  static Int_t AssertDir(const char *dirpath);
125 
126  ClassDef(TProofOutputFile,5) // Wrapper class to steer the merging of files produced on workers
127 };
128 
129 #endif
Bool_t IsRetrieve() const
const char * GetOutputFileName() const
void SetWorkerOrdinal(const char *ordinal)
long long Long64_t
Definition: RtypesCore.h:69
void Print(Option_t *option="") const
Dump the class content.
void SetDir(const char *dir, Bool_t raw=kFALSE)
const char Option_t
Definition: RtypesCore.h:62
void NotifyError(const char *errmsg)
Notify error message.
#define BIT(n)
Definition: Rtypes.h:120
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:45
Int_t AdoptFile(TFile *f)
Adopt a file already open.
UInt_t GetTypeOpt() const
const char * GetFileName() const
Basic string class.
Definition: TString.h:137
static Int_t AssertDir(const char *dirpath)
Assert directory path 'dirpath', with the ownership of the last already existing subpath.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
TFileMerger * fMerger
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:732
TFile * OpenFile(const char *opt)
Open the file using the unique temporary name.
TProofOutputFile & operator=(const TProofOutputFile &)
#define ClassDef(name, id)
Definition: Rtypes.h:254
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
void SetOutputFileName(const char *name)
Set the name of the output file; in the form of an Url.
void SetFileName(const char *name)
TFileMerger * GetFileMerger(Bool_t local=kFALSE)
Get instance of the file merger to be used in 'merge' mode.
A doubly linked list.
Definition: TList.h:47
const char * GetWorkerOrdinal() const
This class provides file copy and merging services.
Definition: TFileMerger.h:30
Collection abstract base class.
Definition: TCollection.h:48
void SetMerged(Bool_t merged=kTRUE)
unsigned int UInt_t
Definition: RtypesCore.h:42
Bool_t TestBit(UInt_t f) const
Definition: TObject.h:173
void Unlink(const char *path)
Unlink path.
Long64_t Merge(TCollection *list)
Merge objects from the list into this object.
double f(double x)
virtual ~TProofOutputFile()
Main destructor.
const char * GetOptionsAnchor() const
EStatusBits
Definition: TObject.h:76
int type
Definition: TGX11.cxx:120
Definition: TProof.h:339
Bool_t IsMerged() const
Bool_t IsRegister() const
void SetRetrieve(Bool_t on=kTRUE)
#define name(a, b)
Definition: linkTestLib0.cpp:5
const char * GetLocalHost() const
Class that contains a list of TFileInfo's and accumulated meta data information about its entries...
TFileCollection * GetFileCollection()
Get instance of the file collection to be used in 'dataset' mode.
TFileCollection * fDataSet
const char * GetDir(Bool_t raw=kFALSE) const
Bool_t IsMerge() const
void ResetBit(UInt_t f)
Definition: TObject.h:172
ERunType GetRunType() const
const Bool_t kTRUE
Definition: Rtypes.h:91
void Init(const char *path, const char *dsname)
Initializer. Called by all constructors.
void AddFile(TFileMerger *merger, const char *path)
Add file to merger, checking the result.