Logo ROOT   6.14/05
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 #include "TNamed.h"
25 
26 class TCollection;
27 class TString;
28 class TList;
29 class TFile;
30 class TFileCollection;
31 class TFileMerger;
32 
33 class TProofOutputFile : public TNamed {
34 
35 friend class TProof;
36 friend class TProofPlayer;
37 friend class TProofPlayerRemote;
38 
39 public:
40  enum ERunType { kMerge = 1, // Type of run: merge or dataset creation
41  kDataset = 2};
42  enum ETypeOpt { kRemote = 1, // Merge from original copies
43  kLocal = 2, // Make local copies before merging
44  kCreate = 4, // Create dataset
45  kRegister = 8, // Register dataset
46  kOverwrite = 16, // Force dataset replacement during registration
47  kVerify = 32}; // Verify the registered dataset
48 
49 private:
50  TProofOutputFile(const TProofOutputFile&); // Not implemented
51  TProofOutputFile& operator=(const TProofOutputFile&); // Not implemented
52 
53  TString fDir; // name of the directory to be exported
54  TString fRawDir; // name of the local directory where to create the file
56  TString fOptionsAnchor; // options and anchor string including delimiters, e.g. "?myopts#myanchor"
59  TString fLocalHost; // Host where the file was created
60  Bool_t fIsLocal; // kTRUE if the file is in the sandbox
62  ERunType fRunType; // Type of run (see enum ERunType)
63  UInt_t fTypeOpt; // Option (see enum ETypeOpt)
64  Bool_t fMergeHistosOneGo; // If true merge histos in one go (argument to TFileMerger)
65 
66  TFileCollection *fDataSet; // Instance of the file collection in 'dataset' mode
67  TFileMerger *fMerger; // Instance of the file merger in 'merge' mode
68 
69  void Init(const char *path, const char *dsname);
70  void SetFileName(const char* name) { fFileName = name; }
71  void SetDir(const char* dir, Bool_t raw = kFALSE) { if (raw) { fRawDir = dir; } else { fDir = dir; } }
72  void SetMerged(Bool_t merged = kTRUE) { fMerged = merged; }
73  void SetWorkerOrdinal(const char* ordinal) { fWorkerOrdinal = ordinal; }
74 
75  void AddFile(TFileMerger *merger, const char *path);
76  void NotifyError(const char *errmsg);
77  void Unlink(const char *path);
78 
79 protected:
80 
81 public:
82  enum EStatusBits {
84  kRetrieve = BIT(17), // If set, the file is copied to the final destination via the client
85  kSwapFile = BIT(18) // Set when the represented file is the result of the automatic
86  // save-to-file functionality
87  };
88  TProofOutputFile() : fDir(), fRawDir(), fFileName(), fOptionsAnchor(), fOutputFileName(),
89  fWorkerOrdinal(), fLocalHost(), fIsLocal(kFALSE), fMerged(kFALSE),
90  fRunType(kMerge), fTypeOpt(kRemote), fMergeHistosOneGo(kFALSE),
91  fDataSet(0), fMerger(0) { }
92  TProofOutputFile(const char *path, const char *option = "M", const char *dsname = 0);
93  TProofOutputFile(const char *path, ERunType type, UInt_t opt = kRemote, const char *dsname = 0);
94  virtual ~TProofOutputFile();
95 
96  const char *GetDir(Bool_t raw = kFALSE) const { return (raw) ? fRawDir : fDir; }
99  const char *GetFileName() const { return fFileName; }
100  const char *GetLocalHost() const { return fLocalHost; }
101  const char *GetOptionsAnchor() const { return fOptionsAnchor; }
102  const char *GetOutputFileName() const { return fOutputFileName; }
103  const char *GetWorkerOrdinal() const { return fWorkerOrdinal; }
104 
105  ERunType GetRunType() const { return fRunType; }
106  UInt_t GetTypeOpt() const { return fTypeOpt; }
107  Bool_t IsMerge() const { return (fRunType == kMerge) ? kTRUE : kFALSE; }
108  Bool_t IsMerged() const { return fMerged; }
109  Bool_t IsRegister() const { return ((fTypeOpt & kRegister) || (fTypeOpt & kVerify)) ? kTRUE : kFALSE; }
110 
114 
115  Int_t AdoptFile(TFile *f); // Adopt a TFile already open
116  TFile* OpenFile(const char *opt); // Open a file with the specified name in fFileName1
117  Long64_t Merge(TCollection *list);
118  void Print(Option_t *option = "") const;
119  void SetOutputFileName(const char *name);
120  void ResetFileCollection() { fDataSet = 0; }
121 
122  static Int_t AssertDir(const char *dirpath);
123 
124  ClassDef(TProofOutputFile,5) // Wrapper class to steer the merging of files produced on workers
125 };
126 
127 #endif
Internal class steering processing in PROOF.
Definition: TProofPlayer.h:60
void SetWorkerOrdinal(const char *ordinal)
long long Long64_t
Definition: RtypesCore.h:69
UInt_t GetTypeOpt() const
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:78
Bool_t IsRegister() const
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:47
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:172
Int_t AdoptFile(TFile *f)
Adopt a file already open.
const char * GetOptionsAnchor() const
ERunType GetRunType() const
Basic string class.
Definition: TString.h:131
static Int_t AssertDir(const char *dirpath)
Assert directory path 'dirpath', with the ownership of the last already existing subpath.
#define f(i)
Definition: RSha256.hxx:104
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Bool_t IsMerge() const
TFileMerger * fMerger
const char * GetOutputFileName() const
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:694
TFile * OpenFile(const char *opt)
Open the file using the unique temporary name.
const char * GetFileName() const
TProofOutputFile & operator=(const TProofOutputFile &)
#define ClassDef(name, id)
Definition: Rtypes.h:320
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
void SetOutputFileName(const char *name)
Set the name of the output file; in the form of an Url.
const char * GetDir(Bool_t raw=kFALSE) const
Bool_t IsRetrieve() const
void SetFileName(const char *name)
void Print(Option_t *option="") const
Dump the class content.
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:44
const char * GetWorkerOrdinal() const
This class provides file copy and merging services.
Definition: TFileMerger.h:30
Collection abstract base class.
Definition: TCollection.h:63
void SetMerged(Bool_t merged=kTRUE)
unsigned int UInt_t
Definition: RtypesCore.h:42
Class to steer the merging of files produced on the workers.
void Unlink(const char *path)
Unlink path.
const Bool_t kFALSE
Definition: RtypesCore.h:88
Long64_t Merge(TCollection *list)
Merge objects from the list into this object.
virtual ~TProofOutputFile()
Main destructor.
EStatusBits
Definition: TObject.h:57
int type
Definition: TGX11.cxx:120
This class controls a Parallel ROOT Facility, PROOF, cluster.
Definition: TProof.h:316
void SetRetrieve(Bool_t on=kTRUE)
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
Bool_t IsMerged() const
void ResetBit(UInt_t f)
Definition: TObject.h:171
void Init(const char *path, const char *dsname)
Initializer. Called by all constructors.
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char * GetLocalHost() const
char name[80]
Definition: TGX11.cxx:109
void AddFile(TFileMerger *merger, const char *path)
Add file to merger, checking the result.