EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FairDbWriter.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FairDbWriter.h
1 #ifndef FAIRDBWRITER_H
2 #define FAIRDBWRITER_H
3 
4 #include <list>
5 #include <string>
6 
7 #include "FairDb.h"
8 #include "FairDbLogEntry.h"
10 #include "ValRange.h"
11 #include "ValTimeStamp.h"
12 
13 class FairDbSqlValPacket;
14 class FairDbTableProxy;
15 class FairDbValidityRec;
16 
17 template <class T> class FairDbWriter
18 {
19 
20  public:
21 
22 // Constructors and destructors.
23  FairDbWriter();
24  FairDbWriter(const ValRange& vr,
25  Int_t aggNo,
26  FairDb::Task task,
27  ValTimeStamp creationDate,
28  const std::string& dbName,
29  const std::string& logComment = "",
30  const std::string& tableName = "");
31  FairDbWriter(const ValRange& vr,
32  Int_t aggNo,
33  FairDb::Task task = 0,
34  ValTimeStamp creationDate = ValTimeStamp(0,0),
35  UInt_t dbNo = 0,
36  const std::string& logComment = "",
37  const std::string& tableName = "");
38  FairDbWriter(const FairDbValidityRec& vrec,
39  const std::string& dbName,
40  const std::string& logComment = "");
41  FairDbWriter(const FairDbValidityRec& vrec,
42  UInt_t dbNo = 0,
43  const std::string& logComment = "");
44 
45  virtual ~FairDbWriter();
46 
47 // State testing member functions
48 
50 
52  Bool_t IsOpen(Bool_t reportErrors = kTRUE) const;
54  Bool_t CanOutput(Bool_t reportErrors = kTRUE) const;
55 
56 // State changing member functions
57 
58  void SetDbNo(UInt_t dbNo) { fDbNo = dbNo;}
59  void SetDbName(const string& dbName);
60  void SetLogComment(const std::string& reason);
61  // For setting of requireGlobal see FairDbCascader::AllocateSeqNo
62  void SetRequireGlobalSeqno(Int_t requireGlobal) {fRequireGlobalSeqno = requireGlobal;}
64 
65 // I/O functions
66  void Abort() { Reset(); }
67  Bool_t Close(const char* fileSpec=0);
68  Bool_t Open(const ValRange& vr,
69  Int_t aggNo,
70  FairDb::Task task,
71  ValTimeStamp creationDate,
72  const string& dbName,
73  const std::string& logComment = "");
74  Bool_t Open(const ValRange& vr,
75  Int_t aggNo,
76  FairDb::Task task = 0,
77  ValTimeStamp creationDate = ValTimeStamp(),
78  UInt_t dbNo = 0,
79  const std::string& logComment = "");
80  Bool_t Open(const FairDbValidityRec& vrec,
81  const string& dbName,
82  const std::string& logComment = "");
83  Bool_t Open(const FairDbValidityRec& vrec,
84  UInt_t dbNo = 0,
85  const std::string& logComment = "");
86 
87  FairDbWriter<T>& operator<<(const T& row);
88 
89  private:
90 
91 // State testing member functions
92 
93  Bool_t NeedsLogEntry() const;
94  Bool_t WritingToMaster() const;
95 
96 // State changing member functions
97 
98  FairDbWriter(const FairDbWriter&); // Forbidden
99  FairDbWriter& operator=(const FairDbWriter&); // Forbidden
100 
101  void CompleteOpen(UInt_t dbNo = 0,
102  const std::string& logComment = "");
103  void Reset();
104 
106  static FairDbTableProxy& GetTableProxy(const std::string& tableName);
107 
108 // Data members
109 
112 
114  UInt_t fDbNo;
115 
118 
121 
124 
126  std::string fTableName;
127 
130 
133 
136 
137  ClassDefT(FairDbWriter<T>,0) // Writer for specific database table.
138 
139 };
141 
142 #endif // FAIRDBWRITER_H