TDbiEpochRollback.cxx

Go to the documentation of this file.
00001 ///////////////////////////////////////////////////////////////////////
00002 // $Id: TDbiEpochRollback.cxx,v 1.1 2011/01/18 05:49:19 finch Exp $
00003 //
00004 // TDbiEpochRollback
00005 
00006 #include <cstring>
00007 #include <sstream>
00008 
00009 #include "TString.h"
00010 
00011 #include "TDbi.hxx"
00012 #include "TDbiEpochRollback.hxx"
00013 #include <TSK_DBI_Log.hxx>
00014 #include <MsgFormat.h>
00015 using std::endl;
00016 #include "TDbiRegistry.hxx"
00017 #include "UtilString.hxx"
00018 #include "TVldTimeStamp.hxx"
00019 
00020 ClassImp(TDbiEpochRollback)
00021 
00022 //   Definition of static data members
00023 //   *********************************
00024 
00025 
00026 // Definition of member functions (alphabetical order)
00027 // ***************************************************
00028 
00029 
00030 //.....................................................................
00031 
00032 TDbiEpochRollback::TDbiEpochRollback()
00033 {
00034 //
00035 //
00036 //  Purpose:  Default constructor
00037 //
00038 //  Contact:   N. West
00039 //
00040 //  Specification:-
00041 //  =============
00042 //
00043 //  o Create TDbiEpochRollback.
00044 
00045 
00046 //  Program Notes:-
00047 //  =============
00048 
00049 //  None.
00050 
00051 
00052     SK_DBI_Trace( "Creating TDbiEpochRollback" << "  ");
00053 }
00054 //.....................................................................
00055 
00056 TDbiEpochRollback::~TDbiEpochRollback() {
00057 //
00058 //
00059 //  Contact:   N. West
00060 //
00061 //  Specification:-
00062 //  =============
00063 //
00064 //  o  Destroy TDbiEpochRollback.
00065 
00066 
00067 
00068   SK_DBI_Trace( "Destroying TDbiEpochRollback" << "  ");
00069 
00070 }
00071 //.....................................................................
00072 
00073 const std::string& TDbiEpochRollback::GetEpochCondition(const std::string& tableName) const {
00074 //
00075 //
00076 //  Purpose:  Return epoch rollback condition  associated with named table.
00077 //            - returns an empty string if there is no associated condition
00078 //
00079 //  Contact:   N. West
00080 
00081 //  Program Notes:-
00082 //  =============
00083 
00084 //  Search in reverse order so that specific entries are processed
00085 //  before generic (i.e. ones that end in wildcard *).
00086 
00087   static std::string condition;
00088 
00089   condition = "";
00090 
00091   name_map_t::const_reverse_iterator itr    = fTableToEpoch.rbegin();
00092   name_map_t::const_reverse_iterator itrEnd = fTableToEpoch.rend();
00093 
00094   for (; itr != itrEnd; ++itr) {
00095     if ( ! UtilString::cmp_wildcard(tableName,itr->first) ) {
00096       ostringstream condition_stream;
00097       condition_stream << "EPOCH <= ";
00098       condition_stream << itr->second;
00099       condition = condition_stream.str();
00100       return condition;
00101     }
00102   }
00103   return condition;
00104 }
00105 
00106 //.....................................................................
00107 
00108 void TDbiEpochRollback::Set(TDbiRegistry& reg) {
00109 //
00110 //
00111 //  Purpose:  Extract epoch Rollback from TDbiRegistry.
00112 //
00113 //  Arguments:
00114 //    reg          in    TDbiRegistry containing "EpochRollback:"
00115 //                 out   Updated TDbiRegistry with this key removed.
00116 //
00117 //  Contact:   N. West
00118 //
00119 //  Specification:-
00120 //  =============
00121 //
00122 //  o Extract epoch Rollback from TDbiRegistry.
00123 
00124   TDbiRegistry::TDbiRegistryKey keyItr(&reg);
00125 
00126   Bool_t  hasChanged = kFALSE;
00127 
00128   const char* key = keyItr();
00129   while ( key ) {
00130 
00131     const char* nextKey =  keyItr();
00132 
00133     // Process EpochRollback keys
00134 
00135     if ( ! strncmp("EpochRollback:",key,14) ) {
00136       std::string tableName = key+14;
00137       Int_t epoch;
00138       bool  ok = reg.Get(key,epoch);
00139       if ( ok ) {
00140         fTableToEpoch[tableName] = epoch;
00141         hasChanged = kTRUE;
00142 
00143       }
00144       else SK_DBI_Warn(  "Illegal EpochRollback registry item: " << key
00145         << " = " <<  reg.GetValueAsString(key) << "  ");
00146       reg.RemoveKey(key);
00147     }
00148     key = nextKey;
00149   }
00150 
00151   if ( hasChanged ) this->Show();
00152 }
00153 //.....................................................................
00154 
00155 void TDbiEpochRollback::Show() const {
00156 
00157 }
00158 
00159 
00160 

Generated on 11 Aug 2013 for SKDatabase by  doxygen 1.6.1