Concept A register of rollback epochs organised by table name More...
#include <TDbiEpochRollback.hxx>
Public Types | |
typedef std::map< std::string, UInt_t > | name_map_t |
Public Member Functions | |
TDbiEpochRollback () | |
virtual | ~TDbiEpochRollback () |
const std::string & | GetEpochCondition (const std::string &tableName) const |
void | Show () const |
void | Clear () |
void | Set (TDbiRegistry ®) |
Private Attributes | |
name_map_t | fTableToEpoch |
Look-up table name -> maximum epoch number. |
Concept A register of rollback epochs organised by table name
Purpose Simplify epoch rollback management by extracting info. from DBI registry and serving by table name Contact: A.Finch@lancaster.ac.uk
Definition at line 34 of file TDbiEpochRollback.hxx.
typedef std::map<std::string,UInt_t> TDbiEpochRollback::name_map_t |
Definition at line 39 of file TDbiEpochRollback.hxx.
TDbiEpochRollback::TDbiEpochRollback | ( | ) |
TDbiEpochRollback::~TDbiEpochRollback | ( | ) | [virtual] |
Definition at line 56 of file TDbiEpochRollback.cxx.
References SK_DBI_Trace.
00056 { 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 }
void TDbiEpochRollback::Clear | ( | ) | [inline] |
Definition at line 52 of file TDbiEpochRollback.hxx.
References fTableToEpoch.
Referenced by TDbiDatabaseManager::ClearRollbacks().
00052 {fTableToEpoch.clear();}
const std::string & TDbiEpochRollback::GetEpochCondition | ( | const std::string & | tableName | ) | const |
Definition at line 73 of file TDbiEpochRollback.cxx.
References UtilString::cmp_wildcard(), and fTableToEpoch.
Referenced by TDbiDatabaseManager::ApplySqlCondition().
00073 { 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 }
void TDbiEpochRollback::Set | ( | TDbiRegistry & | reg | ) |
Definition at line 108 of file TDbiEpochRollback.cxx.
References fTableToEpoch, TDbiRegistry::Get(), TDbiRegistry::GetValueAsString(), TDbiRegistry::RemoveKey(), Show(), and SK_DBI_Warn.
Referenced by TDbiDatabaseManager::Config().
00108 { 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(®); 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 }
void TDbiEpochRollback::Show | ( | ) | const |
Definition at line 155 of file TDbiEpochRollback.cxx.
Referenced by Set().
name_map_t TDbiEpochRollback::fTableToEpoch [private] |
Look-up table name -> maximum epoch number.
Definition at line 60 of file TDbiEpochRollback.hxx.
Referenced by Clear(), GetEpochCondition(), and Set().