TDbiLogEntry.hxx

Go to the documentation of this file.
00001 #ifndef DBILOGENTRY_H
00002 #define DBILOGENTRY_H
00003 
00004 /**
00005  *
00006  * $Id: TDbiLogEntry.hxx,v 1.1 2011/01/18 05:49:20 finch Exp $
00007  *
00008  * \class TDbiLogEntry
00009  *
00010  *
00011  * \brief
00012  * <b>Concept</b>  An single entry in the Database Log which records
00013  *   all non-automatic updates to the database.
00014  *
00015  * \brief
00016  * <b>Purpose</b> Capture and present updates together with the reasons
00017  *   for them.
00018  *
00019  * Contact: A.Finch@lancaster.ac.uk
00020  *
00021  *
00022  */
00023 
00024 #include <string>
00025 using std::string;
00026 #include <iosfwd>
00027 
00028 #include "TObject.h"
00029 
00030 #include "DbiDetector.hxx"
00031 #include "DbiSimFlag.hxx"
00032 #include "TDbi.hxx"
00033 #include "TDbiTableRow.hxx"
00034 #include "TVldTimeStamp.hxx"
00035 
00036 #include "TDbiResultSetHandle.hxx"    //Needed for LinkDef
00037 //#include "TDbiWriter.hxx"    //Needed for LinkDef
00038 
00039 
00040 class TDbiLogEntry;
00041 class TDbiOutRowStream;
00042 class TDbiInRowStream;
00043 class TDbiTableProxy;
00044 class TDbiValidityRec;
00045 
00046 
00047 std::ostream& operator<<(std::ostream& s, const TDbiLogEntry& logEntry);
00048 
00049 class TDbiLogEntry : public TDbiTableRow
00050 {
00051 
00052 public:
00053 
00054   using TObject::Write;
00055 
00056 // Constructors and destructors.
00057   TDbiLogEntry(const string& tableName = "",
00058               const string& reason = "",
00059               Int_t detMask = DbiDetector::FullMask(),
00060               Int_t simMask = DbiSimFlag::FullMask(),
00061               TDbi::Task task = 0,
00062               Int_t logSeqNoMin = 0,
00063               Int_t logSeqNoMax = 0,
00064               Int_t logNumSeqNo = 0);
00065   virtual ~TDbiLogEntry();
00066 
00067 // State testing member functions.
00068 
00069 // Inherited responsibilities.
00070   virtual TDbiTableRow* CreateTableRow() const {
00071                                               return new TDbiLogEntry; }
00072          Int_t GetAggregateNo() const { return -1; }
00073 
00074 // New member functions.
00075  const string& GetLogTableName() const { return fLogTableName; }
00076          Int_t GetDetectorMask() const { return fLogDetMask; }
00077          Int_t GetLogSeqNoMin() const { return fLogSeqNoMin; }
00078          Int_t GetLogSeqNoMax() const { return fLogSeqNoMax; }
00079          Int_t GetLogNumSeqNo() const { return fLogNumSeqNo; }
00080          Int_t GetSimMask() const { return fLogSimMask; }
00081      TDbi::Task GetTask() const { return fLogTask; }
00082  const string& GetUserName() const { return fUserName; }
00083  const string& GetProcessName() const { return fProcessName; }
00084  const string& GetHostName() const { return fHostName; }
00085  const string& GetServerName() const { return fServerName; }
00086  const string& GetReason() const { return fReason; }
00087   TVldTimeStamp GetUpdateTime() const { return fUpdateTime; }
00088 
00089         Bool_t HasReason() const { return fReason.size() > 0; }
00090 
00091 // State changing member functions
00092           void SetReason(const string& reason);
00093           void SetDetectorMask(Int_t detMask) { fLogDetMask = detMask; }
00094           void SetSimMask(Int_t simMask) { fLogSimMask = simMask; }
00095           void SetTask(TDbi::Task task) { fLogTask = task; }
00096           void SetUpdateTime(const TVldTimeStamp& updateTime) {
00097                                          fUpdateTime = updateTime; }
00098           void Recreate (const string& tableName = "",
00099                          const string& reason = "",
00100                          Int_t detMask = DbiDetector::FullMask(),
00101                          Int_t simMask = DbiSimFlag::FullMask(),
00102                          TDbi::Task task = 0,
00103                          Int_t logSeqNoMin = 0,
00104                          Int_t logSeqNoMax = 0,
00105                          Int_t logNumSeqNo = 0);
00106 
00107 // I/O  member functions
00108   virtual void Fill(TDbiInRowStream& rs,
00109                     const TDbiValidityRec* vrec);
00110   virtual void Store(TDbiOutRowStream& ors,
00111                     const TDbiValidityRec* vrec) const;
00112   Bool_t Write(UInt_t dbNo,Int_t logSeqNo=0);
00113 
00114 private:
00115 // Constructors and destructors.
00116   TDbiLogEntry(const TDbiLogEntry& from); // No!
00117 
00118   void SetServerName();
00119 
00120 // Data members
00121 
00122 /// Database no. written to. =0 if not output
00123   UInt_t fDbNo;
00124 
00125 /// Seq. No. used to write this object. =0 if not output
00126   Int_t fSeqNo;
00127 
00128 /// Table being updated.
00129   string fLogTableName;
00130 
00131 /// Detector type mask of update.
00132   Int_t fLogDetMask;
00133 
00134 /// SimFlag  mask of update.
00135   Int_t fLogSimMask;
00136 
00137 /// Task of update
00138   TDbi::Task fLogTask;
00139 
00140 /// Minimum Seq. No. being updated.
00141   Int_t fLogSeqNoMin;
00142 
00143 /// Maximum Seq. No. being updated.
00144   Int_t fLogSeqNoMax;
00145 
00146 /// Number of Seq. Nos. being updated.
00147   Int_t fLogNumSeqNo;
00148 
00149 /// Time of update.
00150   TVldTimeStamp fUpdateTime;
00151 
00152 /// User performing update.
00153   string fUserName;
00154 
00155 /// Process performing update.
00156   string fProcessName;
00157 
00158 /// Host performing update.
00159   string fHostName;
00160 
00161 /// Db server being updated.
00162   string fServerName;
00163 
00164 /// Reason for update.
00165   string fReason;
00166 
00167 
00168 // Note: fLogDetMask,fLogSimMask,fLogTask,fUpdateTime are used to construct the TDbiValidityRec
00169 //       of the update; they are not store in main table.
00170 
00171 ClassDef(TDbiLogEntry,0)    // Configuration data.
00172 
00173 };
00174 
00175 
00176 
00177 #endif  // DBILOGENTRY_H
00178 

Generated on 11 Aug 2013 for SKDatabase by  doxygen 1.6.1