4 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
7 /** @file StoreGateSvc.icc
10 #ifndef STOREGATE_STOREGATESVC_ICC
11 #define STOREGATE_STOREGATESVC_ICC
12 #include "StoreGate/constraints/KeyConcept.h"
13 #include "SGTools/CallBackID.h"
14 #include "AthContainersInterfaces/AuxStore_traits.h"
15 #include "AthenaKernel/ClassName.h"
16 #include "CxxUtils/checker_macros.h"
17 #include "boost/bind/bind.hpp"
20 /// macro to help writing the function calls.
21 /// first looks if there is a hive slot defined, otherwise forwards to the "serial" implementation
22 #define _SGXCALL(FUN,ARGS,ONERR) \
23 SGImplSvc* impl = this->currentStore(); \
25 return impl->FUN ARGS; \
30 /// macro to help writing the function calls
31 #define _SGVOIDCALL(FUN,ARGS) \
32 SGImplSvc* impl = this->currentStore(); \
40 StoreGateSvc::storeID() const
48 StoreGateSvc::currentStore() const {
49 if (m_storeID == StoreID::EVENT_STORE) {
50 SG::HiveEventSlot* slot = currentSlot();
51 if (slot) return slot->pEvtStore;
53 return m_defaultStore;
59 StoreGateSvc::proxy(const CLID& id, const char* key) const {
60 _SGXCALL( proxy, (id, key), 0 );
65 StoreGateSvc::proxy_exact (SG::sgkey_t sgkey) const {
66 _SGXCALL( proxy_exact, (sgkey), 0 );
69 template <typename H, typename TKEY>
71 StoreGateSvc::regHandle ATLAS_NOT_THREAD_SAFE ( const DataHandle<H>& handle, const TKEY& key )
73 CLID clid = ClassID_traits<H>::ID();
74 IResetable *ir = const_cast<IResetable*> (static_cast<const IResetable*> (&handle));
75 SG::DataProxy *dp = 0;
77 bool ret = this->currentStore()->bindHandleToProxyAndRegister (clid, key, ir, dp);
79 return StatusCode::FAILURE;
82 return handle.setState(dp); // FIXME - should be retrieve?
85 /// non-const method - will return an error
86 template <typename H, typename TKEY>
88 StoreGateSvc::regHandle( DataHandle<H>& /*handle*/, const TKEY& key)
90 error() << "regHandle(): DataHandle must be const: "
91 << ClassName<H>::name() << "[" + key + "]"
94 return StatusCode::FAILURE;
97 /// register a callback function, with handle + key
98 template <typename T, typename H, typename TKEY>
100 StoreGateSvc::regFcn ATLAS_NOT_THREAD_SAFE (StatusCode (T::*updFcn)(IOVSVC_CALLBACK_ARGS),
101 const T* obj, const DataHandle<H>& handle,
102 const TKEY& key, bool trigger)
104 CLID clid = ClassID_traits<H>::ID();
105 IResetable *ir = const_cast<IResetable*> (static_cast<const IResetable*> (&handle));
106 SG::DataProxy *dp = 0;
108 const CallBackID c(updFcn,obj);
109 using namespace boost::placeholders;
110 IOVSvcCallBackFcn fcn(boost::bind(updFcn,const_cast<T*>(obj), _1, _2));
112 bool ret = this->currentStore()->bindHandleToProxyAndRegister
113 (clid, key, ir, dp, c, fcn, trigger);
116 return StatusCode::FAILURE;
119 return handle.setState(dp); // FIXME - should be retrieve?
122 /// register a callback function, with handle + key. Non const. Error
123 template <typename T, typename H, typename TKEY>
125 StoreGateSvc::regFcn(StatusCode (T::* /*updFcn*/)(IOVSVC_CALLBACK_ARGS),
126 const T* /*obj*/, DataHandle<H>& /*handle*/,
127 const TKEY& key, bool /*trigger*/)
129 error() << "regHandle(): DataHandle must be const: "
130 << ClassName<H>::name() << "[" + key + "]"
133 return StatusCode::FAILURE;
137 /// register a callback function(2) with an already registered function(1)
138 template <typename T1, typename T2>
140 StoreGateSvc::regFcn ATLAS_NOT_THREAD_SAFE (StatusCode (T1::*fcn1)(IOVSVC_CALLBACK_ARGS),
142 StatusCode (T2::*fcn2)(IOVSVC_CALLBACK_ARGS),
143 const T2* obj2, bool trigger)
145 const CallBackID c1(fcn1, obj1);
146 const CallBackID c2(fcn2, obj2);
147 using namespace boost::placeholders;
148 IOVSvcCallBackFcn fcn( boost::bind(fcn2,const_cast<T2*>(obj2), _1, _2));
150 _SGXCALL( regFcn, (c1, c2, fcn, trigger), StatusCode::FAILURE );
154 /// register a callback function(2) with an already registered AlgTool
155 template <typename T2>
157 StoreGateSvc::regFcn ATLAS_NOT_THREAD_SAFE (const std::string& toolName,
158 StatusCode (T2::*fcn2)(IOVSVC_CALLBACK_ARGS),
159 const T2* obj2, bool trigger)
161 const CallBackID c2(fcn2, obj2);
162 using namespace boost::placeholders;
163 IOVSvcCallBackFcn fcn( boost::bind(fcn2,const_cast<T2*>(obj2),_1,_2));
164 _SGXCALL( regFcn, (toolName, c2, fcn, trigger), StatusCode::FAILURE );
167 ///////////////////////////////////////////////////////////////////
168 // create an object and record it with key
169 //////////////////////////////////////////////////////////////////
170 template <typename T, typename TKEY, typename... ARGS>
172 StoreGateSvc::create(const TKEY& key, ARGS... constructorArgs) {
173 T* pT = new T(constructorArgs...);
174 if(!(this->record(pT, key).isSuccess())) {
175 error() << "create: problem recording created object @"
176 << pT << " using key " << key << endmsg;
177 pT=0; //record will take care of deleting pT even if it fails
181 ///////////////////////////////////////////////////////////////////
182 // record an object with key
183 //////////////////////////////////////////////////////////////////
184 template <typename T, typename TKEY>
185 StatusCode StoreGateSvc::record(T* pObject, const TKEY& key)
187 const bool ALLOWMODS(true);
188 return record(pObject, key, ALLOWMODS); //allow mods by default
190 //-------------------------------------------------------------------
191 template <typename T, typename TKEY>
192 StatusCode StoreGateSvc::record(const T* pObject, const TKEY& key)
194 const bool NOMODS(false);
195 // Ok --- we hold objects as non-const pointers internally, but mark
196 // them as const, so they can only be retrieved as const.
197 T* pObject_nc ATLAS_THREAD_SAFE = const_cast<T*> (pObject);
198 return record(pObject_nc, key, NOMODS); // do not allow mods
201 //-------------------------------------------------------------------
202 template <typename T, typename TKEY>
203 StatusCode StoreGateSvc::record(T* pObject, const TKEY& key,
204 bool allowMods, bool resetOnly, bool noHist)
206 return record1 (SG::asStorable<T>(pObject), pObject, key,
207 allowMods, resetOnly, noHist);
211 //-------------------------------------------------------------------
214 template <typename T, typename TKEY>
215 StatusCode StoreGateSvc::record1(DataObject* obj,
216 T* pObject, const TKEY& key,
217 bool allowMods, bool resetOnly, bool noHist)
219 if (m_storeID == StoreID::EVENT_STORE && currentSlot() != nullptr) {
220 rememberBadRecord (ClassID_traits<T>::ID(), key);
224 BOOST_CONCEPT_ASSERT( (KeyConcept<TKEY>) );
226 // make sure the BaseInfo(Base) structure is initialized
227 SG::BaseInfo<T>::baseinfo();
229 // If s_isConst is set for this type, then we want to automatically
230 // make it const when recorded.
231 if (ClassID_traits<T>::s_isConst)
234 StatusCode sc = this->currentStore()->typeless_record( obj, key, pObject,
235 allowMods, resetOnly, noHist,
238 if (sc.isSuccess()) {
240 "Recorded object @" << pObject
241 << " with key " << (std::string)key
242 << " of type " << ClassID_traits<T>::typeName()
243 << "(CLID " << ClassID_traits<T>::ID()
244 << ")\n in DataObject @" << obj
245 << "\n object " << (allowMods ? "" : "not ")
246 << "modifiable when retrieved");
254 //-------------------------------------------------------------------
257 template <typename T, typename TKEY>
258 StatusCode StoreGateSvc::overwrite1(DataObject* obj, T* pObject,
260 bool allowMods, bool noHist)
262 if (m_storeID == StoreID::EVENT_STORE && currentSlot() != nullptr) {
263 rememberBadRecord (ClassID_traits<T>::ID(), key);
267 BOOST_CONCEPT_ASSERT( (KeyConcept<TKEY>) );
269 // make sure the BaseInfo(Base) structure is initialized
270 SG::BaseInfo<T>::baseinfo();
272 // If s_isConst is set for this type, then we want to automatically
273 // make it const when recorded.
274 if (ClassID_traits<T>::s_isConst) allowMods = false;
276 StatusCode sc = this->currentStore()->typeless_overwrite(ClassID_traits<T>::ID(),
278 pObject, allowMods, noHist,
281 if (sc.isSuccess()) {
283 "overwrite: Recorded object @" << pObject
284 << " with key " << (std::string)key
285 << " of type " << ClassID_traits<T>::typeName()
286 << "(CLID " << ClassID_traits<T>::ID()
287 << ")\n in DataObject @" << obj
288 << "\n object " << (allowMods ? "" : "not ")
289 << "modifiable when retrieved");
295 //////////////////////////////////////////////////////////////////
296 // Retrieve the default object (with no key) as a const pointer
297 //////////////////////////////////////////////////////////////////
298 template <typename T>
299 StatusCode StoreGateSvc::retrieve(const T*& ptr) const
301 if (m_storeID == StoreID::EVENT_STORE && currentSlot() != nullptr) {
302 rememberBadRetrieve (ClassID_traits<T>::ID(), "");
305 SG::DataProxy* dp =proxy(ClassID_traits<T>::ID());
306 if (!dp || !dp->isValid()) {
308 << "retrieve(default): No valid proxy for default object \n"
309 << " of type " << ClassID_traits<T>::typeName() << "(CLID "
310 << ClassID_traits<T>::ID() << ')' << endmsg;
311 return StatusCode::FAILURE;
313 ptr = SG::DataProxy_cast<T> (dp);
315 return StatusCode::FAILURE;
318 //for types with an associated store, try to retrieve it and associate it
319 this->associateAux (ptr, SG::DEFAULTKEY);
321 SG_MSG_DEBUG("retrieve(default): Retrieved const pointer to default object \n"
322 << " of type " << ClassID_traits<T>::typeName()
323 << "(CLID " << ClassID_traits<T>::ID() << ')');
326 return StatusCode::SUCCESS;
329 //////////////////////////////////////////////////////////////////
330 // Retrieve the default object (with no key) as a pointer (non-const)
331 //////////////////////////////////////////////////////////////////
332 template <typename T>
333 StatusCode StoreGateSvc::retrieve(T*& ptr) const
335 if (m_storeID == StoreID::EVENT_STORE && currentSlot() != nullptr) {
336 rememberBadRetrieve (ClassID_traits<T>::ID(), "");
339 SG::DataProxy* dp =proxy(ClassID_traits<T>::ID());
340 if (!dp || !dp->isValid() || dp->isConst()) {
342 << "retrieve(default): No valid proxy for default object "
343 << " of type " << ClassID_traits<T>::typeName() << "(CLID "
344 << ClassID_traits<T>::ID() << ")\n Try to use a const retrieve "
346 return StatusCode::FAILURE;
348 ptr = SG::DataProxy_cast<T> (dp);
350 return StatusCode::FAILURE;
353 //for types with an associated store, try to retrieve it and associate it
354 this->associateAux (ptr, SG::DEFAULTKEY);
356 SG_MSG_DEBUG("retrieve(default): Retrieved non-const pointer to default object \n"
357 << " of type " << ClassID_traits<T>::typeName()
358 << "(CLID " << ClassID_traits<T>::ID() << ')');
361 return StatusCode::SUCCESS;
364 //////////////////////////////////////////////////////////////////
365 // Retrieve the keyed object as a const pointer
366 // Overload for std::string key type
367 //////////////////////////////////////////////////////////////////
368 template <typename T>
369 StatusCode StoreGateSvc::retrieve(const T*& ptr, const std::string& key) const
371 if (m_storeID == StoreID::EVENT_STORE && currentSlot() != nullptr) {
372 rememberBadRetrieve (ClassID_traits<T>::ID(), key);
375 SG::DataProxy* dp =proxy (ClassID_traits<T>::ID(),
378 if (!dp || !dp->isValid()) {
380 << "retrieve(const): No valid proxy for object " << key << ' '
381 << " of type " << ClassID_traits<T>::typeName() << "(CLID "
382 << ClassID_traits<T>::ID() << ')' << endmsg;
383 return StatusCode::FAILURE;
385 ptr = SG::DataProxy_cast<T> (dp);
387 return StatusCode::FAILURE;
390 //for types with an associated store, try to retrieve it and associate it
391 this->associateAux (ptr, key);
393 SG_MSG_DEBUG( "Retrieved const pointer to object " << key << ' '
394 << " of type " << ClassID_traits<T>::typeName()
395 << "(CLID " << ClassID_traits<T>::ID() << ')');
398 return StatusCode::SUCCESS;
401 //////////////////////////////////////////////////////////////////
402 // Retrieve the keyed object as a const pointer
403 //////////////////////////////////////////////////////////////////
404 template <typename T, typename TKEY>
405 StatusCode StoreGateSvc::retrieve(const T*& ptr, const TKEY& key) const
408 BOOST_CONCEPT_ASSERT( (KeyConcept<TKEY>) );
410 return this->retrieve(ptr, static_cast<std::string>(key));
413 //////////////////////////////////////////////////////////////////
414 // Retrieve the keyed object as a non-const pointer
415 // Overload for std::string key type
416 //////////////////////////////////////////////////////////////////
417 template <typename T>
418 StatusCode StoreGateSvc::retrieve(T*& ptr, const std::string& key) const
420 if (m_storeID == StoreID::EVENT_STORE && currentSlot() != nullptr) {
421 rememberBadRetrieve (ClassID_traits<T>::ID(), key);
424 SG::DataProxy* dp =proxy (ClassID_traits<T>::ID(),
427 if (!dp || !dp->isValid() || dp->isConst()) {
428 SG_MSG_WARNING("retrieve(non-const): No valid proxy for object "
430 << " of type " << ClassID_traits<T>::typeName() << "(CLID "
431 << ClassID_traits<T>::ID()
432 << ") \n Try to use a const retrieve" );
433 return StatusCode::FAILURE;
435 ptr = SG::DataProxy_cast<T> (dp);
437 return StatusCode::FAILURE;
440 //for types with an associated store, try to retrieve it and associate it
441 this->associateAux (ptr, key);
443 SG_MSG_DEBUG("Retrieved non-const pointer to object " << (std::string)key
444 << ' ' << " of type " << ClassID_traits<T>::typeName()
445 << "(CLID " << ClassID_traits<T>::ID() << ')');
448 return StatusCode::SUCCESS;
451 //////////////////////////////////////////////////////////////////
452 // Retrieve the keyed object as a non-const pointer
453 //////////////////////////////////////////////////////////////////
454 template <typename T, typename TKEY>
455 StatusCode StoreGateSvc::retrieve(T*& ptr, const TKEY& key) const
458 BOOST_CONCEPT_ASSERT( (KeyConcept<TKEY>) );
460 return this->retrieve(ptr, static_cast<std::string>(key));
463 /// Retrieve all objects of type T: returns an SG::ConstIterator range
464 template <typename T>
466 StoreGateSvc::retrieve(SG::ConstIterator<T>& begin,
467 SG::ConstIterator<T>& end) const {
468 if (m_storeID == StoreID::EVENT_STORE && currentSlot() != nullptr) {
469 rememberBadRetrieve (ClassID_traits<T>::ID(), "(iterator)");
471 _SGXCALL(retrieve, (ClassID_traits<T>::ID(), begin, end), StatusCode::FAILURE);
476 * @brief Retrieve an object of type @c T from StoreGate.
477 * Return 0 if not found.
480 template <typename T>
481 T* StoreGateSvc::retrieve () const
484 retrieve (p).ignore();
489 * @brief Retrieve an object of type @c T from StoreGate.
490 * Return 0 if not found.
491 * @param key The key to use for the lookup.
493 template <typename T, class TKEY>
494 T* StoreGateSvc::retrieve (const TKEY& key) const
497 retrieve (p, key).ignore();
502 * @brief Retrieve an object of type @c T from StoreGate.
503 * Return 0 if not found.
505 template <typename T>
506 T* StoreGateSvc::tryRetrieve () const
508 if (m_storeID == StoreID::EVENT_STORE && currentSlot() != nullptr) {
509 rememberBadRetrieve (ClassID_traits<T>::ID(), "");
512 SG::DataProxy* dp = proxy (ClassID_traits<T>::ID());
513 if (dp && dp->isValid() && !dp->isConst()) {
514 T* ptr = SG::DataProxy_cast<T> (dp);
516 this->associateAux (ptr, SG::DEFAULTKEY);
523 template <typename T>
524 const T* StoreGateSvc::tryConstRetrieve() const
526 if (m_storeID == StoreID::EVENT_STORE && currentSlot() != nullptr) {
527 rememberBadRetrieve (ClassID_traits<T>::ID(), "");
530 SG::DataProxy* dp = proxy (ClassID_traits<T>::ID());
531 if (dp && dp->isValid()) {
532 const T* ptr = SG::DataProxy_cast<T> (dp);
534 this->associateAux (ptr, SG::DEFAULTKEY);
542 * @brief Retrieve an object of type @c T from StoreGate.
543 * Return 0 if not found. Don't print any WARNINGs
544 * @param key The key to use for the lookup.
546 template <typename T, class TKEY>
547 T* StoreGateSvc::tryRetrieve (const TKEY& key) const
549 if (m_storeID == StoreID::EVENT_STORE && currentSlot() != nullptr) {
550 rememberBadRetrieve (ClassID_traits<T>::ID(), key);
553 BOOST_CONCEPT_ASSERT( (KeyConcept<TKEY>) );
555 SG::DataProxy* dp = proxy (ClassID_traits<T>::ID(),
556 static_cast<std::string> (key),
558 if (dp && dp->isValid() && !dp->isConst()) {
559 T* ptr = SG::DataProxy_cast<T> (dp);
561 this->associateAux (ptr, key);
568 template <typename T, class TKEY>
569 const T* StoreGateSvc::tryConstRetrieve (const TKEY& key) const
571 if (m_storeID == StoreID::EVENT_STORE && currentSlot() != nullptr) {
572 rememberBadRetrieve (ClassID_traits<T>::ID(), key);
576 BOOST_CONCEPT_ASSERT( (KeyConcept<TKEY>) );
578 SG::DataProxy* dp = proxy (ClassID_traits<T>::ID(),
579 static_cast<std::string> (key),
581 if (dp && dp->isValid()) {
582 const T* ptr = SG::DataProxy_cast<T> (dp);
584 this->associateAux (ptr, key);
591 template <typename T>
592 int StoreGateSvc::typeCount() const
594 return typeCount(ClassID_traits<T>::ID());
598 template <typename T, typename TKEY>
600 StoreGateSvc::contains(const TKEY& key) const
602 return this->contains(ClassID_traits<T>::ID(), key);
605 template <typename TKEY>
607 StoreGateSvc::contains(const CLID& clid, const TKEY& key) const
609 _SGXCALL( contains, (clid,key), false );
612 template <typename T, typename TKEY>
614 StoreGateSvc::transientContains(const TKEY& key) const
616 return transientContains(ClassID_traits<T>::ID(), key);
621 template <typename TKEY>
623 StoreGateSvc::transientContains(const CLID& id, const TKEY& key) const
625 _SGXCALL(transientContains, (id, key), false);
628 //-------------------------end of contains methods--------------------
629 template <typename T>
631 StoreGateSvc::keys(std::vector<std::string>& vkeys,
632 bool includeAlias, bool onlyValid) const {
633 return this->keys(ClassID_traits<T>::ID(), vkeys, includeAlias, onlyValid);
637 template <typename T, typename TKEY>
639 StoreGateSvc::bind ATLAS_NOT_THREAD_SAFE (const DataHandle<T>& handle, const TKEY& key) {
640 CLID clid = ClassID_traits<T>::ID();
641 IResetable *ir = const_cast<IResetable*> (static_cast<const IResetable*> (&handle));
642 SG::DataProxy *dp = 0;
643 bool ret = this->currentStore()->bindHandleToProxy (clid, key, ir, dp);
645 return StatusCode::FAILURE;
648 return handle.setState(dp); // FIXME - should be retrieve?
651 //-------------------------------------------------------------------
652 template <typename T, typename TKEY>
653 StatusCode StoreGateSvc::record(std::unique_ptr<T> pUnique, const TKEY& key)
655 const bool ALLOWMODS(true);
656 return record(std::move(pUnique), key, ALLOWMODS); //allow mods by default
658 //-------------------------------------------------------------------
659 template <typename T, typename TKEY>
660 StatusCode StoreGateSvc::record(std::unique_ptr<const T> pUnique,
663 const bool NOMODS(false);
664 // Ok --- we hold objects as non-const pointers internally, but mark
665 // them as const, so they can only be retrieved as const.
666 T* ptr ATLAS_THREAD_SAFE = const_cast<T*> (pUnique.release());
667 return record1(SG::asStorable (ptr), ptr,
668 key, NOMODS); // do not allow mods
671 //-------------------------------------------------------------------
672 template <typename T, typename TKEY>
673 StatusCode StoreGateSvc::record(std::unique_ptr<T> pUnique, const TKEY& key,
674 bool allowMods, bool resetOnly, bool noHist)
676 T* ptr = pUnique.get();
677 return record1 (SG::asStorable<T>(std::move(pUnique)), ptr, key,
678 allowMods, resetOnly, noHist);
681 template <typename T, typename TKEY>
682 StatusCode StoreGateSvc::overwrite(T* p2BRegistered, const TKEY& key)
684 const bool ALLOWMODS(true);
685 return overwrite(p2BRegistered, key, ALLOWMODS); //SG takes ownership
688 template <typename T, typename TKEY>
690 StoreGateSvc::overwrite(T* pObject, const TKEY& key,
691 bool allowMods, bool noHist)
693 return overwrite1 (SG::asStorable<T>(pObject), pObject, key,
697 template <typename T, typename TKEY>
698 StatusCode StoreGateSvc::overwrite(std::unique_ptr<T> pUnique, const TKEY& key)
700 const bool ALLOWMODS(true);
701 return overwrite(std::move(pUnique), key, ALLOWMODS); //allow mods by default
704 template <typename T, typename TKEY>
705 StatusCode StoreGateSvc::overwrite(std::unique_ptr<T> pUnique, const TKEY& key,
706 bool allowMods, bool noHist)
708 T* ptr = pUnique.get();
709 return overwrite1 (SG::asStorable<T>(std::move(pUnique)), ptr, key,
713 template <typename T, typename AKEY>
714 StatusCode StoreGateSvc::setAlias(const T* pObject, const AKEY& aKey)
716 boost::function_requires< KeyConcept<AKEY> > ();
717 _SGXCALL(setAlias, (pObject, aKey), StatusCode::FAILURE);
719 //-------------------------------------------------------------------
720 template <typename T, typename TKEY, typename AKEY>
722 StoreGateSvc::setAlias(const T* /*dummy*/,
723 const TKEY& key, const AKEY& aKey)
726 BOOST_CONCEPT_ASSERT( (KeyConcept<TKEY>) );
727 BOOST_CONCEPT_ASSERT( (KeyConcept<AKEY>) );
729 _SGXCALL(setAlias, (ClassID_traits<T>::ID(), key, aKey), StatusCode::FAILURE);
734 StoreGateSvc::setAlias(SG::DataProxy* proxy, const std::string& aliasKey)
736 _SGXCALL(setAlias, (proxy, aliasKey), StatusCode::FAILURE);
739 //////////////////////////////////////////////////////////////////
740 // Make a soft link to the object with key: return non_const link
741 //////////////////////////////////////////////////////////////////
742 template <typename T, typename TLINK>
744 StoreGateSvc::symLink(const T* pObject, TLINK* /*dummy*/)
746 _SGXCALL(symLink, (pObject, ClassID_traits<TLINK>::ID()), StatusCode::FAILURE);
749 //////////////////////////////////////////////////////////////////
750 // Make a soft link to the object with key: set const link
751 //////////////////////////////////////////////////////////////////
752 template <typename T, typename TLINK>
754 StoreGateSvc::symLink(const T* pObject, const TLINK* /*dummy*/)
756 _SGXCALL(symLink, (pObject, ClassID_traits<TLINK>::ID()), StatusCode::FAILURE);
759 template <typename TKEY>
761 StoreGateSvc::symLink(const CLID id, const TKEY& key, const CLID linkid)
764 //FIXME we have no way to check that the type represented by ID (the primary)
765 //FIXME is convertible into the linkid type. VERY BAD. Need introspection???
766 BOOST_CONCEPT_ASSERT( (KeyConcept<TKEY>) );
768 _SGXCALL(symLink, (id, key, linkid), StatusCode::FAILURE);
772 /// Remove pObject, will remove its proxy if not reset only.
773 template <typename T>
775 StoreGateSvc::remove(const T* pObject) {
776 _SGXCALL(remove, (pObject), StatusCode::FAILURE);
779 /// Remove pObject and its proxy no matter what.
780 template <typename T>
782 StoreGateSvc::removeDataAndProxy(const T* pObject) {
783 _SGXCALL(removeDataAndProxy, (pObject), StatusCode::FAILURE);
786 template <typename T, class TKEY>
788 StoreGateSvc::retrieveHighestVersion(SG::ObjectWithVersion<T>& dobjWithVersion,
789 const TKEY& requestedKey) const
791 std::list< SG::ObjectWithVersion<T> > allVersions;
792 StatusCode sc(this->retrieveAllVersions(allVersions,requestedKey));
793 if (sc.isSuccess()) {
794 allVersions.sort(); // on highest version number
795 dobjWithVersion.versionedKey.copyVK(allVersions.back().versionedKey.rawVersionKey());
800 template <typename T, class TKEY>
802 StoreGateSvc::retrieveAllVersions(std::list< SG::ObjectWithVersion<T> >& allVersions,
803 const TKEY& requestedKey) const
805 StatusCode sc(StatusCode::FAILURE);
806 SG::ConstIterator<T> i,e;
807 if ((this->retrieve<T>(i,e)).isSuccess()){
808 SG::VersionedKey reqVK(requestedKey);
810 SG::VersionedKey vk(i.key());
811 if (reqVK.sameKey(vk)) {
812 sc = StatusCode::SUCCESS;
813 SG::ObjectWithVersion<T> okOWV(vk, i.proxy());
814 allVersions.push_back(okOWV);
823 template <typename T>
825 StoreGateSvc::retrieveUniquePrivateCopy (const std::string& key)
827 CLID clid = ClassID_traits<T>::ID();
828 DataObject* obj = this->currentStore()->typeless_retrievePrivateCopy(clid, key);
829 std::unique_ptr<T> ret (SG::Storable_cast<T>(obj));
830 if (DataBucketBase* dbb = dynamic_cast<DataBucketBase*> (obj))
838 //////////////////////////////////////////////////////////////////
839 // Retrieve the @c CLID of a given "key"
841 //////////////////////////////////////////////////////////////////
842 template<typename TKEY>
844 StoreGateSvc::clid( const TKEY& key ) const
846 _SGXCALL(clid, (key), CLID_NULL);
849 //////////////////////////////////////////////////////////////////
850 // Retrieve the @c CLID s of a given "key"
852 //////////////////////////////////////////////////////////////////
853 template<typename TKEY>
855 StoreGateSvc::clids( const TKEY& key ) const
857 std::vector<CLID> nullV;
858 _SGXCALL(clids, (key), nullV);
861 ///////////////////////////////////////////////////////////////////////////
865 StoreGateSvc::setProxyProviderSvc(IProxyProviderSvc* pPPSvc) {
866 _SGVOIDCALL(setProxyProviderSvc, (pPPSvc));
872 StoreGateSvc::proxyProviderSvc() {
873 _SGXCALL(proxyProviderSvc, (), nullptr);
878 * @brief Return the metadata source ID for the current event slot.
879 * @param key SG key of the DataHeader to query.
880 * Returns an empty string if no source has been set.
882 * The default version always returns an empty string.
886 StoreGateSvc::sourceID (const std::string& key /*= "EventSelector"*/) const {
887 _SGXCALL(sourceID, (key), "");
891 template <class TKEY>
893 StoreGateSvc::remap (CLID clid,
896 off_t index_offset) {
897 _SGVOIDCALL(remap_impl, (this->stringToKey (source, clid),
898 this->stringToKey (target, clid),
904 * @brief Remember that retrieve() was called for a MT store.
905 * @param clid CLID of the operation.
906 * @param key Key of the operation.
909 void StoreGateSvc::rememberBadRetrieve (CLID clid, const std::string& key) const
911 rememberBad (m_badRetrieves, clid, key);
916 * @brief Remember that retrieve() was called for a MT store.
917 * @param clid CLID of the operation.
918 * @param key Key of the operation.
921 void StoreGateSvc::rememberBadRecord (CLID clid, const std::string& key) const
923 rememberBad (m_badRecords, clid, key);
927 template <class DOBJ, class AUXSTORE>
928 bool StoreGateSvc::associateAux_impl (DOBJ* ptr,
929 const std::string& key,
930 const AUXSTORE*) const
932 CLID auxclid = ClassID_traits<AUXSTORE>::ID();
933 _SGXCALL( associateAux_impl, (ptr, key, auxclid), false);
937 template <class DOBJ>
938 bool StoreGateSvc::associateAux_impl (DOBJ* /*ptr*/,
939 const std::string& /*key*/,
940 const SG::NoAuxStore*) const
947 * @brief associate a data object to its auxiliary store
948 * Return false if the aux store is not found.
949 * @param key The key to use for the lookup.
951 template <class DOBJ>
952 bool StoreGateSvc::associateAux (DOBJ* ptr,
953 const std::string& key,
954 bool ignoreMissing) const
956 typename SG::AuxStore_traits<DOBJ>::type* pDummy(0); //used to pass down auxstore type
957 bool hasAux=associateAux_impl(ptr, key, pDummy) || ignoreMissing;
958 if (!hasAux) SG_MSG_WARNING("associateAux const: Could not associate AuxStore of type "
959 << SG::AuxStore_traits<DOBJ>::const_typeName()
960 << "\n to object of type " << ClassID_traits<DOBJ>::typeName() << "(CLID "
961 << ClassID_traits<DOBJ>::ID() << ") with key " << key << endmsg);
966 template <class DOBJ>
967 bool StoreGateSvc::associateAux (const DOBJ* ptr,
968 const std::string& key,
969 bool ignoreMissing) const
971 typename SG::AuxStore_traits<DOBJ>::const_type* pDummy(0); //used to pass down auxstore type
972 // Should generally be ok, since any actual modification is done
973 // inside the store lock. Still kind of a wart that we still do this, though.
974 DOBJ* ptr_nc ATLAS_THREAD_SAFE = const_cast<DOBJ*> (ptr);
975 bool hasAux=associateAux_impl(ptr_nc, key, pDummy) || ignoreMissing;
976 if (!hasAux) SG_MSG_WARNING("associateAux const: Could not associate AuxStore of type "
977 << SG::AuxStore_traits<DOBJ>::const_typeName()
978 << "\n to object of type " << ClassID_traits<DOBJ>::typeName() << "(CLID "
979 << ClassID_traits<DOBJ>::ID() << ") with key " << key << endmsg);
984 #endif //STOREGATE_STOREGATESVC_ICC