Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

DbiWriter.h

Go to the documentation of this file.
00001 #ifndef DBIWRITER_H
00002 #define DBIWRITER_H
00003 
00032 #include <list>
00033 #include <string>
00034 
00035 #include "DatabaseInterface/Dbi.h"
00036 #include "DatabaseInterface/DbiLogEntry.h"
00037 #include "DatabaseInterface/DbiTableProxyRegistry.h"
00038 #include "Validity/VldRange.h"
00039 #include "Validity/VldTimeStamp.h"
00040 
00041 class DbiSqlValPacket;
00042 class DbiTableProxy;
00043 class DbiValidityRec;
00044 
00045 template <class T> class DbiWriter
00046 {
00047 
00048 public:
00049 
00050 // Constructors and destructors.
00051            DbiWriter();
00052            DbiWriter(const VldRange& vr,
00053                      Int_t aggNo,
00054                      Dbi::Task task,
00055                      VldTimeStamp creationDate,
00056                      const std::string& dbName,
00057                      const std::string& logComment = "",
00058                      const std::string& tableName = "");
00059            DbiWriter(const VldRange& vr,
00060                      Int_t aggNo,
00061                      Dbi::Task task = 0,
00062                      VldTimeStamp creationDate = VldTimeStamp(0,0),
00063                      UInt_t dbNo = 0,
00064                      const std::string& logComment = "",
00065                      const std::string& tableName = "");
00066            DbiWriter(const DbiValidityRec& vrec,
00067                      const std::string& dbName,
00068                      const std::string& logComment = "");
00069            DbiWriter(const DbiValidityRec& vrec,
00070                      UInt_t dbNo = 0,
00071                      const std::string& logComment = "");
00072 
00073   virtual ~DbiWriter();
00074 
00075 // State testing member functions
00076 
00077        DbiTableProxy& TableProxy() const;
00078 
00080           Bool_t IsOpen(Bool_t reportErrors = kTRUE) const;
00082           Bool_t CanOutput(Bool_t reportErrors = kTRUE) const;
00083 
00084 // State changing member functions
00085 
00086     void SetDbNo(UInt_t dbNo) { fDbNo = dbNo;}
00087     void SetDbName(const string& dbName);
00088     void SetLogComment(const std::string& reason);
00089     // For setting of requireGlobal see DbiCascader::AllocateSeqNo
00090     void SetRequireGlobalSeqno(Int_t requireGlobal) {fRequireGlobalSeqno = requireGlobal;}
00091     void SetOverlayCreationDate() {fUseOverlayCreationDate = kTRUE;}
00092 
00093 //  I/O functions
00094   void Abort() { Reset(); }
00095   Bool_t Close(const char* fileSpec=0);
00096   Bool_t Open(const VldRange& vr,
00097             Int_t aggNo,
00098             Dbi::Task task,
00099             VldTimeStamp creationDate,
00100             const string& dbName,
00101             const std::string& logComment = "");
00102    Bool_t Open(const VldRange& vr,
00103             Int_t aggNo,
00104             Dbi::Task task = 0,
00105             VldTimeStamp creationDate = VldTimeStamp(),
00106             UInt_t dbNo = 0,
00107             const std::string& logComment = "");
00108  Bool_t Open(const DbiValidityRec& vrec,
00109              const string& dbName,
00110              const std::string& logComment = "");
00111  Bool_t Open(const DbiValidityRec& vrec,
00112               UInt_t dbNo = 0,
00113               const std::string& logComment = "");
00114 
00115   DbiWriter<T>& operator<<(const T& row);
00116 
00117 private:  
00118 
00119 // State testing member functions
00120 
00121   Bool_t NeedsLogEntry() const;
00122   Bool_t WritingToMaster() const;
00123 
00124 // State changing member functions
00125 
00126 DbiWriter(const DbiWriter&); // Forbidden
00127 DbiWriter& operator=(const DbiWriter&); // Forbidden
00128 
00129     void CompleteOpen(UInt_t dbNo = 0,
00130                       const std::string& logComment = "");
00131     void Reset();
00132 
00133 static DbiTableProxy& GetTableProxy();
00134 static DbiTableProxy& GetTableProxy(const std::string& tableName);
00135 
00136 // Data members
00137 
00139   Int_t fAggregateNo;   
00140 
00142   UInt_t fDbNo;          
00143 
00145   DbiSqlValPacket* fPacket;        
00146 
00148   Int_t fRequireGlobalSeqno;     
00149 
00151   DbiTableProxy* fTableProxy;    
00152 
00154   std::string fTableName;     
00155 
00157   Bool_t fUseOverlayCreationDate;
00158 
00160   DbiValidityRec* fValidRec;      
00161 
00163   DbiLogEntry fLogEntry;      
00164 
00165 ClassDefT(DbiWriter<T>,0)          // Writer for specific database table. 
00166 
00167 };
00168 ClassDefT2(DbiWriter,T)
00169 
00170 #endif  // DBIWRITER_H

Generated on Mon Feb 15 11:06:35 2010 for loon by  doxygen 1.3.9.1