EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FairDbSqlValPacket.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FairDbSqlValPacket.h
1 #ifndef FAIRDBSQLVALPACKET
2 #define FAIRDBSQLVALPACKET
3 
4 
5 #include <fstream>
6 #include <list>
7 #include <vector>
8 #include <string>
9 using std::string;
10 
11 #if !defined(__CINT__) || defined(__MAKECINT__)
12 #include "Rtypes.h"
13 #endif
14 
15 #include "ValTimeStamp.h"
16 
17 class FairDbTableRow;
18 class FairDbValidityRec;
19 class VldRange;
20 
22 {
23 
24  public:
25 
26 // Types and enum
27 
28  typedef enum ECompResult {
33  } CompResult_t;
34 
35 // Constructors and destructors.
37  FairDbSqlValPacket(std::ifstream& is);
39  virtual ~FairDbSqlValPacket();
40 
41 // State testing member functions
42  Bool_t CanBeStored() const {
43  return (fSeqNo > 0 && fNumErrors == 0 && this->GetNumSqlStmts()> 0)
44  ? kTRUE : kFALSE;
45  };
47  Bool_t log = kFALSE,
48  const Char_t* thisName = "this",
49  const Char_t* thatName = "that" ) const;
50  Bool_t CreateTable(UInt_t dbNo) const;
51  UInt_t GetNumErrors() const { return fNumErrors; }
52  UInt_t GetNumSqlStmts() const { return fNumStmts; }
53  UInt_t GetSeqNo() const { return fSeqNo; }
55  string GetStmt(UInt_t stmtNo) const;
56  std::vector<string> GetStmtValues(UInt_t stmtNo) const;
57  const string& GetTableName() const { return fTableName; }
58  Bool_t IsEqual(const FairDbSqlValPacket& that,
59  Bool_t log = kFALSE,
60  const Char_t* thisName = "this",
61  const Char_t* thatName = "that" ) const;
62 
63 // I/O
64  Bool_t Fill(std::ifstream& is);
65  Bool_t Store(UInt_t dbNo, Bool_t replace = kFALSE) const;
66  Bool_t Write(std::ofstream& ios,
67  Bool_t addMetadata = kFALSE) const;
68 
69 // Reconstruct.
70  void Recreate(const string& tableName,
71  const ValRange& vr,
72  Int_t aggNo,
73  FairDb::Task task = 0,
74  ValTimeStamp creationDate = ValTimeStamp());
75  Bool_t AddDataRow(const FairDbTableProxy& tblProxy,
76  const FairDbValidityRec* vrec,
77  const FairDbTableRow& row);
78 
79 // State changing member functions
80  void Clear() { this->Reset(); fNumErrors = 0; }
82  void SetSeqNo(UInt_t seqno);
83  void Reset(); //Doesn't clear fNumErrors.
84 
85  virtual void Print(Option_t* option="") const;
86 
87  protected:
88 
89  private:
90  void AddRow(const string& row);
91  Bool_t AddRow(const FairDbTableProxy& tblProxy,
92  const FairDbValidityRec* vrec,
93  const FairDbTableRow& row);
94  void Report(const char* msg,
95  UInt_t line_num,
96  const string& line);
97  void SetMetaData() const;
98  void SetSeqNoOnRow(string& row,const string& seqno);
99 
100  static Bool_t fgLastMetaHadRowCounter; // Ugly hack during transition to ROW_COUNTER tables.
101  FairDbSqlValPacket(const FairDbSqlValPacket& ); // Not allowed.
102 
103 
104 // Data members
105 
107  UInt_t fNumErrors;
108 
110  UInt_t fSeqNo;
111 
113  mutable string fSqlMySqlMetaMain;
114 
116  mutable string fSqlMySqlMetaVal;
117 
119  std::list<string> fSqlStmts;
120 
122  UInt_t fNumStmts;
123 
125  string fTableName;
126 
129 
130  ClassDef(FairDbSqlValPacket,0) // SQL to generate Validity Packet.
131 
132 };
133 #endif // FAIRDBSQLVALPACKET