TDbiWriter.hxx
Go to the documentation of this file.00001 #ifndef DBIWRITER_H
00002 #define DBIWRITER_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include <list>
00032 #include <string>
00033
00034 #include "TDbi.hxx"
00035 #include "TDbiLogEntry.hxx"
00036 #include "TDbiDatabaseManager.hxx"
00037 #include "TVldRange.hxx"
00038 #include "TVldTimeStamp.hxx"
00039
00040
00041 class TDbiSqlValPacket;
00042 class TDbiTableProxy;
00043 class TDbiValidityRec;
00044
00045 template <class T> class TDbiWriter
00046 {
00047
00048 public:
00049
00050
00051 TDbiWriter();
00052 TDbiWriter(const TVldRange& vr,
00053 Int_t aggNo,
00054 TDbi::Task task,
00055 TVldTimeStamp creationDate,
00056 const std::string& dbName,
00057 const std::string& logComment = "",
00058 const std::string& tableName = "");
00059 TDbiWriter(const TVldRange& vr,
00060 Int_t aggNo,
00061 TDbi::Task task = 0,
00062 TVldTimeStamp creationDate = TVldTimeStamp(0,0),
00063 UInt_t dbNo = 0,
00064 const std::string& logComment = "",
00065 const std::string& tableName = "");
00066 TDbiWriter(const TDbiValidityRec& vrec,
00067 const std::string& dbName,
00068 const std::string& logComment = "");
00069 TDbiWriter(const TDbiValidityRec& vrec,
00070 UInt_t dbNo = 0,
00071 const std::string& logComment = "");
00072
00073 virtual ~TDbiWriter();
00074
00075
00076
00077 UInt_t GetEpoch() const;
00078 TDbiTableProxy& TableProxy() const;
00079
00080
00081 Bool_t IsOpen(Bool_t reportErrors = kTRUE) const;
00082
00083 Bool_t CanOutput(Bool_t reportErrors = kTRUE) const;
00084
00085
00086
00087 void SetDbNo(UInt_t dbNo) { fDbNo = dbNo;}
00088 void SetDbName(const string& dbName);
00089 void SetEpoch(UInt_t epoch);
00090 void SetLogComment(const std::string& reason);
00091
00092 void SetRequireGlobalSeqno(Int_t requireGlobal) {fRequireGlobalSeqno = requireGlobal;}
00093 void SetOverlayCreationDate() {fUseOverlayCreationDate = kTRUE;}
00094
00095
00096 void Abort() { Reset(); }
00097 Bool_t Close(const char* fileSpec=0);
00098 Bool_t Open(const TVldRange& vr,
00099 Int_t aggNo,
00100 TDbi::Task task,
00101 TVldTimeStamp creationDate,
00102 const string& dbName,
00103 const std::string& logComment = "");
00104 Bool_t Open(const TVldRange& vr,
00105 Int_t aggNo,
00106 TDbi::Task task = 0,
00107 TVldTimeStamp creationDate = TVldTimeStamp(),
00108 UInt_t dbNo = 0,
00109 const std::string& logComment = "");
00110 Bool_t Open(const TDbiValidityRec& vrec,
00111 const string& dbName,
00112 const std::string& logComment = "");
00113 Bool_t Open(const TDbiValidityRec& vrec,
00114 UInt_t dbNo = 0,
00115 const std::string& logComment = "");
00116
00117 TDbiWriter<T>& operator<<(const T& row);
00118
00119 private:
00120
00121
00122
00123 Bool_t NeedsLogEntry() const;
00124 Bool_t WritingToMaster() const;
00125
00126
00127
00128 TDbiWriter(const TDbiWriter&);
00129 TDbiWriter& operator=(const TDbiWriter&);
00130
00131 void CompleteOpen(UInt_t dbNo = 0,
00132 const std::string& logComment = "");
00133 void Reset();
00134
00135 static TDbiTableProxy& GetTableProxy();
00136 static TDbiTableProxy& GetTableProxy(const std::string& tableName);
00137
00138
00139
00140
00141 Int_t fAggregateNo;
00142
00143
00144 UInt_t fDbNo;
00145
00146
00147 TDbiSqlValPacket* fPacket;
00148
00149
00150 Int_t fRequireGlobalSeqno;
00151
00152
00153 TDbiTableProxy* fTableProxy;
00154
00155
00156 std::string fTableName;
00157
00158
00159 Bool_t fUseOverlayCreationDate;
00160
00161
00162 TDbiValidityRec* fValidRec;
00163
00164
00165 TDbiLogEntry fLogEntry;
00166
00167 ClassDefT(TDbiWriter<T>,0)
00168
00169 };
00170
00171 ClassDefT2(TDbiWriter,T)
00172
00173 #endif // DBIWRITER_H
00174