/search.css" rel="stylesheet" type="text/css"/> /search.js">
00001 #ifndef DBISQLVALPACKET 00002 #define DBISQLVALPACKET 00003 00027 #include <fstream> 00028 #include <list> 00029 #include <vector> 00030 #include <string> 00031 #include "DatabaseInterface/Dbi.h" 00032 #include "DatabaseInterface/DbiTableProxy.h" 00033 using std::string; 00034 00035 #if !defined(__CINT__) || defined(__MAKECINT__) 00036 #include "Rtypes.h" 00037 #endif 00038 00039 #include "Context/TimeStamp.h" 00040 00041 class DbiTableRow; 00042 class DbiValidityRec; 00043 class ContextRange; 00044 00045 class DbiSqlValPacket 00046 { 00047 00048 public: 00049 00050 // Types and enum 00051 00052 typedef enum ECompResult { 00053 kIdentical, 00054 kUpdate, 00055 kOutOfDate, 00056 kConflict 00057 } CompResult_t; 00058 00059 // Constructors and destructors. 00060 DbiSqlValPacket(); 00061 DbiSqlValPacket(std::ifstream& is); 00062 DbiSqlValPacket(const DbiValidityRec& vrec); 00063 virtual ~DbiSqlValPacket(); 00064 00065 // State testing member functions 00066 Bool_t CanBeStored() const { 00067 return (fSeqNo > 0 && fNumErrors == 0 && this->GetNumSqlStmts()> 0) 00068 ? kTRUE : kFALSE; }; 00069 CompResult_t Compare(const DbiSqlValPacket& that, 00070 Bool_t log = kFALSE, 00071 const Char_t* thisName = "this", 00072 const Char_t* thatName = "that" ) const; 00073 Bool_t CreateTable(UInt_t dbNo) const; 00074 UInt_t GetNumErrors() const { return fNumErrors; } 00075 UInt_t GetNumSqlStmts() const { return fNumStmts; } 00076 UInt_t GetSeqNo() const { return fSeqNo; } 00077 TimeStamp GetVersionDate() const { return fVersionDate; } 00078 string GetStmt(UInt_t stmtNo) const; 00079 std::vector<string> GetStmtValues(UInt_t stmtNo) const; 00080 const string& GetTableName() const{ return fTableName; } 00081 Bool_t IsEqual(const DbiSqlValPacket& that, 00082 Bool_t log = kFALSE, 00083 const Char_t* thisName = "this", 00084 const Char_t* thatName = "that" ) const; 00085 00086 // I/O 00087 Bool_t Fill(std::ifstream& is); 00088 Bool_t Store(UInt_t dbNo, Bool_t replace = kFALSE) const; 00089 Bool_t Write(std::ofstream& ios, 00090 Bool_t addMetadata = kFALSE) const; 00091 00092 // Reconstruct. 00093 void Recreate(const string& tableName, 00094 const ContextRange& vr, 00095 Int_t aggNo, 00096 Dbi::SubSite subsite = 0, 00097 Dbi::Task task = 0, 00098 TimeStamp versionDate = TimeStamp()); 00099 Bool_t AddDataRow(const DbiTableProxy& tblProxy, 00100 const DbiValidityRec* vrec, 00101 const DbiTableRow& row); 00102 00103 // State changing member functions 00104 void Clear() { this->Reset(); fNumErrors = 0; } 00105 void SetVersionDate(TimeStamp ts); 00106 void SetSeqNo(UInt_t seqno); 00107 void Reset(); //Doesn't clear fNumErrors. 00108 00109 virtual void Print(Option_t *option="") const; 00110 00111 protected: 00112 00113 private: 00114 void AddRow(const string & row); 00115 Bool_t AddRow(const DbiTableProxy& tblProxy, 00116 const DbiValidityRec* vrec, 00117 const DbiTableRow& row); 00118 void Report(const char* msg, 00119 UInt_t line_num, 00120 const string& line); 00121 void SetMetaData() const; 00122 void SetSeqNoOnRow(string& row,const string& seqno); 00123 00124 static Bool_t fgLastMetaHadRowCounter; // Ugly hack during transition to ROW_COUNTER tables. 00125 DbiSqlValPacket(const DbiSqlValPacket& ); // Not allowed. 00126 00127 00128 // Data members 00129 00131 UInt_t fNumErrors; 00132 00134 UInt_t fSeqNo; 00135 00137 mutable string fSqlMySqlMetaMain; 00138 00140 mutable string fSqlMySqlMetaVld; 00141 00143 std::list<string> fSqlStmts; 00144 00146 UInt_t fNumStmts; 00147 00149 string fTableName; 00150 00152 TimeStamp fVersionDate; 00153 00154 // Removed: ClassDef(DbiSqlValPacket,0) // SQL to generate Validity Packet. 00155 00156 }; 00157 #endif // DBISQLVALPACKET