/////////////////////////////////////////////////////////////////////// // $Id: IDbiEpochRollback.cxx,v 1.1 2011/01/18 05:49:19 finch Exp $ // // COMET::IDbiEpochRollback #include #include #include "TString.h" #include "IDbi.hxx" #include "IDbiEpochRollback.hxx" #include #include using std::endl; #include "IDbiRegistry.hxx" #include "UtilString.hxx" #include "IVldTimeStamp.hxx" ClassImp(COMET::IDbiEpochRollback) // Definition of static data members // ********************************* // Definition of member functions (alphabetical order) // *************************************************** //..................................................................... COMET::IDbiEpochRollback::IDbiEpochRollback() { // // // Purpose: Default constructor // // Contact: N. West // // Specification:- // ============= // // o Create COMET::IDbiEpochRollback. // Program Notes:- // ============= // None. COMETTrace( "Creating COMET::IDbiEpochRollback" << " "); } //..................................................................... COMET::IDbiEpochRollback::~IDbiEpochRollback() { // // // Contact: N. West // // Specification:- // ============= // // o Destroy COMET::IDbiEpochRollback. COMETTrace( "Destroying COMET::IDbiEpochRollback" << " "); } //..................................................................... const std::string& COMET::IDbiEpochRollback::GetEpochCondition(const std::string& tableName) const { // // // Purpose: Return epoch rollback condition associated with named table. // - returns an empty string if there is no associated condition // // Contact: N. West // Program Notes:- // ============= // Search in reverse order so that specific entries are processed // before generic (i.e. ones that end in wildcard *). static std::string condition; condition = ""; name_map_t::const_reverse_iterator itr = fTableToEpoch.rbegin(); name_map_t::const_reverse_iterator itrEnd = fTableToEpoch.rend(); for (; itr != itrEnd; ++itr) { if ( ! COMET::UtilString::cmp_wildcard(tableName,itr->first) ) { ostringstream condition_stream; condition_stream << "EPOCH <= "; condition_stream << itr->second; condition = condition_stream.str(); return condition; } } return condition; } //..................................................................... void COMET::IDbiEpochRollback::Set(IDbiRegistry& reg) { // // // Purpose: Extract epoch Rollback from IDbiRegistry. // // Arguments: // reg in IDbiRegistry containing "EpochRollback:" // out Updated IDbiRegistry with this key removed. // // Contact: N. West // // Specification:- // ============= // // o Extract epoch Rollback from IDbiRegistry. IDbiRegistry::IDbiRegistryKey keyItr(®); Bool_t hasChanged = kFALSE; const char* key = keyItr(); while ( key ) { const char* nextKey = keyItr(); // Process EpochRollback keys if ( ! strncmp("EpochRollback:",key,14) ) { std::string tableName = key+14; Int_t epoch; bool ok = reg.Get(key,epoch); if ( ok ) { fTableToEpoch[tableName] = epoch; hasChanged = kTRUE; } else COMETWarn( "Illegal EpochRollback registry item: " << key << " = " << reg.GetValueAsString(key) << " "); reg.RemoveKey(key); } key = nextKey; } if ( hasChanged ) this->Show(); } //..................................................................... void COMET::IDbiEpochRollback::Show() const { // // // Purpose: Print out the current EpochRollback status. // // // Contact: N. West // std::ostream& msg=ICOMETLog::GetLogStream(); msg << "\n\nEpochRollback Status: "; if ( fTableToEpoch.size() == 0 ) msg <<"Not enabled" << endl; else { msg << "Maximum EPOCH limits:- " << endl; name_map_t::const_reverse_iterator itr = fTableToEpoch.rbegin(); name_map_t::const_reverse_iterator itrEnd = fTableToEpoch.rend(); for (; itr != itrEnd; ++itr) { std::string name = itr->first; if ( name.size() < 30 ) name.append(30-name.size(),' '); msg <<" " << name << " " << itr->second << endl; } } }