Collaboration diagram for UpdateManagerSvc::Item:
Public Types | |
typedef std::pair< BasePtrSetter *, void * > | UserPtrType |
Type for the list of user's pointers for the condition. | |
typedef std::vector< Item * > | ItemList |
Type used for the collections of items. | |
typedef std::pair< Item *, BaseObjectMemberFunction * > | ParentItem |
Type used as pointer to an item that is using this one, a parent. | |
typedef std::vector< ParentItem > | ParentList |
Type for the list of parents. | |
typedef std::list< UserPtrType > | UserPtrList |
Type for the list of user's pointers for the condition. | |
typedef std::vector< MembFunc > | MembFuncList |
Type for the list of the registered member functions. | |
Public Member Functions | |
Item (const std::string &objPath, ValidDataObject *overrideObj=NULL) | |
Constructor for an item representing an object in the data store. | |
Item (const std::string &objPath, UserPtrType dest, ValidDataObject *overrideObj=NULL) | |
Constructor for an item representing an object in the data store. | |
Item (BaseObjectMemberFunction *mf, const std::string tsRoot) | |
Constructor for an item representing a generic object. | |
~Item () | |
Destructor. | |
bool | isValid (const Gaudi::Time &when) |
void | resetIOV () |
void | invalidate () |
void | changeValidity (const Gaudi::Time &new_since, const Gaudi::Time &new_until) |
void | purge (MsgStream *log=NULL) |
StatusCode | setUserPointers (DataObject *pObj, bool force=false) |
StatusCode | setPointers (DataObject *pObj, bool force=false) |
StatusCode | update (IDataProviderSvc *dp, const Gaudi::Time &when, MsgStream *log=NULL) |
Main method. Used to update the object and all the used ones. | |
bool | match (void *p) const |
Tells if this item represents the given pointer. | |
bool | match (const std::string &p, bool is_path_to_db=false) const |
Tells if this item represents object identified by the given pointer. | |
bool | isHead () const |
Tells if the item does not have parents. | |
bool | isTail () const |
Tells if the item does not have parents. | |
MembFuncList::iterator | find (BaseObjectMemberFunction *mf) |
Finds the MembFunc object containing the given member function. | |
void | addParent (Item *parent, BaseObjectMemberFunction *parentMF) |
Adds a (item,member_function) pair to the list of parents. | |
BaseObjectMemberFunction * | addChild (BaseObjectMemberFunction *thisMF, Item *child) |
Adds a child item to the given member function. | |
Public Attributes | |
Gaudi::Time | since |
Time points delimiting the interval of validity of the item (intersection of the intervals of validity of the member functions). | |
Gaudi::Time | until |
ParentList | parents |
Item parents: the (item,member_function) pairs that depend on this item. | |
ItemList | children |
List of all the children: the items on which this item depend (used for fast accessing). | |
std::string | path |
Path to the object, inside the data store, represented by the item. | |
std::string | db_path |
Path of the persistent version of the object inside the Conditions DataBase. | |
ValidDataObject * | vdo |
Pointer to the ValidDataObject interface of the represented object. | |
void * | ptr |
Void pointer to the represented object, obtained via dynamic_cast (used to unically identify the item). | |
ValidDataObject * | override |
Pointer to the object used to override the object retrieved from the data provider. | |
MembFuncList | memFuncs |
List of the registered member functions. | |
bool | updateLock |
Flag used to prevent infinite loops when updating. | |
UserPtrList | user_dest_ptrs |
List op setters for user's pointers. | |
Classes | |
struct | MembFunc |
Used inside Item to identify a registered member function. More... |
Definition at line 128 of file UpdateManagerSvc.h.
typedef std::pair<BasePtrSetter*,void*> UpdateManagerSvc::Item::UserPtrType |
Type for the list of user's pointers for the condition.
Definition at line 130 of file UpdateManagerSvc.h.
typedef std::vector<Item*> UpdateManagerSvc::Item::ItemList |
typedef std::pair<Item*,BaseObjectMemberFunction*> UpdateManagerSvc::Item::ParentItem |
Type used as pointer to an item that is using this one, a parent.
Definition at line 174 of file UpdateManagerSvc.h.
typedef std::vector<ParentItem> UpdateManagerSvc::Item::ParentList |
typedef std::list<UserPtrType> UpdateManagerSvc::Item::UserPtrList |
Type for the list of user's pointers for the condition.
Definition at line 178 of file UpdateManagerSvc.h.
typedef std::vector<MembFunc> UpdateManagerSvc::Item::MembFuncList |
Type for the list of the registered member functions.
Definition at line 209 of file UpdateManagerSvc.h.
UpdateManagerSvc::Item::Item | ( | const std::string & | objPath, | |
ValidDataObject * | overrideObj = NULL | |||
) | [inline] |
Constructor for an item representing an object in the data store.
Definition at line 135 of file UpdateManagerSvc.h.
UpdateManagerSvc::Item::Item | ( | const std::string & | objPath, | |
UserPtrType | dest, | |||
ValidDataObject * | overrideObj = NULL | |||
) | [inline] |
Constructor for an item representing an object in the data store.
Definition at line 141 of file UpdateManagerSvc.h.
UpdateManagerSvc::Item::Item | ( | BaseObjectMemberFunction * | mf, | |
const std::string | tsRoot | |||
) | [inline] |
Constructor for an item representing a generic object.
Definition at line 150 of file UpdateManagerSvc.h.
UpdateManagerSvc::Item::~Item | ( | ) |
Destructor.
Definition at line 22 of file UpdateManagerSvc_Item.cpp.
00022 { 00023 for (MembFuncList::const_iterator mi = memFuncs.begin(); 00024 mi != memFuncs.end(); ++mi) { 00025 delete mi->mf; 00026 delete mi->items; 00027 } 00028 // I'm the owner of the list of user's pointer setters: delete them! 00029 for (UserPtrList::iterator pi = user_dest_ptrs.begin(); 00030 pi != user_dest_ptrs.end(); ++pi){ 00031 delete pi->first; 00032 } 00033 }
bool UpdateManagerSvc::Item::isValid | ( | const Gaudi::Time & | when | ) | [inline] |
Definition at line 211 of file UpdateManagerSvc.h.
void UpdateManagerSvc::Item::resetIOV | ( | ) | [inline] |
Definition at line 214 of file UpdateManagerSvc.h.
void UpdateManagerSvc::Item::invalidate | ( | ) | [inline] |
Definition at line 216 of file UpdateManagerSvc.h.
void UpdateManagerSvc::Item::changeValidity | ( | const Gaudi::Time & | new_since, | |
const Gaudi::Time & | new_until | |||
) | [inline] |
Definition at line 224 of file UpdateManagerSvc.h.
void UpdateManagerSvc::Item::purge | ( | MsgStream * | log = NULL |
) |
Definition at line 214 of file UpdateManagerSvc_Item.cpp.
00214 { 00215 if ( ! path.empty() ) { 00216 if (log) (*log) << MSG::DEBUG << "Purging " << path << endmsg; 00217 // Clean up pointers 00218 const bool force = true; 00219 setPointers(NULL,force).ignore(); 00220 } else { 00221 if (log) (*log) << MSG::DEBUG << "Purging object at " << ptr << endmsg; 00222 } 00223 00224 // I'm not sure I need this 00225 // invalidate(); 00226 // or just this 00227 since = 1; 00228 until = 0; 00229 }
StatusCode UpdateManagerSvc::Item::setUserPointers | ( | DataObject * | pObj, | |
bool | force = false | |||
) | [inline] |
Definition at line 277 of file UpdateManagerSvc.h.
StatusCode UpdateManagerSvc::Item::setPointers | ( | DataObject * | pObj, | |
bool | force = false | |||
) | [inline] |
Definition at line 292 of file UpdateManagerSvc.h.
StatusCode UpdateManagerSvc::Item::update | ( | IDataProviderSvc * | dp, | |
const Gaudi::Time & | when, | |||
MsgStream * | log = NULL | |||
) |
Main method. Used to update the object and all the used ones.
Definition at line 37 of file UpdateManagerSvc_Item.cpp.
00037 { 00038 if (log){ 00039 (*log) << MSG::DEBUG << "Updating (Item* " << this << ") " << ptr << " ---BEGIN---"; 00040 if (!path.empty()) (*log) << " " << path; 00041 (*log) << endmsg; 00042 (*log) << MSG::VERBOSE << " initial validity: " << since << " -> " << until << endmsg; 00043 } 00044 if (updateLock) { 00045 if (log) (*log) << MSG::VERBOSE << "Update lock found: break loop" << endmsg; 00046 return StatusCode::SUCCESS; 00047 } 00048 // check validity 00049 if (isValid(when)) { 00050 if (log) (*log) << MSG::VERBOSE << "Item valid, not need to update" << endmsg; 00051 return StatusCode::SUCCESS; 00052 } 00053 // prepare for update 00054 updateLock = true; 00055 resetIOV(); 00056 StatusCode sc; 00057 // start real update 00058 if (ptr == NULL && vdo == NULL && !path.empty()) { // I do not have a VDO ptr (or a void*) but a path: load it 00059 00060 if (log) (*log) << MSG::DEBUG << "Retrieve object " << path << " from data provider" << endmsg; 00061 00062 DataObject *pObj; 00063 sc = dp->retrieveObject(path,pObj); 00064 00065 if (!sc.isSuccess()){ 00066 if (log) (*log) << MSG::ERROR << "Retrieve from data provider failed!" << endmsg; 00067 return sc; 00068 } 00069 00070 // Check if the requested condition is in the override list. 00071 if ( override ) { 00072 // yes, it is! 00073 // First I check if I can update in place the object 00074 ValidDataObject * vdo = dynamic_cast<ValidDataObject *>(pObj); 00075 if (vdo) { // Good, we can update in place 00076 vdo->update(*override); 00077 Condition * cond = dynamic_cast<Condition *>(pObj); 00078 if (cond) { // A condition needs to be initialized too 00079 sc = cond->initialize(); 00080 if ( !sc.isSuccess() ) { 00081 if (log) (*log) << MSG::ERROR 00082 << "Unable to initialize overridden condition at " 00083 << path << endmsg; 00084 return sc; 00085 } 00086 } 00087 // to avoid memory leaks, I have to delete the overriding object 00088 delete override; 00089 //override->release(); 00090 override = NULL; 00091 } else { // I cannot update the object, so I replace it. 00092 // let's unregister the original object 00093 sc = dp->unregisterObject(pObj); 00094 if ( !sc.isSuccess() ) { 00095 if (log) (*log) << MSG::ERROR << "Unable to unregister object at " << path << endmsg; 00096 return sc; 00097 } 00098 // and delete it 00099 pObj->release(); 00100 // Now I can register the user specified one 00101 pObj = override; 00102 sc = dp->registerObject(path,pObj); 00103 if ( !sc.isSuccess() ) { 00104 if (log) (*log) << MSG::ERROR << "Unable to register override object to " << path << endmsg; 00105 return sc; 00106 } 00107 // I do not need to delete the overriding object because now it belongs to the T.S. 00108 } 00109 } 00110 00111 // Set also internal pointers 00112 sc = setPointers(pObj); 00113 if ( !sc.isSuccess() ) { 00114 if (log) (*log) << MSG::ERROR << "Failure setting the pointers for object at " << path << endmsg; 00115 return sc; 00116 } 00117 00118 // try to get the path to CondDB folder 00119 IOpaqueAddress *pAddr = pObj->registry()->address(); 00120 if (pAddr != NULL) { 00121 if (pAddr->svcType() == CONDDB_StorageType) { 00122 // it comes from the cond db, so I can find its path 00123 db_path = pAddr->par()[0]; 00124 } 00125 } 00126 } else { 00127 if (vdo != NULL && !vdo->isValid(when)){ // I have a VDO ptr and the object is not valid 00128 if (log) (*log) << MSG::DEBUG << "Update object " << path << " from data provider" << endmsg; 00129 sc = vdo->update(); // only if I didn't load it 00130 if ( !sc.isSuccess() ) { 00131 if (log) (*log) << MSG::ERROR << "Update from data provider failed!" << endmsg; 00132 return sc; 00133 } 00134 } 00135 } 00136 if (vdo != NULL) { // it is a valid data object and should be up-to-date: align validity 00137 // no check because it shouldn't be necessary 00138 since = vdo->validSince(); 00139 until = vdo->validTill(); 00140 } 00141 // object internal data are up-to-date, now check what it depends on 00142 if (log) (*log) << MSG::VERBOSE << "Enter dependencies update loop" << endmsg; 00143 for (MembFuncList::iterator mfIt = memFuncs.begin(); mfIt != memFuncs.end(); ++mfIt){ 00144 if (!mfIt->isValid(when)) { // only if one the children of the member function need an update 00145 size_t n = mfIt - memFuncs.begin(); 00146 if (log) (*log) << MSG::VERBOSE << "Loop over dependencies of m.f. " << n << endmsg; 00147 mfIt->resetIOV(); 00148 for (ItemList::iterator itemIt = mfIt->items->begin(); itemIt != mfIt->items->end(); ++itemIt){ 00149 sc = (*itemIt)->update(dp,when,log); 00150 if (!sc.isSuccess()) return sc; 00151 // child item updated, update mf's IOV 00152 if (mfIt->since < (*itemIt)->since) mfIt->since = (*itemIt)->since; 00153 if (mfIt->until > (*itemIt)->until) mfIt->until = (*itemIt)->until; 00154 } 00155 if (log) (*log) << MSG::VERBOSE << "Call m.f. " << n << endmsg; 00156 sc = (*(mfIt->mf))(); 00157 if (!sc.isSuccess()){ 00158 if (log) (*log) << MSG::DEBUG << "m.f. " << n << " returned a failure" << endmsg; 00159 return sc; 00160 } 00161 } 00162 // update the overall validity even if the M.F. was not called 00163 if (since < mfIt->since) since = mfIt->since; 00164 if (until > mfIt->until) until = mfIt->until; 00165 } 00166 updateLock = false; 00167 //std::cout << "UMS: final validity: " << since << " -> " << until << std::endl; 00168 //std::cout << "UMS: Updating (Item* " << this << ") " << ptr << " ---END---" << std::endl; 00169 if (log){ 00170 (*log) << MSG::VERBOSE << " final validity: " << since << " -> " << until << endmsg; 00171 (*log) << MSG::DEBUG << "Updating (Item* " << this << ") " << ptr << " ---END---"; 00172 if (!path.empty()) (*log) << " " << path; 00173 (*log) << endmsg; 00174 } 00175 sc = StatusCode::SUCCESS; 00176 return sc; 00177 }
bool UpdateManagerSvc::Item::match | ( | void * | p | ) | const [inline] |
bool UpdateManagerSvc::Item::match | ( | const std::string & | p, | |
bool | is_path_to_db = false | |||
) | const [inline] |
Tells if this item represents object identified by the given pointer.
Definition at line 307 of file UpdateManagerSvc.h.
bool UpdateManagerSvc::Item::isHead | ( | ) | const [inline] |
bool UpdateManagerSvc::Item::isTail | ( | ) | const [inline] |
MembFuncList::iterator UpdateManagerSvc::Item::find | ( | BaseObjectMemberFunction * | mf | ) | [inline] |
Finds the MembFunc object containing the given member function.
Definition at line 316 of file UpdateManagerSvc.h.
void UpdateManagerSvc::Item::addParent | ( | Item * | parent, | |
BaseObjectMemberFunction * | parentMF | |||
) | [inline] |
Adds a (item,member_function) pair to the list of parents.
Definition at line 324 of file UpdateManagerSvc.h.
BaseObjectMemberFunction * UpdateManagerSvc::Item::addChild | ( | BaseObjectMemberFunction * | thisMF, | |
Item * | child | |||
) |
Adds a child item to the given member function.
Return a pointer to the actual member function if an equivalent one was already registered.
Definition at line 181 of file UpdateManagerSvc_Item.cpp.
00181 { 00182 MembFuncList::iterator mfIt = find(thisMF); 00183 if (mfIt == memFuncs.end()) { 00184 mfIt = memFuncs.insert(mfIt,MembFunc(thisMF)); 00185 } else { 00186 if (mfIt->mf != thisMF) 00187 delete thisMF; 00188 } 00189 if (std::find(mfIt->items->begin(),mfIt->items->end(),child) == mfIt->items->end()){ 00190 // it is a new child (not in current m.f. list) 00191 mfIt->items->push_back(child); 00192 00193 // intersect M.F. validity with the new child 00194 if (mfIt->since < child->since) mfIt->since = child->since; 00195 if (mfIt->until > child->until) mfIt->until = child->until; 00196 00197 // add the new child to the list of childs if not already included 00198 if (std::find(children.begin(),children.end(),child) == children.end()){ 00199 children.push_back(child); 00200 } 00201 00202 // intersect the item validity with the one of the member function 00203 if (since < mfIt->since) since = mfIt->since; 00204 if (until > mfIt->until) until = mfIt->until; 00205 00206 } 00207 // return the real pointer since thisMF can be deleted 00208 return mfIt->mf; 00209 }
Gaudi::Time UpdateManagerSvc::Item::since |
Time points delimiting the interval of validity of the item (intersection of the intervals of validity of the member functions).
Definition at line 250 of file UpdateManagerSvc.h.
Gaudi::Time UpdateManagerSvc::Item::until |
Definition at line 250 of file UpdateManagerSvc.h.
Item parents: the (item,member_function) pairs that depend on this item.
Definition at line 253 of file UpdateManagerSvc.h.
List of all the children: the items on which this item depend (used for fast accessing).
Definition at line 256 of file UpdateManagerSvc.h.
std::string UpdateManagerSvc::Item::path |
Path to the object, inside the data store, represented by the item.
Definition at line 259 of file UpdateManagerSvc.h.
std::string UpdateManagerSvc::Item::db_path |
Path of the persistent version of the object inside the Conditions DataBase.
Definition at line 261 of file UpdateManagerSvc.h.
Pointer to the ValidDataObject interface of the represented object.
Definition at line 263 of file UpdateManagerSvc.h.
Void pointer to the represented object, obtained via dynamic_cast (used to unically identify the item).
Definition at line 265 of file UpdateManagerSvc.h.
Pointer to the object used to override the object retrieved from the data provider.
Definition at line 267 of file UpdateManagerSvc.h.
Flag used to prevent infinite loops when updating.
Definition at line 272 of file UpdateManagerSvc.h.