TDbiEpochRollback.cxx
Go to the documentation of this file.00001
00002
00003
00004
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
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 TDbiEpochRollback::TDbiEpochRollback()
00033 {
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 SK_DBI_Trace( "Creating TDbiEpochRollback" << " ");
00053 }
00054
00055
00056 TDbiEpochRollback::~TDbiEpochRollback() {
00057
00058
00059
00060
00061
00062
00063
00064
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
00077
00078
00079
00080
00081
00082
00083
00084
00085
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
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 TDbiRegistry::TDbiRegistryKey keyItr(®);
00125
00126 Bool_t hasChanged = kFALSE;
00127
00128 const char* key = keyItr();
00129 while ( key ) {
00130
00131 const char* nextKey = keyItr();
00132
00133
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