ATLAS Offline Software
SGImplSvc.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #undef DEBUG_SGIMPL
6 
7 #include <algorithm>
8 #include <cassert>
9 #include <cstdio>
10 #include <iostream>
11 #include <functional>
12 #include <format>
13 #include <string>
14 #include <unordered_map>
15 
16 #include <sstream>
17 #include <fstream>
18 #include <iomanip>
19 
24 #include "AthenaKernel/IIOVSvc.h"
27 #include "AthenaKernel/StoreID.h"
28 #include "GaudiKernel/IClassIDSvc.h"
29 #include "GaudiKernel/IHistorySvc.h"
30 #include "GaudiKernel/ISvcLocator.h"
31 #include "GaudiKernel/IConversionSvc.h"
32 #include "GaudiKernel/Incident.h"
33 #include "GaudiKernel/IOpaqueAddress.h"
34 #include "GaudiKernel/MsgStream.h"
35 #include "GaudiKernel/StatusCode.h"
36 #include "GaudiKernel/DataHistory.h"
39 #include "SGTools/DataProxy.h"
40 #include "SGTools/DataStore.h"
41 #include "SGTools/StringPool.h"
43 #include "SGTools/SGVersionedKey.h"
48 
49 // StoreGateSvc. must come before SGImplSvc.h
50 #include "StoreGate/StoreGateSvc.h"
52 #include "SGTools/DataStore.h"
53 
54 using std::setw;
55 using std::hex;
56 using std::dec;
57 using std::endl;
58 using std::ends;
59 using std::pair;
60 using std::string;
61 using std::vector;
62 
63 using SG::DataProxy;
64 using SG::DataStore;
66 
67 // Helpers for debug formatting
68 // std::print implementation to be replaced when C++ 23 is available
69 namespace dbg {
70 template <class... Args> void print(std::FILE* stream, std::format_string<Args...> fmt, Args&&... args) {
71  std::fputs(std::format(fmt, std::forward<Args>(args)...), stream);
72 }
73 
74 template <class T> void* ptr(T* p) { return static_cast<void*>(p); }
75 }
76 
78 // Remapping implementation.
79 
80 
81 namespace SG {
82 
83 
84  struct RemapImpl
85  {
87 
88  struct remap_t {
90  off_t index_offset;
91  };
94  };
95 
96 
97 } // namespace SG
98 
99 
102 SGImplSvc::SGImplSvc(const string& name,ISvcLocator* svc)
103  : base_class(name, svc),
104  m_pCLIDSvc("ClassIDSvc", name),
105  m_pDataLoader("EventPersistencySvc", name),
106  m_pPPSHandle("ProxyProviderSvc", name),
107  m_pPPS(nullptr),
108  m_pHistorySvc("HistorySvc", name),
109  m_pStore(new DataStore(*this)),
110  m_pIncSvc("IncidentSvc", name),
111  m_DumpStore(false),
112  m_ActivateHistory(false),
113  m_DumpArena(false),
114  m_pIOVSvc("IOVSvc", name),
115  m_storeLoaded(false),
116  m_remap_impl (new SG::RemapImpl),
117  m_arena (name),
118  m_slotNumber(-1),
119  m_numSlots(1)
120 {
121  //our properties
122  declareProperty("ProxyProviderSvc", m_pPPSHandle);
123  declareProperty("Dump", m_DumpStore);
124  declareProperty("ActivateHistory", m_ActivateHistory);
125  declareProperty("DumpArena", m_DumpArena);
126  //StoreGateSvc properties
127  declareProperty("IncidentSvc", m_pIncSvc);
128  //add handler for Service base class property
129  m_outputLevel.declareUpdateHandler(&SGImplSvc::msg_update_handler, this);
130 
132  header->addArena (&m_arena);
133 }
134 
135 
139  header->delArena (&m_arena);
140 
141  delete m_pStore;
142  delete m_remap_impl;
143 }
144 
148 
149  verbose() << "Initializing " << name() << endmsg;
150 
152 
153  if (!m_pStore)
154  m_pStore = new DataStore (*this);
155  if (!m_remap_impl)
157 
158  //properties accessible from now on
159 
161  // If this is the default event store (StoreGateSvc), then declare
162  // our arena as the default for memory allocations.
163  if (this->storeID() == StoreID::EVENT_STORE) {
166  }
167  // set up the incident service:
168  if (!(m_pIncSvc.retrieve()).isSuccess()) {
169  error() << "Could not locate IncidentSvc "
170  << endmsg;
171  return StatusCode::FAILURE;
172  }
173 
174  // We explicitly do not retrieve m_pIOVSvc and rely on retrieval
175  // on first use to avoid an initialization loop here.
176 
177  CHECK( m_pDataLoader.retrieve() );
178  CHECK( m_pCLIDSvc.retrieve() );
179 
180  if (!m_pPPSHandle.empty()) {
181  CHECK( m_pPPSHandle.retrieve() );
182  m_pPPS = &*m_pPPSHandle;
183  }
184 
185  if ( m_pPPS && (m_pPPS->preLoadProxies(*m_pStore)).isFailure() )
186  {
187  SG_MSG_DEBUG(" Failed to preLoad proxies");
188  return StatusCode::FAILURE;
189  }
190 
191  // Get hold of History Service
192  if (m_ActivateHistory) {
193  CHECK( m_pHistorySvc.retrieve() );
194  }
195 
196  return StatusCode::SUCCESS;
197 }
200 
201  verbose() << "Start " << name() << endmsg;
202  /*
203  // This will need regFcn clients to be updated first.
204  if ( 0 == m_pPPS || (m_pPPS->preLoadProxies(*m_pStore)).isFailure() ) {
205  debug() << " Failed to preLoad proxies"
206  << endmsg;
207  return StatusCode::FAILURE;
208  }
209  */
210 
211  return StatusCode::SUCCESS;
212 }
215 
216  verbose() << "Stop " << name() << endmsg;
217  //HACK ALERT: ID event store objects refer to det store objects
218  //by setting an ad-hoc priority for event store(s) we make sure they are finalized and hence cleared first
219  // see e.g. https://savannah.cern.ch/bugs/index.php?99993
220  if (store()->storeID() == StoreID::EVENT_STORE) {
221  ISvcManager* pISM(dynamic_cast<ISvcManager*>(serviceLocator().get()));
222  if (!pISM)
223  return StatusCode::FAILURE;
224  pISM->setPriority(name(), pISM->getPriority(name())+1).ignore();
225  verbose() << "stop: setting service priority to " << pISM->getPriority(name())
226  << " so that event stores get finalized and cleared before other stores" <<endmsg;
227  }
228  return StatusCode::SUCCESS;
229 }
230 
232 void SGImplSvc::handle(const Incident &inc) {
233 
234  if (inc.type() == "EndEvent") {
235  if (m_DumpStore) {
236  SG_MSG_DEBUG("Dumping StoreGate Contents");
237  info() << '\n' << dump() << endl
238  << endmsg;
239  }
240  }
241 }
242 
244  lock_t lock (m_mutex);
245  StatusCode sc(StatusCode::SUCCESS);
246  //FIXME this should probably be dealt with by the providers
247  if (0 != m_pPPS && !m_storeLoaded) {
248  m_storeLoaded = true;
250 #ifdef DEBUG_SGIMPL
251  dbg::print(stderr, "SGImplSvc::loadEventProxies() LOADED PROXIES on {}\n", name());
252  }
253  else {
254  dbg::print(stderr, "SGImplSvc::loadEventProxies() PROXIES ALREADY LOADED on {}\n", name());
255 #endif
256  }
257  return sc;
258 }
259 
261 // Create a key for a type (used if the client has not specified a key)
262 string SGImplSvc::createKey(const CLID& id)
263 {
264  return std::to_string(m_pStore->typeCount(id) + 1);
265 }
267 // clear store
269 {
270 #ifdef DEBUG_SGIMPL
271  dbg::print(stderr, "SGImplSvc::clearStore(forceRemove={}) on {}\n", forceRemove, name());
272 #endif
273  {
274  if (m_DumpArena) {
275  std::ostringstream s;
276  m_arena.report(s);
277  info() << "Report for Arena: " << m_arena.name() << '\n'
278  << s.str() << endmsg;
279  }
280  }
281  {
282  lock_t lock (m_mutex);
283  emptyTrash();
284  for (auto& p : m_newBoundHandles)
285  p.second.clear();
286  assert(m_pStore);
287  debug() << "Clearing store with forceRemove="
288  << forceRemove << endmsg;
289  bool hard_reset = (m_numSlots > 1);
290  m_pStore->clearStore(forceRemove, hard_reset, &msgStream(MSG::DEBUG));
291  m_storeLoaded=false; //FIXME hack needed by loadEventProxies
292  }
293  {
294  lock_t remap_lock (m_remapMutex);
295  m_remap_impl->m_remaps.clear();
296  m_arena.reset();
297  }
298 
299  return StatusCode::SUCCESS;
300 }
304  verbose() << "Finalizing " << name() << endmsg ;
305 
306  // Incident service may not work in finalize.
307  // Clear this, so that we won't try to send an incident from clearStore.
308  (m_pIncSvc.release()).ignore();
309 
310  const bool FORCEREMOVE(true);
311  clearStore(FORCEREMOVE).ignore();
312 
314  delete m_pStore;
315  m_pStore = nullptr;
316  delete m_remap_impl;
317  m_remap_impl = 0;
318  m_arena.erase();
319 
320  return Service::finalize();
321 }
325  verbose() << "Reinitializing " << name() << endmsg ;
326  const bool FORCEREMOVE(true);
327  clearStore(FORCEREMOVE).ignore();
328  //not in v20r2p2! return Service::reinitialize();
329  return StatusCode::SUCCESS;
330 }
331 
334 // add proxy (with IOpaqueAddress that will later be retrieved from P)
336 StatusCode SGImplSvc::recordAddress(const std::string& skey,
337  IOpaqueAddress* pAddress,
338  bool clearAddressFlag)
339 {
340  lock_t lock (m_mutex);
341  assert(0 != pAddress);
342  CLID dataID = pAddress->clID();
343 
344  if (dataID == 0)
345  {
346  warning() << "recordAddress: Invalid Class ID found in IOpaqueAddress @"
347  << pAddress << ". IOA will not be recorded"
348  << endmsg;
349  return StatusCode::FAILURE;
350  }
351 
352  //do not overwrite a persistent object
353  if (m_pPPS) {
354  DataProxy* dp = m_pStore->proxy (dataID, skey);
355  if (!dp) {
356  dp = m_pPPS->retrieveProxy(dataID, skey, *m_pStore);
357  }
358  if (dp && dp->provider()) {
359  std::string clidTypeName;
360  m_pCLIDSvc->getTypeNameOfID(dataID, clidTypeName).ignore();
361  warning() << "recordAddress: failed for key="<< skey << ", type "
362  << clidTypeName
363  << " (CLID " << dataID << ')'
364  << "\n there is already a persistent version of this object. Will not record a duplicate! "
365  << endmsg;
366  return StatusCode::FAILURE;
367  }
368  }
369 
370  // Check if a key already exists
371  DataProxy* dp = m_pStore->proxy_exact(dataID, skey);
372  if (0 == dp && 0 != m_pPPS) {
373  dp = m_pPPS->retrieveProxy(dataID, skey, *m_pStore);
374  }
375 
376  // Now treat the various cases:
377  if (0 == dp)
378  {
379  // create the proxy object and register it
380  dp = new DataProxy (TransientAddress (dataID, skey,
381  pAddress, clearAddressFlag),
382  m_pDataLoader.get(), true, true);
383  m_pStore->addToStore(dataID, dp).ignore();
384 
385  addAutoSymLinks (skey, dataID, dp, 0, false);
386  }
387  else if ((0 != dp) && (0 == dp->address()))
388  // Note: intentionally not checking dp->isValidAddress()
389  {
390  // Update proxy with IOpaqueAddress
391  dp->setAddress(pAddress);
392  }
393  else
394  {
395  string errType;
396  m_pCLIDSvc->getTypeNameOfID(dataID, errType).ignore();
397  warning() << "recordAddress: preexisting proxy @" << dp
398  << " with non-NULL IOA found for key "
399  << skey << " type " << errType << " (" << dataID << "). \n"
400  << "Cannot record IOpaqueAddress @" << pAddress
401  << endmsg;
402  return StatusCode::FAILURE;
403  }
404 
405  return StatusCode::SUCCESS;
406 
407 }
408 
411 // add proxy (with IOpaqueAddress that will later be retrieved from P)
413 StatusCode SGImplSvc::recordAddress(IOpaqueAddress* pAddress, bool clearAddressFlag)
414 {
415  lock_t lock (m_mutex);
416  assert(0 != pAddress);
417 
418  CLID dataID = pAddress->clID();
419 
420  string gK = (pAddress->par())[1]; // transient name by convention
421  if (gK.empty()) gK = (pAddress->par())[0]; // FIXME backward compatibility
422  if (gK.empty()) gK = createKey(dataID);
423 
424  return this->recordAddress(gK, pAddress, clearAddressFlag);
425 }
426 
428  const string& gK,
429  DataObject* pDObj,
430  bool allowMods,
431  bool resetOnly) {
432  // locate the proxy
433  DataProxy* dp = m_pStore->proxy_exact(dataID, gK);
434 
435  if (0 != dp) { //proxy found
436  if (0 != dp->object())
437  {
438  // Case 0: duplicated proxy
439  warning() << " setupProxy:: error setting up proxy for key "
440  << gK << " and clid " << dataID
441  << "\n Pre-existing valid DataProxy @"<< dp
442  << " found in Store for key " << dp->object()->name()
443  << " with clid " << dp->object()->clID()
444  << endmsg;
445  recycle(pDObj); // commit this object to trash
446  dp = 0;
447  } else {
448  // Case 1: Proxy found... if not valid, update it:
449  dp->setObject(pDObj);
450  if (!allowMods) dp->setConst();
451  }
452  } else {
453  // Case 2: No Proxy found:
454  dp = new DataProxy(pDObj,
455  TransientAddress(dataID, gK),
456  !allowMods, resetOnly);
457  if (!(m_pStore->addToStore(dataID, dp).isSuccess())) {
458  warning() << " setupProxy:: could not addToStore proxy @" << dp
459  << endmsg;
460  recycle(pDObj); // commit this object to trash
461  delete dp;
462  dp = 0;
463  }
464  }
465  return dp;
466 }
467 
470 {
471  lock_t lock (m_mutex);
472  store()->setStoreID(id);
473 }
476 {
477  lock_t lock (m_mutex);
478  return store()->storeID();
479 }
480 
481 
482 void
483 SGImplSvc::keys(const CLID& id, std::vector<std::string>& vkeys,
484  bool includeAlias, bool onlyValid)
485 
486 {
487  lock_t lock (m_mutex);
488  return store()->keys(id, vkeys, includeAlias, onlyValid);
489 }
490 
491 
492 bool SGImplSvc::isSymLinked(const CLID& linkID, DataProxy* dp)
493 {
494  return (0 != dp) ? dp->transientID(linkID) : false;
495 }
496 
497 
498 StatusCode
500  const CallBackID& c2,
501  const IOVSvcCallBackFcn& fcn,
502  bool trigger)
503 {
504  lock_t lock (m_mutex);
505  return ( m_pIOVSvc->regFcn(c1,c2,fcn,trigger) );
506 }
507 
508 
509 StatusCode
510 SGImplSvc::regFcn( const std::string& toolName,
511  const CallBackID& c2,
512  const IOVSvcCallBackFcn& fcn,
513  bool trigger)
514 {
515  lock_t lock (m_mutex);
516  return ( m_pIOVSvc->regFcn(toolName,c2,fcn,trigger) );
517 }
518 
519 
521 // Dump Contents in store:
522 string SGImplSvc::dump() const
523 {
524  lock_t lock (m_mutex);
525  auto out_buffer = std::string{};
526  auto out = std::back_inserter(out_buffer);
527  const std::string me = name();
528  std::format_to(out, "{}: <<<<<<<<<<<<<<<<< Data Store Dump >>>>>>>>>>>>>>> \n", me);
529  std::format_to(out, "{}: SGImplSvc()::dump() which is {} \n", me, m_storeLoaded ? "LOADED" : "NOT LOADED");
530 
531  DataStore::ConstStoreIterator s_iter, s_end;
532  store()->tRange(s_iter, s_end).ignore();
533 
534  for (; s_iter != s_end; ++s_iter)
535  {
536 
537  CLID id = s_iter->first;
538  int nProxy = store()->typeCount(id);
539  std::string tname;
540  m_pCLIDSvc->getTypeNameOfID(id, tname).ignore();
541  std::format_to(out, "{}: Found {} {} for ClassID {} ({}): \n", me, nProxy, ((nProxy == 1) ? "proxy" : "proxies"), id, tname);
542 
543  // loop over each type:
544  SG::ConstProxyIterator p_iter = (s_iter->second).begin();
545  SG::ConstProxyIterator p_end = (s_iter->second).end();
546 
547  while (p_iter != p_end) {
548  const DataProxy& dp(*p_iter->second);
549  std::format_to(out, "{}: flags: ({:7s}, {:8s}, {:6s}) --- data: {:10p} --- key: {}\n", me,
550  (dp.isValid() ? "valid" : "INVALID"),
551  (dp.isConst() ? "locked" : "UNLOCKED"),
552  (dp.isResetOnly() ? "reset" : "DELETE"),
553  dbg::ptr(dp.object()), p_iter->first);
554  ++p_iter;
555  }
556  }
557  std::format_to(out, "{}: <<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>> \n", me);
558  return out_buffer;
559 }
560 
561 DataStore*
563 {
564  return m_pStore;
565 }
566 
567 const DataStore*
569 {
570  return m_pStore;
571 }
572 
573 
575 // Make a soft link to the object with key
577 StatusCode SGImplSvc::symLink(const void* pObject, CLID linkID)
578 {
579  lock_t lock (m_mutex);
580  SG::DataProxy* dp(proxy(pObject));
581 
582  // if symLink already exists, just return success
583  return isSymLinked(linkID,dp) ?
584  StatusCode::SUCCESS :
585  addSymLink(linkID,dp);
586 }
587 
588 StatusCode SGImplSvc::symLink(const CLID id, const std::string& key, const CLID linkID)
589 {
590  lock_t lock (m_mutex);
591  SG::DataProxy* dp(proxy(id, key, false));
592  // if symLink already exists, just return success
593  return isSymLinked(linkID,dp) ?
594  StatusCode::SUCCESS :
595  addSymLink(linkID,dp);
596 }
597 
598 
601 {
602  if (0 == dp) {
603  warning() << "addSymLink: no target DataProxy found. Sorry, can't link to a non-existing data object"
604  << endmsg;
605  return StatusCode::FAILURE;
606  }
607  StatusCode sc = m_pStore->addSymLink(linkid, dp);
608 
609  // If the symlink is a derived->base conversion, then we may have
610  // a different transient pointer for the symlink.
611  if (sc.isSuccess() && dp->object()) {
612  void* baseptr = SG::DataProxy_cast (dp, linkid);
613  if (baseptr)
614  this->t2pRegister (baseptr, dp).ignore();
615  }
616  return sc;
617 }
618 
619 
620 StatusCode SGImplSvc::setAlias(const void* pObject, const std::string& aliasKey)
621 {
622  lock_t lock (m_mutex);
623 
624  SG::DataProxy* dp(0);
625  dp = proxy(pObject);
626  if (0 == dp) {
627  error() << "setAlias: problem setting alias "
628  << aliasKey << '\n'
629  << "DataObject does not exist, record before setting alias."
630  << endmsg;
631  return StatusCode::FAILURE;
632  }
633 
634  StatusCode sc = addAlias(aliasKey, dp);
635  if (sc.isFailure()) {
636  error() << "setAlias: problem setting alias "
637  << aliasKey << '\n'
638  << "DataObject does not exist, record before setting alias."
639  << endmsg;
640  return StatusCode::FAILURE;
641  }
642 
643  return StatusCode::SUCCESS;
644 }
645 
646 
648  const std::string& key, const std::string& aKey)
649 {
650  lock_t lock (m_mutex);
651 
652  SG::DataProxy* dp(0);
653  dp = proxy(clid, key);
654  if (0 == dp) {
655  error() << "setAlias: problem setting alias "
656  << std::string(aKey) << '\n'
657  << "DataObject does not exist, record before setting alias."
658  << endmsg;
659  return StatusCode::FAILURE;
660  }
661 
662  StatusCode sc = addAlias(aKey, dp);
663  if (sc.isFailure()) {
664  error() << "setAlias: problem setting alias "
665  << (std::string)aKey << '\n'
666  << "DataObject does not exist, record before setting alias."
667  << endmsg;
668  return StatusCode::FAILURE;
669  }
670 
671  return StatusCode::SUCCESS;
672 }
673 
674 StatusCode SGImplSvc::setAlias(SG::DataProxy* proxy, const std::string& aliasKey)
675 {
676  return addAlias( aliasKey, proxy );
677 }
678 
680 SGImplSvc::addAlias(const std::string& aliasKey, DataProxy* proxy)
681 {
682  if (0 == proxy) {
683  warning() << "addAlias: no target DataProxy given, Cannot alias to a non-existing object"
684  << endmsg;
685  return StatusCode::FAILURE;
686  }
687 
688  // add key to proxy and to ProxyStore
689  return m_pStore->addAlias(aliasKey, proxy);
690 }
691 
692 int SGImplSvc::typeCount(const CLID& id) const
693 {
694  lock_t lock (m_mutex);
695  return m_pStore->typeCount(id);
696 }
697 
698 
699 bool
700 SGImplSvc::contains(const CLID id, const std::string& key) const
701 {
702  try {
703  return (0 != proxy(id, key, true));
704  } catch(...) { return false; }
705 }
706 
707 
708 bool
709 SGImplSvc::transientContains(const CLID id, const std::string& key) const
710 {
711  try {
712  return (0 != transientProxy(id, key));
713  } catch(...) { return false; }
714 }
715 
716 
717 DataProxy*
718 SGImplSvc::proxy(const void* const pTransient) const
719 {
720  // No lock needed here --- the T2pmap held by DataStore has its own locking
721  // (and we were seeing contention here).
722  //lock_t lock (m_mutex);
723  return m_pStore->locatePersistent(pTransient);
724 }
725 
726 DataProxy*
727 SGImplSvc::proxy(const CLID& id) const
728 {
729  return proxy(id, false);
730 }
731 
732 DataProxy*
733 SGImplSvc::proxy(const CLID& id, bool checkValid) const
734 {
735  DataProxy* dp = nullptr;
736  {
737  lock_t lock (m_mutex);
738  dp = m_pStore->proxy(id);
739  if (0 == dp && 0 != m_pPPS) {
741  dp = m_pPPS->retrieveProxy(id, string("DEFAULT"), *pStore);
742  }
743  }
745  // Be sure to release the lock before this.
746  // isValid() may call back to the store, so we could otherwise deadlock..
747  if (checkValid && 0 != dp) {
748  // FIXME: For keyless retrieve, this checks only the first instance
749  // of the CLID in store. If that happens to be invalid, but the second
750  // is valid - this does not work (when checkValid is requested).
751  return dp->isValid() ? dp : 0;
752  }
753  return dp;
754 }
755 
756 DataProxy*
757 SGImplSvc::proxy(const CLID& id, const string& key) const
758 {
759  return proxy(id, key, false);
760 }
761 
762 DataProxy*
763 SGImplSvc::proxy(const CLID& id, const string& key, bool checkValid) const
764 {
765  DataProxy* dp = nullptr;
766  {
767  lock_t lock (m_mutex);
768  dp = m_pStore->proxy(id, key);
769 #ifdef DEBUG_SGIMPL
770  if (!dp) dbg::print(stderr, "::SGImplSvc::proxy(name={}, key={}): data proxy is null, m_pPPS is {}\n", this->name(), key, m_pPPS == 0 ? "NULL" : "NOT NULL");
771 #endif
772  if (0 == dp && 0 != m_pPPS) {
774  dp = m_pPPS->retrieveProxy(id, key, *pStore);
775 #ifdef DEBUG_SGIMPL
776  if (!dp) dbg::print(stderr, "::SGImplSvc::proxy(name={}, key={}): data proxy is still null\n", this->name(), key);
777 #endif
778  }
779  }
780  // Be sure to release the lock before this.
781  // isValid() may call back to the store, so we could otherwise deadlock..
782  if (checkValid && 0 != dp && !(dp->isValid())) {
783  dp = 0;
784  }
785  return dp;
786 }
787 
788 
795 {
796  lock_t lock (m_mutex);
797  return m_pStore->addToStore (id, proxy);
798 }
799 
800 
822  const std::string& key,
823  bool allowMods,
824  bool returnExisting)
825 {
826  lock_t lock (m_mutex);
827  const void* raw_ptr = obj.get();
828  const std::type_info* tinfo = nullptr;
829 
830  if (DataBucketBase* bucket = dynamic_cast<DataBucketBase*> (obj.get())) {
831  raw_ptr = bucket->object();
832  tinfo = &bucket->tinfo();
833  }
834 
835  if (returnExisting) {
836  SG::DataProxy* proxy = this->proxy (obj->clID(), key);
837  if (proxy && proxy->isValid()) return proxy;
838 
839  // Look for the same object recorded under a different key/clid.
840  proxy = this->proxy (raw_ptr);
841  if (proxy && proxy->isValid()) {
842  if (proxy->transientID (obj->clID())) {
843  // CLID matches. Make an alias.
844  if (addAlias (key, proxy).isFailure()) {
845  CLID clid = proxy->clID();
846  std::string clidTypeName;
847  m_pCLIDSvc->getTypeNameOfID(clid, clidTypeName).ignore();
848  warning() << "SGImplSvc::recordObject: addAlias fails for object "
849  << clid << "[" << clidTypeName << "] " << proxy->name()
850  << " and new key " << key
851  << endmsg;
852 
853  proxy = nullptr;
854  }
855  }
856 
857  else if (key == proxy->name() || proxy->hasAlias(key) > 0)
858  {
859  // key matches. Make a symlink.
860  if (addSymLink (obj->clID(), proxy).isFailure()) {
861  CLID clid = proxy->clID();
862  std::string clidTypeName;
863  m_pCLIDSvc->getTypeNameOfID(clid, clidTypeName).ignore();
864  CLID newclid = obj->clID();
865  std::string newclidTypeName;
866  m_pCLIDSvc->getTypeNameOfID(newclid, newclidTypeName).ignore();
867  error() << "SGImplSvc::recordObject: addSymLink fails for object "
868  << clid << "[" << clidTypeName << "] " << proxy->name()
869  << " and new clid " << newclid << "[" << newclidTypeName << "]"
870  << endmsg;
871  proxy = nullptr;
872  }
873  }
874 
875  else {
876  CLID clid = proxy->clID();
877  std::string clidTypeName;
878  m_pCLIDSvc->getTypeNameOfID(clid, clidTypeName).ignore();
879  CLID newclid = obj->clID();
880  std::string newclidTypeName;
881  m_pCLIDSvc->getTypeNameOfID(newclid, newclidTypeName).ignore();
882  error() << "SGImplSvc::recordObject: existing object found with "
883  << clid << "[" << clidTypeName << "] " << proxy->name()
884  << " but neither clid " << newclid << "[" << newclidTypeName << "]"
885  << " nor key " << key << " match."
886  << endmsg;
887  proxy = nullptr;
888  }
889 
890  return proxy;
891  }
892  }
893 
894  const bool resetOnly = true;
895  const bool noHist = false;
896  SG::DataProxy* proxy = nullptr;
897  if (this->typeless_record (obj.get(), key, raw_ptr,
898  allowMods, resetOnly, noHist, tinfo,
899  &proxy, true).isFailure())
900  {
901  return nullptr;
902  }
903  return proxy;
904 }
905 
906 
911 {
913 }
914 
915 
922 void SGImplSvc::setSlotNumber (int slot, int numSlots)
923 {
924  m_slotNumber = slot;
925  m_numSlots = numSlots;
926 
928  header->setArenaForSlot (slot, &m_arena);
929 }
930 
931 
932 std::vector<const SG::DataProxy*>
934 {
935  lock_t lock (m_mutex);
936  const std::vector<SG::DataProxy*>& proxies = store()->proxies();
937  std::vector<const SG::DataProxy*> ret (proxies.begin(), proxies.end());
938  return ret;
939 }
940 
941 
942 std::vector<CLID>
944 {
945  lock_t lock (m_mutex);
946 
947  using std::distance;
948  DataStore::ConstStoreIterator s_iter, s_end;
949  store()->tRange(s_iter, s_end).ignore();
950 
951  std::vector<CLID> clids;
952  clids.reserve( distance( s_iter, s_end ) );
953 
954  for (; s_iter != s_end; ++s_iter ) {
955  const CLID id = s_iter->first;
956  clids.push_back (id);
957  }
958 
959  return clids;
960 }
961 
962 
963 DataProxy*
964 SGImplSvc::transientProxy(const CLID& id, const string& key) const
965 {
966  lock_t lock (m_mutex);
967  DataProxy* dp(m_pStore->proxy(id, key));
968  return ( (0 != dp && dp->isValidObject()) ? dp : 0 );
969 }
970 
971 DataObject*
972 SGImplSvc::accessData(const CLID& id) const
973 {
974  lock_t lock (m_mutex);
975  DataProxy* theProxy(proxy(id, true));
976  return (0 == theProxy) ? 0 : theProxy->accessData();
977 }
978 
979 DataObject*
980 SGImplSvc::accessData(const CLID& id, const string& key) const
981 {
982  lock_t lock (m_mutex);
983  DataProxy* theProxy(proxy(id, key, true));
984  return (0 == theProxy) ? 0 : theProxy->accessData();
985 }
986 
987 bool
989  const std::string& keyA, const std::string& keyB )
990 {
991  lock_t lock (m_mutex);
992  const bool checkValid = true;
993  DataProxy* a = proxy( id, keyA, checkValid );
994  DataProxy* b = proxy( id, keyB, checkValid );
995  if ( 0 == a || 0 == b ) { return false; }
996  DataObject* objA = a->accessData();
997  DataObject* objB = b->accessData();
998 
999  if ( 0 == objA || 0 == objB ) { return false; }
1000  // prevent 'accidental' release of DataObjects...
1001  const unsigned int refCntA = objA->addRef();
1002  const unsigned int refCntB = objB->addRef();
1003  // in case swap is being specialized for DataObjects
1004  using std::swap;
1005  swap( objA, objB );
1006  a->setObject( objA );
1007  b->setObject( objB );
1008  // and then restore old ref-count;
1009  return ( (refCntA-1) == objA->release() &&
1010  (refCntB-1) == objB->release() );
1011 }
1012 
1013 StatusCode
1014 SGImplSvc::typeless_record( DataObject* obj, const std::string& key,
1015  const void* const raw_ptr,
1016  bool allowMods, bool resetOnly, bool noHist)
1017 {
1018  return typeless_record (obj, key, raw_ptr, allowMods, resetOnly, noHist, 0,
1019  nullptr, true);
1020 }
1021 
1022 
1023 StatusCode
1024 SGImplSvc::typeless_record( DataObject* obj, const std::string& key,
1025  const void* const raw_ptr,
1026  bool allowMods, bool resetOnly, bool noHist,
1027  const std::type_info* tinfo)
1028 {
1029  return typeless_record (obj, key, raw_ptr, allowMods, resetOnly, noHist,tinfo,
1030  nullptr, true);
1031 }
1032 
1033 
1034 StatusCode
1035 SGImplSvc::typeless_record( DataObject* obj, const std::string& key,
1036  const void* const raw_ptr,
1037  bool allowMods, bool resetOnly, bool noHist,
1038  const std::type_info* tinfo,
1039  SG::DataProxy** proxy_ret,
1040  bool noOverwrite)
1041 {
1042  lock_t lock (m_mutex);
1043  SG::DataProxy* proxy =
1044  record_impl( obj, key, raw_ptr, allowMods, resetOnly, !noOverwrite, tinfo);
1045  if ( proxy == nullptr )
1046  return StatusCode::FAILURE;
1047  if (proxy_ret)
1048  *proxy_ret = proxy;
1049 
1050  if ( !m_ActivateHistory || noHist ) {
1051  return StatusCode::SUCCESS;
1052  }
1053 
1054  if ( store()->storeID() != StoreID::EVENT_STORE ) {
1055  return StatusCode::SUCCESS;
1056  } else {
1057  return record_HistObj( obj->clID(), key, name(), allowMods, resetOnly );
1058  }
1059 }
1060 
1061 StatusCode
1063  DataObject* obj,
1064  const std::string& key,
1065  const void* const raw_ptr,
1066  bool allowMods,
1067  bool noHist,
1068  const std::type_info* tinfo)
1069 {
1070  lock_t lock (m_mutex);
1071  StatusCode sc(StatusCode::SUCCESS);
1072  SG::DataProxy* toRemove(proxy(clid, key, false));
1073  if (0 != toRemove) {
1074  toRemove->addRef();
1075  const bool FORCEREMOVE(true);
1076  sc =removeProxy(toRemove, (void*)0, FORCEREMOVE);
1077  }
1078  if (sc.isSuccess()) {
1079  const bool ALLOWOVERWRITE(true);
1080  const bool NORESET(false);
1081  if (record_impl( obj, key, raw_ptr, allowMods, NORESET, ALLOWOVERWRITE, tinfo) == nullptr)
1082  sc = StatusCode::FAILURE;
1083  else if ( m_ActivateHistory && noHist && store()->storeID() == StoreID::EVENT_STORE ) {
1084  sc = record_HistObj( obj->clID(), key, name(), allowMods, NORESET );
1085  }
1086  }
1087  //for detector store objects managed by IIOVSvc, replace the old proxy with the new one (#104311)
1088  if (toRemove && sc.isSuccess() && store()->storeID() == StoreID::DETECTOR_STORE) {
1089  sc = m_pIOVSvc->replaceProxy(toRemove, proxy(clid, key));
1090  }
1091  if (toRemove)
1092  toRemove->release();
1093  return sc;
1094 }
1095 
1097 SGImplSvc::record_impl( DataObject* pDObj, const std::string& key,
1098  const void* const raw_ptr,
1099  bool allowMods, bool resetOnly, bool allowOverwrite,
1100  const std::type_info* tinfo)
1101 {
1102  CLID clid = pDObj->clID();
1103  std::string rawKey(key);
1104  bool isVKey(SG::VersionedKey::isVersionedKey(key));
1105  if (isVKey) {
1106  //FIXME VersionedKeys will need to be handled more efficiently
1107  SG::VersionedKey vk(rawKey);
1108  DataProxy *dp(proxy(clid, vk.key()));
1109  if (dp) {
1110  //proxies primary key
1111  const std::string& pTAName(dp->name());
1112  //original key as versioned
1113  SG::VersionedKey primaryVK(pTAName);
1114 
1115  //if the existing matching object has no version
1116  //create a versioned alias for the original unversioned key
1117  //so it will remain accessible
1118  if (!SG::VersionedKey::isVersionedKey(pTAName)) {
1119  if (!(this->addAlias(primaryVK.rawVersionKey(), dp)).isSuccess()) {
1120  warning() << "record_impl: Could not setup alias key "
1121  << primaryVK.rawVersionKey()
1122  << " for unversioned object " << pTAName
1123  << endmsg;
1124  return nullptr;
1125  }
1126  }
1127  if (vk.isAuto()) {
1128  //make a new versioned key incrementing the existing version
1129  SG::VersionedKey newVK(primaryVK.key(), primaryVK.version()+1);
1130  //FIXME this will fail in a confusing way if version+1 is in use
1131  //FIXME need a better error message below, probably looking at all
1132  //FIXME aliases
1133  rawKey = newVK.rawVersionKey();
1134  }
1135  }
1136  }
1137  if (!allowOverwrite && m_pPPS) {
1138  //do not overwrite a persistent object
1139  DataProxy* dp = m_pStore->proxy (clid, rawKey);
1140  if (!dp) {
1141  dp = m_pPPS->retrieveProxy(clid, rawKey, *m_pStore);
1142  }
1143  if (dp && dp->provider()) {
1144  std::string clidTypeName;
1145  m_pCLIDSvc->getTypeNameOfID(clid, clidTypeName).ignore();
1146  warning() << "record_impl: you are recording an object with key "
1147  << rawKey << ", type " << clidTypeName
1148  << " (CLID " << clid << ')'
1149  << "\n There is already a persistent version of this object. Recording a duplicate may lead to unreproducible results and it is deprecated."
1150  << endmsg;
1151  }
1152  }
1153  //now check whether raw_ptr has already been recorded
1154  //We need to do this before we create the bucket, the proxy etc
1155  SG::DataProxy* dp(proxy(raw_ptr));
1156  if (0 != dp) {
1157  std::string clidTypeName;
1158  m_pCLIDSvc->getTypeNameOfID(clid, clidTypeName).ignore();
1159  warning() << "record_impl: failed for key="<< rawKey << ", type "
1160  << clidTypeName
1161  << " (CLID " << clid << ')'
1162  << "\n object @" << raw_ptr
1163  << " already in store with key="<< dp->name()
1164  << ". Will not record a duplicate! "
1165  << endmsg;
1166  if (pDObj != dp->object()) {
1167  DataBucketBase* pDBB(dynamic_cast<DataBucketBase*>(pDObj));
1168  if (!pDBB) std::abort();
1169  pDBB->relinquish(); //don't own the data obj already recorded!
1170  }
1171  this->recycle(pDObj);
1172  return nullptr;
1173  }
1174 
1175 
1176  // setup the proxy
1177  dp = setupProxy( clid, rawKey, pDObj, allowMods, resetOnly );
1178  if ( 0 == dp ) {
1179  std::string clidTypeName;
1180  m_pCLIDSvc->getTypeNameOfID(clid, clidTypeName).ignore();
1181  warning() << "record_impl: Problem setting up the proxy for object @"
1182  << raw_ptr
1183  << "\n recorded with key " << rawKey
1184  << " of type " << clidTypeName
1185  << " (CLID " << clid << ") in DataObject @" << pDObj
1186  << endmsg;
1187 
1188  return nullptr;
1189  }
1190 
1191  // record in t2p:
1192  if ( !(this->t2pRegister( raw_ptr, dp )).isSuccess() ) {
1193  std::string clidTypeName;
1194  m_pCLIDSvc->getTypeNameOfID(clid, clidTypeName).ignore();
1195  warning() << "record_impl: can not add to t2p map object @" <<raw_ptr
1196  << "\n with key " << rawKey
1197  << " of type " << clidTypeName
1198  << " (CLID " << clid << ')'
1199  << endmsg;
1200  return nullptr;
1201  }
1202 
1203  addAutoSymLinks (rawKey, clid, dp, tinfo);
1204 
1205  //handle versionedKeys: we register an alias with the "true" key
1206  //unless an object as already been recorded with that key.
1207  //Notice that addAlias overwrites any existing alias, so a generic
1208  //retrieve will always return the last version added
1209  //FIXME not the one with the highest version
1210  if (isVKey) {
1211  SG::VersionedKey vk(rawKey);
1212  if (!(this->addAlias(vk.key(), dp)).isSuccess()) {
1213  warning() << "record_impl: Could not setup alias key " << vk.key()
1214  << " for VersionedKey " << rawKey
1215  << ". Generic access to this object with clid" << clid
1216  << " will not work"
1217  << endmsg;
1218  }
1219  }
1220 
1221  return dp;
1222 }
1223 
1224 DataProxy*
1226  bool checkValid) const
1227 {
1228  DataProxy* dp = m_pStore->proxy(tAddr);
1229 
1230  if (checkValid && 0 != dp) {
1231  return dp->isValid() ? dp : 0;
1232  } else {
1233  return dp;
1234  }
1235 }
1236 
1237 StatusCode
1239  bool forceRemove)
1240 {
1241  lock_t lock (m_mutex);
1242  // check if valid proxy
1243  if (0 == proxy) return StatusCode::FAILURE;
1244 
1245  if (0 == pTrans) {
1246  DataBucketBase* bucket = dynamic_cast<DataBucketBase*>(proxy->object());
1247  if (bucket) pTrans = bucket->object();
1248  }
1249 
1250  // remove all entries from t2p map
1251  // --- only if the proxy actually has an object!
1252  // otherwise, we can trigger I/O.
1253  // besides being useless here, we can get deadlocks if we
1254  // call into the I/O code while holding the SG lock.
1255  if (proxy->isValidObject()) {
1256  this->t2pRemove(pTrans);
1258  for (SG::DataProxy::CLIDCont_t::const_iterator i = clids.begin();
1259  i != clids.end();
1260  ++i)
1261  {
1262  void* ptr = SG::DataProxy_cast (proxy, *i);
1263  this->t2pRemove(ptr);
1264  }
1265  }
1266 
1267  // remove from store
1268  return m_pStore->removeProxy(proxy, forceRemove, true);
1269 }
1270 
1271 StatusCode
1272 SGImplSvc::t2pRegister(const void* const pTrans, DataProxy* const pPers)
1273 {
1274  return m_pStore->t2pRegister(pTrans, pPers);
1275 }
1276 
1277 
1278 void
1279 SGImplSvc::t2pRemove(const void* const pTrans)
1280 {
1281  m_pStore->t2pRemove(pTrans);
1282 }
1283 
1284 void
1285 SGImplSvc::msg_update_handler(Gaudi::Details::PropertyBase& /*outputLevel*/)
1286 {
1287  setUpMessaging();
1288  updateMsgStreamOutputLevel( outputLevel() );
1289  msgSvc()->setOutputLevel(name(), outputLevel());
1290 }
1291 
1292 StatusCode
1295  SG::ConstProxyIterator& end) const {
1296  lock_t lock (m_mutex);
1297  return m_pStore->pRange(id,begin,end);
1298 }
1299 
1300 StatusCode SGImplSvc::setConst(const void* pObject)
1301 {
1302  lock_t lock (m_mutex);
1303  // Check if DataProxy does not exist
1304  DataProxy * dp = proxy(pObject);
1305 
1306  if (0 == dp)
1307  {
1308  warning() << "setConst: NO Proxy for the dobj you want to set const"
1309  << endmsg;
1310  return StatusCode::FAILURE;
1311  }
1312 
1313  dp->setConst();
1314  return StatusCode::SUCCESS;
1315 }
1316 
1317 
1318 // remove an object from Store, will remove its proxy if not reset only
1319 StatusCode
1320 SGImplSvc::remove(const void* pObject)
1321 {
1322  lock_t lock (m_mutex);
1323  return removeProxy(proxy(pObject), pObject);
1324 }
1325 
1326 
1327 // remove an object and its proxy from Store
1328 StatusCode
1329 SGImplSvc::removeDataAndProxy(const void* pObject)
1330 {
1331  lock_t lock (m_mutex);
1332  const bool FORCEREMOVE(true);
1333  return removeProxy(proxy(pObject), pObject, FORCEREMOVE);
1334 }
1335 
1336 //put a bad (unrecordable) dobj away
1337 void SGImplSvc::recycle(DataObject* pBadDObj) {
1338  assert(pBadDObj);
1339  pBadDObj->addRef();
1340  m_trash.push_back(pBadDObj);
1341 }
1342 
1343 //throw away bad objects
1345  lock_t lock (m_mutex);
1346  while (!m_trash.empty()) {
1347  m_trash.front()->release(); //delete the bad data object
1348  m_trash.pop_front(); //remove pointer from list
1349  }
1350 }
1351 
1352 
1353 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1354 
1355 bool SGImplSvc::bindHandleToProxy(const CLID& id, const string& key,
1356  IResetable* ir, DataProxy *&dp)
1357 {
1358  lock_t lock (m_mutex);
1359 
1360  dp = m_pStore->proxy (id, key);
1361  if (dp == nullptr && m_pPPS != nullptr) {
1362  dp = m_pPPS->retrieveProxy(id, key, *m_pStore);
1363  }
1364 
1365  if (0 == dp) return false;
1366 
1367  if (! dp->bindHandle(ir) ) {
1368  fatal() << "DataHandle at " << hex << ir << dec
1369  << " already bound to DataProxy with key " << ir->key()
1370  << ". Cannot bind to proxy " << dp->name() << " as well\n"
1371  << " You have probably registered multiple callbacks via regFcn with the same DataHandle using different keys (DataProxies)\n"
1372  << endmsg;
1373  return false;
1374  }
1375 
1376  //already done in DataHandleBase::setState dp->addRef();
1377 
1378 #ifndef NDEBUG
1379  SG_MSG_DEBUG(" Bound handle " << MSG::hex << ir << " to proxy "
1380  << dp << MSG::dec);
1381 #endif
1382  return true;
1383 }
1384 
1385 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1386 
1387 bool SGImplSvc::bindHandleToProxyAndRegister (const CLID& id, const std::string& key,
1389 {
1390  lock_t lock (m_mutex);
1391  bool ret = bindHandleToProxy (id, key, ir, dp);
1392  if (ret) {
1393  StatusCode sc = m_pIOVSvc->regProxy(dp,key);
1394  if (sc.isFailure()) return false;
1395  }
1396  return true;
1397 }
1398 
1399 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1400 
1401 bool SGImplSvc::bindHandleToProxyAndRegister (const CLID& id, const std::string& key,
1403  const CallBackID& c,
1404  const IOVSvcCallBackFcn& fcn,
1405  bool trigger)
1406 {
1407  lock_t lock (m_mutex);
1408  bool ret = bindHandleToProxy (id, key, ir, dp);
1409  if (ret) {
1410  StatusCode sc = m_pIOVSvc->regProxy(dp,key);
1411  if (sc.isFailure()) return false;
1412  sc = m_pIOVSvc->regFcn(dp,c,fcn,trigger);
1413  if (sc.isFailure()) return false;
1414  }
1415  return true;
1416 }
1417 
1418 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1419 
1420 StatusCode
1421 SGImplSvc::record_HistObj(const CLID& id, const std::string& key,
1422  const std::string& store,
1423  bool allowMods, bool resetOnly) {
1424 
1425  DataHistory *dho;
1426  dho = m_pHistorySvc->createDataHistoryObj( id, key, store );
1427 
1428  std::string idname;
1429  StatusCode sc = m_pCLIDSvc->getTypeNameOfID(id, idname);
1430  if (sc.isFailure() || idname.empty() ) {
1431  idname = std::to_string(id);
1432  }
1433  idname += '/';
1434  idname += key;
1435 
1436  DataObject* obj = SG::asStorable(dho);
1437 
1438  const bool ALLOWOVERWRITE(false);
1439  if (record_impl(obj, idname, dho, allowMods, resetOnly, ALLOWOVERWRITE,
1440  &typeid(DataHistory)) == nullptr)
1441  return StatusCode::FAILURE;
1442  return StatusCode::SUCCESS;
1443 }
1444 
1445 
1455 SGImplSvc::stringToKey (const std::string& str, CLID clid)
1456 {
1458  return m_stringpool.stringToKey (str, clid);
1459 }
1460 
1461 
1469 const std::string* SGImplSvc::keyToString (sgkey_t key) const
1470 {
1472  return m_stringpool.keyToString (key);
1473 }
1474 
1475 
1484 const std::string*
1486 {
1488  return m_stringpool.keyToString (key, clid);
1489 }
1490 
1491 
1505  const std::string& str,
1506  CLID clid)
1507 {
1509  if (!m_stringpool.registerKey (key, str, clid)) {
1510  CLID clid2;
1511  const std::string* str2 = m_stringpool.keyToString (key, clid2);
1512  REPORT_MESSAGE (MSG::WARNING) << "The numeric key " << key
1513  << " maps to multiple string key/CLID pairs: "
1514  << *str2 << "/" << clid2 << " and "
1515  << str << "/" << clid;
1516  }
1517 }
1518 
1519 
1528 {
1529  // We should hold m_stringPoolMutex before touching the pool.
1530  // But if we acquire the locks for both this and the other store,
1531  // we risk a deadlock. So first copy the other pool, so that we
1532  // don't need to hold both locks at the same time.
1534  {
1535  lock_t lock (other.m_stringPoolMutex);
1536  tmp = other.m_stringpool;
1537  }
1539  return m_stringpool.merge (tmp);
1540 }
1541 
1542 
1543 void
1544 SGImplSvc::releaseObject(const CLID& id, const std::string& key) {
1545  lock_t lock (m_mutex);
1546  DataProxy *pP(0);
1547  if (0 != (pP = proxy(id, key))) {
1548  // remove all entries from t2p map
1550  SG::DataProxy::CLIDCont_t::const_iterator i(clids.begin()), e(clids.end());
1551  while (i != e) t2pRemove(SG::DataProxy_cast (pP, *i++));
1552  DataBucketBase *pDBB(dynamic_cast<DataBucketBase*>(pP->object()));
1553  //tell the bucket to let go of the data object
1554  if (0 != pDBB) pDBB->relinquish(); //somebody else better took ownership
1555  bool hard_reset = (m_numSlots > 1);
1556  pP->reset (hard_reset);
1557  }
1558 }
1559 
1560 void
1562  lock_t lock (m_mutex);
1563 
1564  // Remove transient pointer entries for this proxy.
1565  // But do that only if the proxy has a valid object.
1566  // Otherwise, we could trigger I/O --- which we don't want since it's useless
1567  // (we'd just destroy the object immediately). In some cases it can also
1568  // lead to a deadlock (see ATR-24482).
1569  if (dp->isValidObject()) {
1570  SG::DataProxy::CLIDCont_t clids = dp->transientID();
1571  SG::DataProxy::CLIDCont_t::const_iterator i(clids.begin()), e(clids.end());
1572  while (i != e) {
1574  }
1575  }
1576 
1577  bool hard_reset = (m_numSlots > 1);
1578  dp->reset (hard_reset);
1579 }
1580 
1581 
1590  sgkey_t target,
1591  off_t index_offset)
1592 {
1595  payload.target = target;
1596  payload.index_offset = index_offset;
1598 }
1599 
1600 
1609 bool SGImplSvc::tryELRemap (sgkey_t sgkey_in, size_t index_in,
1610  sgkey_t& sgkey_out, size_t& index_out)
1611 {
1614  m_remap_impl->m_remaps.find (sgkey_in);
1615  if (i == m_remap_impl->m_remaps.end())
1616  return false;
1617  const SG::RemapImpl::remap_t& payload = i->second;
1618  sgkey_out = payload.target;
1619  index_out = index_in + payload.index_offset;
1620  return true;
1621 }
1622 
1623 
1625  const std::string& key)
1626 {
1627  lock_t lock (m_mutex);
1628  DataObject* obj = nullptr;
1629  SG::DataProxy* dp = proxy (clid, key);
1630  //we do not want anyone to mess up with our copy hence we release it immediately.
1631  if (dp && dp->isValid()) {
1632  obj = dp->object();
1633  obj->addRef();
1635  }
1636  return obj;
1637 }
1638 
1639 
1640 CLID SGImplSvc::clid( const std::string& key ) const
1641 {
1642  lock_t lock (m_mutex);
1643  SG::DataStore::ConstStoreIterator s_iter, s_end;
1644  store()->tRange(s_iter, s_end).ignore();
1645 
1646  for ( ; s_iter != s_end; ++s_iter ) {
1647  if ( s_iter->second.find( key ) != s_iter->second.end() ) {
1648  return s_iter->first;
1649  }
1650  }
1651 
1652  return CLID_NULL;
1653 }
1654 
1655 
1656 std::vector<CLID> SGImplSvc::clids( const std::string& key ) const
1657 {
1658  lock_t lock (m_mutex);
1659  std::vector<CLID> clids;
1660  SG::DataStore::ConstStoreIterator s_iter, s_end;
1661  store()->tRange(s_iter, s_end).ignore();
1662 
1663  for ( ; s_iter != s_end; ++s_iter ) {
1664  if ( s_iter->second.find( key ) != s_iter->second.end() ) {
1665  clids.push_back(s_iter->first);
1666  }
1667  }
1668 
1669  return clids;
1670 }
1671 
1672 
1674 void SGImplSvc::addAutoSymLinks (const std::string& key,
1675  CLID clid,
1676  DataProxy* dp,
1677  const std::type_info* tinfo,
1678  bool warn_nobib /*= true*/)
1679 {
1680  // Automatically make all legal base class symlinks
1681  if (!tinfo) {
1683  }
1684  const SG::BaseInfoBase* bib = nullptr;
1685  if (tinfo) {
1686  bib = SG::BaseInfoBase::find (*tinfo);
1687  }
1688  if (!bib) {
1689  // Could succeed where the previous fails if clid for DataVector<T>
1690  // but tinfo is for ConstDataVector<DataVector<T> >.
1691  bib = SG::BaseInfoBase::find (clid);
1692  }
1693  if ( bib ) {
1694  const std::vector<CLID>& bases = bib->get_bases();
1695  for ( std::size_t i = 0, iMax = bases.size(); i < iMax; ++i ) {
1696  if ( bases[i] != clid ) {
1697  if ( addSymLink( bases[i], dp ).isSuccess() ) {
1698  // register with t2p
1699  if (dp->object())
1700  this->t2pRegister( SG::DataProxy_cast( dp, bases[i] ), dp ).ignore();
1701  }
1702  else {
1703  warning() << "record_impl: Doing auto-symlinks for object with CLID "
1704  << clid
1705  << " and SG key " << key
1706  << ": Proxy already set for base CLID " << bases[i]
1707  << "; not making auto-symlink." << endmsg;
1708  }
1709  }
1710  }
1711 
1712  // Handle copy conversions.
1713  {
1714  for (CLID copy_clid : bib->get_copy_conversions()) {
1715  if (m_pStore->addSymLink (copy_clid, dp).isFailure()) {
1716  warning() << "record_impl: Doing auto-symlinks for object with CLID "
1717  << clid
1718  << " and SG key " << key
1719  << ": Proxy already set for copy-conversion CLID "
1720  << copy_clid
1721  << "; not making auto-symlink." << endmsg;
1722  }
1723  }
1724  }
1725  }
1726  else {
1727  if (warn_nobib) {
1728  warning() << "record_impl: Could not find suitable SG::BaseInfoBase for CLID ["
1729  << clid << "] (" << key << ") !\t"
1730  << "No auto-symlink established !"
1731  << endmsg;
1732  }
1733  }
1734 }
1735 
1736 void
1738  lock_t lock (m_mutex);
1739 
1740  // Reset handles added since the last call to commit.
1741  bool hard_reset = (m_numSlots > 1);
1742  std::vector<IResetable*> handles;
1743  m_newBoundHandles[std::this_thread::get_id()].swap (handles);
1744  for (IResetable* h : handles)
1745  h->reset (hard_reset);
1746 }
1747 
1748 
1754 void
1756 {
1757  m_newBoundHandles[std::this_thread::get_id()].push_back (handle);
1758 }
1759 
1760 
1766 void
1768 {
1769  std::vector<IResetable*>& v = m_newBoundHandles[std::this_thread::get_id()];
1771  std::find (v.begin(), v.end(), handle);
1772  if (it != v.end())
1773  v.erase (it);
1774 }
1775 
1776 
1780 {
1781  lock_t lock (m_mutex);
1782  m_arena.makeCurrent();
1784 }
1785 
1786 
1797 StatusCode
1798 SGImplSvc::createObj (IConverter* cvt,
1799  IOpaqueAddress* addr,
1800  DataObject*& refpObject)
1801 {
1802  // This lock was here originally, but is probably not really needed ---
1803  // both DataProxy and the I/O components have their own locks.
1804  // Further, this was observed to cause deadlocks for the detector store,
1805  // and would in general be expected to be a contention issue.
1806  //lock_t lock (m_mutex);
1807  return cvt->createObj (addr, refpObject);
1808 }
1809 
1810 
1811 // This is intended to be called from the debugger.
1812 void SG_dump (SGImplSvc* sg)
1813 {
1814  std::cout << sg->dump() << "\n";
1815 }
1816 void SG_dump (SGImplSvc* sg, const char* fname)
1817 {
1818  std::ofstream f (fname);
1819  f << sg->dump() << "\n";
1820  f.close();
1821 }
1822 
1823 
1830 SG::SourceID SGImplSvc::sourceID (const std::string& key /*= "EventSelector"*/) const
1831 {
1832  lock_t lock (m_mutex);
1834  if (dp) {
1835  const DataHeader* dh = SG::DataProxy_cast<DataHeader> (dp);
1836  if (dh) {
1837  return dh->begin()->getToken()->dbID().toString();
1838  }
1839  }
1840  return "";
1841 }
1842 
1843 
1845 // Retrieve a list of collections from Transient Store with no Key.
1846 // const version
1849  SG::detail::IteratorBase& cibegin,
1850  SG::detail::IteratorBase& ciend) const
1851 {
1852  lock_t lock (m_mutex);
1855 
1856  if (!(proxyRange(clid,first,end)).isSuccess()) {
1857  std::string typnam;
1858  m_pCLIDSvc->getTypeNameOfID(clid, typnam).ignore();
1859  SG_MSG_DEBUG("retrieve(range): no object found "
1860  << " of type " << typnam
1861  << "(CLID " << clid << ')');
1862  }
1863 
1864  (ciend.setState(end, end, true)).ignore();
1865 
1866  if (!(cibegin.setState(first, end, true)).isSuccess()) {
1867  std::string typnam;
1868  m_pCLIDSvc->getTypeNameOfID(clid, typnam).ignore();
1869  SG_MSG_DEBUG("retrieve(range): Can't initialize iterator for object range "
1870  << " of type " << typnam
1871  << "(CLID " << clid << ')');
1872  return StatusCode::FAILURE;
1873  }
1874 
1875  return StatusCode::SUCCESS;
1876 }
1877 
1878 
1880  const std::string& key,
1881  CLID auxclid) const
1882 {
1883  // If we already have the aux store (as should usually be the case), return
1884  // without taking out the SG lock. Otherwise, we can deadlock
1885  // if another thread is also trying to dereference a link to the aux store.
1886  // (Should _not_ be holding the SG lock when dereferencing the link!)
1887  if (ptr->hasStore()) return true;
1888 
1889  lock_t lock (m_mutex);
1890  SG_MSG_VERBOSE("called associateAux_impl for key " + key);
1891  // no Aux store set yet
1892  if (!ptr->hasStore()) {
1893  SG::DataProxy* dp = proxy (auxclid, key + "Aux.", true);
1894  if (dp) {
1895  if (!dp->isConst()) {
1896  SG::IAuxStore* pAux = SG::DataProxy_cast<SG::IAuxStore> (dp);
1897  if (pAux) {
1898  ptr->setStore (pAux);
1899  return true;
1900  }
1901  }
1902 
1903  const SG::IConstAuxStore* pAux = SG::DataProxy_cast<SG::IConstAuxStore> (dp);
1904  if (pAux) {
1905  ptr->setStore (pAux);
1906  return true;
1907  }
1908  }
1909  }
1910  return false;
1911 }
1912 
1913 
1915  const std::string& key,
1916  CLID auxclid) const
1917 {
1918  lock_t lock (m_mutex);
1919  SG_MSG_VERBOSE("called associateAux_impl for key " + key);
1920  // no Aux store set yet
1921  if (!ptr->hasStore()) {
1922  SG::DataProxy* dp = proxy (auxclid, key + "Aux.", true);
1923  if (dp) {
1924  if (!dp->isConst()) {
1925  SG::IAuxStore* pAux = SG::DataProxy_cast<SG::IAuxStore> (dp);
1926  if (pAux) {
1927  ptr->setStore (pAux);
1928  return true;
1929  }
1930  }
1931 
1932  const SG::IConstAuxStore* pAux = SG::DataProxy_cast<SG::IConstAuxStore> (dp);
1933  if (pAux) {
1934  ptr->setStore (pAux);
1935  return true;
1936  }
1937  }
1938  }
1939  return false;
1940 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
SG::DataProxy_cast
DATA * DataProxy_cast(DataProxy *proxy)
cast the proxy into the concrete data object it proxies
Definition: DataProxy_cast.h:53
SGImplSvc::mergeStringPool
bool mergeStringPool(const SGImplSvc &other)
Merge the string pool from another store into this one.
Definition: SGImplSvc.cxx:1527
SG::VersionedKey::isVersionedKey
static bool isVersionedKey(const char *)
quickly determine whether a string has the right format to be a VK
Definition: SGVersionedKey.cxx:18
SGImplSvc::associateAux_impl
bool associateAux_impl(SG::AuxVectorBase *ptr, const std::string &key, CLID auxclid) const
Definition: SGImplSvc.cxx:1879
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
SG::DataStore::typeCount
int typeCount(const CLID &id) const
Count number of object of a given type in store.
Definition: Control/SGTools/src/DataStore.cxx:407
SGTest::store
TestStore store
Definition: TestStore.cxx:23
common.sgkey
def sgkey(tool)
Definition: common.py:1027
CurrentEventStore.h
Hold a pointer to the current event store.
CallBackID
Definition: CallBackID.h:24
SGImplSvc::setAlias
StatusCode setAlias(CLID clid, const std::string &key, const std::string &aliasKey)
make an alias to a DataObject (provide data type and old key)
Definition: SGImplSvc.cxx:647
TileDCSDataPlotter.dp
dp
Definition: TileDCSDataPlotter.py:842
SGImplSvc::contains
bool contains(const CLID id, const std::string &key) const
Look up a keyed object in TDS by CLID.
Definition: SGImplSvc.cxx:700
SGImplSvc::createObj
virtual StatusCode createObj(IConverter *cvt, IOpaqueAddress *addr, DataObject *&refpObject) override
Call converter to create an object, with locking.
Definition: SGImplSvc.cxx:1798
SGImplSvc::addSymLink
StatusCode addSymLink(const CLID &linkid, SG::DataProxy *dp)
Definition: SGImplSvc.cxx:600
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:50
SGImplSvc::setConst
StatusCode setConst(const void *pointer)
prevent downstream clients from modifying the pointed-at dobj
Definition: SGImplSvc.cxx:1300
SGImplSvc::SGImplSvc
SGImplSvc(const SGImplSvc &)=delete
SG::DataStore::t2pRegister
StatusCode t2pRegister(const void *const pTrans, DataProxy *const pPers)
methods to query the T2PMap:
Definition: Control/SGTools/src/DataStore.cxx:615
SGImplSvc::locatePersistent
SG::DataProxy * locatePersistent(const SG::TransientAddress *tAddr, bool checkValid=false) const
Definition: SGImplSvc.cxx:1225
header
Definition: hcg.cxx:526
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:407
SG::RemapImpl::remap_t::target
sgkey_t target
Definition: SGImplSvc.cxx:89
SGImplSvc::clearStore
virtual StatusCode clearStore(bool forceRemove=false) override final
clear DataStore contents: called by the event loop mgrs
Definition: SGImplSvc.cxx:268
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SGImplSvc::commitNewDataObjects
virtual void commitNewDataObjects() override final
Reset handles added since the last call to commit.
Definition: SGImplSvc.cxx:1737
vtune_athena.format
format
Definition: vtune_athena.py:14
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
python.CaloAddPedShiftConfig.args
args
Definition: CaloAddPedShiftConfig.py:47
DataBucketBase
A non-templated base class for DataBucket, allows to access the transient object address as a void*.
Definition: DataBucketBase.h:24
SGImplSvc::recordObject
virtual SG::DataProxy * recordObject(SG::DataObjectSharedPtr< DataObject > obj, const std::string &key, bool allowMods, bool returnExisting) override final
Record an object in the store.
Definition: SGImplSvc.cxx:821
SG::DataStore::proxy
virtual DataProxy * proxy(const TransientAddress *tAddr) const override
return proxy for a given type/key pair if key is empty returns the default proxy (currently last regi...
Definition: Control/SGTools/src/DataStore.cxx:416
SG::StringPool
Definition: StringPool.h:35
IProxyProviderSvc::loadProxies
virtual StatusCode loadProxies(IProxyRegistry &dataStore)=0
add new proxies to store every Event:
DataBucketBase.h
SG::VersionedKey::version
unsigned char version() const
Definition: SGVersionedKey.cxx:67
SG::AuxElement
Base class for elements of a container that can have aux data.
Definition: AuxElement.h:483
DataBucketBase::object
virtual void * object()=0
initialize
void initialize()
Definition: run_EoverP.cxx:894
SG_dump
void SG_dump(SGImplSvc *sg)
These are intended to be easy to call from the debugger.
Definition: SGImplSvc.cxx:1812
DataStore.h
SGImplSvc::boundHandle
virtual void boundHandle(IResetable *handle) override final
Tell the store that a proxy has been bound to a handle.
Definition: SGImplSvc.cxx:1755
SG::DataStore::addAlias
virtual StatusCode addAlias(const std::string &aliasKey, DataProxy *proxy) override
add alias to store
Definition: Control/SGTools/src/DataStore.cxx:379
extractSporadic.c1
c1
Definition: extractSporadic.py:133
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
SGVersionedKey.h
SGImplSvc::removeProxy
StatusCode removeProxy(SG::DataProxy *proxy, const void *pTrans, bool forceRemove=false)
remove proxy from store, unless it is reset only.
Definition: SGImplSvc.cxx:1238
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
SG::RemapImpl::sgkey_t
IStringPool::sgkey_t sgkey_t
Definition: SGImplSvc.cxx:86
skel.it
it
Definition: skel.GENtoEVGEN.py:407
SGImplSvc::stringToKey
virtual sgkey_t stringToKey(const std::string &str, CLID clid) override final
Find the key for a string/CLID pair.
Definition: SGImplSvc.cxx:1455
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:70
SG::TransientAddress
Definition: TransientAddress.h:32
SG::DataProxy::accessData
DataObject * accessData()
Access DataObject on-demand using conversion service.
SGImplSvc::m_newBoundHandles
std::map< std::thread::id, std::vector< IResetable * > > m_newBoundHandles
Keep track of proxies bound since the last call to commitNewDataObjects or clearStore.
Definition: SGImplSvc.h:718
SG::CurrentEventStore::setStore
static IProxyDict * setStore(IProxyDict *store)
Set the current store.
Definition: CurrentEventStore.cxx:36
SGImplSvc::proxyRange
StatusCode proxyRange(const CLID &id, SG::ConstProxyIterator &beg, SG::ConstProxyIterator &end) const
return a range to all proxies of a given CLID
Definition: SGImplSvc.cxx:1293
CLIDRegistry::CLIDToTypeinfo
static const std::type_info * CLIDToTypeinfo(CLID clid)
Translate between CLID and type_info.
Definition: CLIDRegistry.cxx:136
SGImplSvc::m_stringPoolMutex
mutex_t m_stringPoolMutex
Definition: SGImplSvc.h:724
SGImplSvc::m_pIncSvc
ServiceHandle< IIncidentSvc > m_pIncSvc
property
Definition: SGImplSvc.h:688
fmt
const char *const fmt
Definition: TripleGaussCollFit.cxx:84
get_generator_info.stderr
stderr
Definition: get_generator_info.py:40
SGImplSvc::emptyTrash
void emptyTrash()
throw away bad objects
Definition: SGImplSvc.cxx:1344
SG::DataStore::ConstStoreIterator
StoreMap::const_iterator ConstStoreIterator
Definition: Control/SGTools/SGTools/DataStore.h:81
SG::DataStore::clearStore
void clearStore(bool force, bool hard, MsgStream *pmlog)
If HARD is true, then the bound objects should also clear any data that depends on the identity of th...
Definition: Control/SGTools/src/DataStore.cxx:68
SGImplSvc::releaseObject
void releaseObject(const CLID &id, const std::string &key)
release object held by proxy, if any.
Definition: SGImplSvc.cxx:1544
SG::DataProxy::isValid
bool isValid() const
called by destructor
python.RatesEmulationExample.lock
lock
Definition: RatesEmulationExample.py:148
PyPoolBrowser.dh
dh
Definition: PyPoolBrowser.py:102
SGImplSvc::proxies
virtual std::vector< const SG::DataProxy * > proxies() const override final
return the list of all current proxies in store
Definition: SGImplSvc.cxx:933
dbg::ptr
void * ptr(T *p)
Definition: SGImplSvc.cxx:74
SGImplSvc::reinitialize
virtual StatusCode reinitialize() override final
Service reinitialization.
Definition: SGImplSvc.cxx:324
Args
Definition: test_lwtnn_fastgraph.cxx:12
IStringPool::sgkey_t
SG::sgkey_t sgkey_t
Type of the keys.
Definition: IStringPool.h:34
SG::RemapImpl
Definition: SGImplSvc.cxx:85
SG::BaseInfoBase::get_bases
const std::vector< CLID > & get_bases() const
Return the class IDs of all known bases of T (that have class IDs).
Definition: BaseInfo.cxx:304
SGImplSvc::sourceID
virtual SG::SourceID sourceID(const std::string &key="EventSelector") const override
Return the metadata source ID for the current event slot.
Definition: SGImplSvc.cxx:1830
SG::VersionedKey::isAuto
static bool isAuto(const std::string &)
quickly determine whether a string has the right format to be a VK with auto-generated version #
Definition: SGVersionedKey.cxx:28
SG::DataStore::setStoreID
void setStoreID(StoreID::type id)
Definition: Control/SGTools/SGTools/DataStore.h:92
AuxVectorBase.h
Manage index tracking and synchronization of auxiliary data.
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
SG::detail::IteratorBase::setState
StatusCode setState(SG::ConstProxyIterator itr, SG::ConstProxyIterator itrEnd, bool isConst)
Reset state of the iterator.
Definition: SGIterator.cxx:94
SG::AuxVectorBase
Manage index tracking and synchronization of auxiliary data.
Definition: AuxVectorBase.h:98
SGImplSvc::m_ActivateHistory
bool m_ActivateHistory
Activate the history service.
Definition: SGImplSvc.h:690
SG::Arena::makeCurrent
ArenaBase * makeCurrent()
Make this Arena the current one for its ArenaHeader.
Definition: Arena.cxx:59
SG::DataProxy::CLIDCont_t
TransientAddress::TransientClidSet CLIDCont_t
Definition: DataProxy.h:54
SGImplSvc::m_storeLoaded
bool m_storeLoaded
FIXME hack needed by loadEventProxies.
Definition: SGImplSvc.h:699
SG::ArenaBase::report
void report(std::ostream &os) const
Generate a report of the memory in use by this Arena.
Definition: ArenaBase.cxx:76
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
SGImplSvc::m_slotNumber
int m_slotNumber
The Hive slot number for this store, or -1 if this isn't a Hive store.
Definition: SGImplSvc.h:709
SGImplSvc::keyToString
virtual const std::string * keyToString(sgkey_t key) const override final
Find the string corresponding to a given key.
Definition: SGImplSvc.cxx:1469
SG::StringPool::clear
void clear()
Empty the pool.
Definition: StringPool.cxx:352
SGImplSvc::initialize
virtual StatusCode initialize() override final
Service initialization.
Definition: SGImplSvc.cxx:147
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:92
SGImplSvc::typeless_overwrite
StatusCode typeless_overwrite(const CLID &id, DataObject *obj, const std::string &key, const void *const raw_ptr, bool allowMods, bool noHist=false, const std::type_info *tinfo=0)
same as typeless_record, allows to overwrite an object in memory or on disk
Definition: SGImplSvc.cxx:1062
SG::RemapImpl::m_remaps
remap_map_t m_remaps
Definition: SGImplSvc.cxx:93
SGImplSvc::bindHandleToProxyAndRegister
bool bindHandleToProxyAndRegister(const CLID &id, const std::string &key, IResetable *ir, SG::DataProxy *&dp)
Also do registration with IOVSvc.
Definition: SGImplSvc.cxx:1387
SGImplSvc::storeID
StoreID::type storeID() const
get store ID. request forwarded to DataStore:
Definition: SGImplSvc.cxx:475
SGImplSvc::unboundHandle
virtual void unboundHandle(IResetable *handle) override final
Tell the store that a handle has been unbound from a proxy.
Definition: SGImplSvc.cxx:1767
SG::asStorable
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)
Definition: DataObjectSharedPtr.h:65
DiTauMassTools::ignore
void ignore(T &&)
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:58
SGImplSvc::m_pStore
SG::DataStore * m_pStore
Definition: SGImplSvc.h:685
IResetable
a resetable object (e.g. a SG DataHandle)
Definition: IResetable.h:15
ArenaHeader.h
Proxy for a group of Arenas. See Arena.h for an overview of the arena-based memory allocators.
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
python.UpdateManyBadChannelIOVs.toRemove
tuple toRemove
Definition: UpdateManyBadChannelIOVs.py:86
SGImplSvc::m_pDataLoader
ServiceHandle< IConversionSvc > m_pDataLoader
Definition: SGImplSvc.h:676
SGImplSvc::m_DumpStore
bool m_DumpStore
Dump Property flag: triggers dump() at EndEvent.
Definition: SGImplSvc.h:689
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
SGImplSvc::clids
std::vector< CLID > clids() const
Return all CLIDs in the store.
Definition: SGImplSvc.cxx:943
DataHeader
This class provides the layout for summary information stored for data written to POOL.
Definition: DataHeader.h:126
lumiFormat.i
int i
Definition: lumiFormat.py:85
SG::ArenaHeader
Proxy for a group of Arenas.
Definition: ArenaHeader.h:54
SGImplSvc::bindHandleToProxy
bool bindHandleToProxy(const CLID &id, const std::string &key, IResetable *ir, SG::DataProxy *&dp)
name says it all
Definition: SGImplSvc.cxx:1355
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
SGImplSvc::sgkey_t
IStringPool::sgkey_t sgkey_t
Definition: SGImplSvc.h:351
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::ArenaBase::reset
void reset()
Reset all contained allocators.
Definition: ArenaBase.cxx:44
SGImplSvc::m_arena
SG::Arena m_arena
Allocation arena to associate with this store.
Definition: SGImplSvc.h:706
SGImplSvc.h
SG::VersionedKey
a StoreGateSvc key with a version number. Notice that StoreGate does not order multiple instances of ...
Definition: SGVersionedKey.h:31
SGImplSvc::m_stringpool
SG::StringPool m_stringpool
Definition: SGImplSvc.h:701
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:37
StringPool.h
Maintain a mapping of strings to 64-bit ints.
SGImplSvc::accessData
DataObject * accessData(const CLID &id) const
find proxy and access its data. Returns 0 to flag failure
Definition: SGImplSvc.cxx:972
SG::DataStore::addSymLink
StatusCode addSymLink(const CLID &linkid, DataProxy *proxy)
add symlink to store:
Definition: Control/SGTools/src/DataStore.cxx:332
SGImplSvc::clearProxyPayload
void clearProxyPayload(SG::DataProxy *)
use to reset a proxy (clearing the data object it contains) Unlike DataProxy::reset this method corre...
Definition: SGImplSvc.cxx:1561
SGImplSvc::setupProxy
SG::DataProxy * setupProxy(const CLID &dataID, const std::string &gK, DataObject *pDObj, bool allowMods, bool resetOnly)
try to locate a proxy or create it if needed
Definition: SGImplSvc.cxx:427
IOVSvcCallBackFcn
boost::function< StatusCode(IOVSVC_CALLBACK_ARGS) > IOVSvcCallBackFcn
the type of an IOVSvc call back: it wraps both the method and the object the method is called on
Definition: IOVSvcDefs.h:58
SG::BaseInfoBase::get_copy_conversions
std::vector< CLID > get_copy_conversions() const
Return known copy conversions.
Definition: BaseInfo.cxx:455
SGImplSvc
The Athena Transient Store API.
Definition: SGImplSvc.h:109
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
hist_file_dump.f
f
Definition: hist_file_dump.py:140
SGImplSvc::transientContains
bool transientContains(const CLID id, const std::string &key) const
Look up a transient data object in TDS only by CLID.
Definition: SGImplSvc.cxx:709
SGImplSvc::m_pHistorySvc
ServiceHandle< IHistorySvc > m_pHistorySvc
Definition: SGImplSvc.h:683
SG::StringPool::keyToString
const std::string * keyToString(sgkey_t key) const
Find the string corresponding to a given key.
Definition: StringPool.cxx:288
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
SGImplSvc::remove
StatusCode remove(const void *pObject)
Remove pObject, will remove its proxy if not reset only.
Definition: SGImplSvc.cxx:1320
SGImplSvc::remap_impl
void remap_impl(sgkey_t source, sgkey_t target, off_t index_offset)
Declare a remapping.
Definition: SGImplSvc.cxx:1589
SG::ArenaBase::erase
void erase()
Erase all contained allocators.
Definition: ArenaBase.cxx:60
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
SGImplSvc::record_impl
SG::DataProxy * record_impl(DataObject *obj, const std::string &key, const void *const raw_ptr, bool allowMods, bool resetOnly, bool allowOverwrite, const std::type_info *tinfo)
real recording of an object with a key, allow possibility of specifying const-access
Definition: SGImplSvc.cxx:1097
SGImplSvc::tryELRemap
virtual bool tryELRemap(sgkey_t sgkey_in, size_t index_in, sgkey_t &sgkey_out, size_t &index_out) override final
Test to see if the target of an ElementLink has moved.
Definition: SGImplSvc.cxx:1609
DataHeader.h
This file contains the class definition for the DataHeader and DataHeaderElement classes.
WriteCalibToCool.swap
swap
Definition: WriteCalibToCool.py:94
IProxyProviderSvc::preLoadProxies
virtual StatusCode preLoadProxies(IProxyRegistry &dataStore)=0
add proxies to the store before Begin Event:
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
SG::DataProxy::clID
CLID clID() const
Retrieve clid.
SGImplSvc::~SGImplSvc
virtual ~SGImplSvc() override final
Standard Destructor.
Definition: SGImplSvc.cxx:137
StoreID::DETECTOR_STORE
@ DETECTOR_STORE
Definition: StoreID.h:27
SGImplSvc::msg_update_handler
void msg_update_handler(Gaudi::Details::PropertyBase &outputLevel)
callback for output level property
Definition: SGImplSvc.cxx:1285
StoreID.h
SGImplSvc::finalize
virtual StatusCode finalize() override final
Service finalization.
Definition: SGImplSvc.cxx:303
SG::DataStore::storeID
virtual StoreID::type storeID() const override
Definition: Control/SGTools/SGTools/DataStore.h:93
IProxyProviderSvc::retrieveProxy
virtual SG::DataProxy * retrieveProxy(const CLID &id, const std::string &key, IProxyRegistry &dataStore)=0
Use a provider to create a proxy for ID/KEY.
SGImplSvc::recordAddress
StatusCode recordAddress(const std::string &skey, IOpaqueAddress *pAddress, bool clearAddressFlag=true)
Create a proxy object using an IOpaqueAddress and a transient key.
Definition: SGImplSvc.cxx:336
SGImplSvc::retrieve
StatusCode retrieve(CLID clid, SG::detail::IteratorBase &cibegin, SG::detail::IteratorBase &ciend) const
Retrieve all objects of type T: returns an SG::ConstIterator range.
Definition: SGImplSvc.cxx:1848
SGImplSvc::dump
std::string dump() const
dump objects in store.
Definition: SGImplSvc.cxx:522
SGImplSvc::registerKey
virtual void registerKey(sgkey_t key, const std::string &str, CLID clidid) override final
Remember an additional mapping from key to string/CLID.
Definition: SGImplSvc.cxx:1504
SGImplSvc::setStoreID
void setStoreID(StoreID::type id)
set store ID. request forwarded to DataStore:
Definition: SGImplSvc.cxx:469
dbg
Definition: SGImplSvc.cxx:69
SGImplSvc::typeCount
int typeCount(const CLID &id) const
Return the number of instances of type T (input CLID)
Definition: SGImplSvc.cxx:692
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
SGImplSvc::record_HistObj
StatusCode record_HistObj(const CLID &id, const std::string &key, const std::string &store, bool allowMods, bool resetOnly=true)
Definition: SGImplSvc.cxx:1421
debug
const bool debug
Definition: MakeUncertaintyPlots.cxx:53
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:76
SG::BaseInfoBase::find
static const BaseInfoBase * find(CLID clid)
Find the BaseInfoBase instance for clid.
Definition: BaseInfo.cxx:570
SGImplSvc::removeDataAndProxy
StatusCode removeDataAndProxy(const void *pObject)
Remove pObject and its proxy no matter what.
Definition: SGImplSvc.cxx:1329
SGImplSvc::recycle
void recycle(DataObject *pBadDObj)
put a bad (unrecordable) dobj away
Definition: SGImplSvc.cxx:1337
SGImplSvc::m_DumpArena
bool m_DumpArena
DumpArena Property flag : trigger m_arena->report() at clearStore.
Definition: SGImplSvc.h:691
errorcheck.h
Helpers for checking error return status codes and reporting errors.
SG::DataStore::keys
void keys(const CLID &id, std::vector< std::string > &vkeys, bool includeAlias, bool onlyValid)
Definition: Control/SGTools/src/DataStore.cxx:121
SGImplSvc::clid
CLID clid(const std::string &key) const
Retrieve the main CLID of the object recorded in StoreGate with the given "key" WARNING: slow!
Definition: SGImplSvc.cxx:1640
SGImplSvc::typeless_record
StatusCode typeless_record(DataObject *obj, const std::string &key, const void *const raw_ptr, bool allowMods, bool resetOnly=true, bool noHist=false)
type-less recording of an object with a key, allow possibility of specifying const-access and history...
Definition: SGImplSvc.cxx:1014
SG::VersionedKey::rawVersionKey
const std::string & rawVersionKey() const
Definition: SGVersionedKey.h:76
SG::RemapImpl::remap_t::index_offset
off_t index_offset
Definition: SGImplSvc.cxx:90
SG::sgkey_t
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition: CxxUtils/CxxUtils/sgkey_t.h:32
StoreClearedIncident.h
Incident sent after a store is cleared.
SG::DataProxy::name
virtual const name_type & name() const override final
Retrieve data object key == string.
SG::DataStore::locatePersistent
DataProxy * locatePersistent(const void *const pTransient) const
locate the persistent (proxy) for a given T* (void*):
Definition: Control/SGTools/src/DataStore.cxx:608
SGImplSvc::m_numSlots
int m_numSlots
The total number of slots. 1 if this isn't a Hive store.
Definition: SGImplSvc.h:712
SGImplSvc::symLink
StatusCode symLink(const void *p2BRegistered, CLID linkID)
make a soft link to the object T* already registered
Definition: SGImplSvc.cxx:577
PixelModuleFeMask_create_db.payload
string payload
Definition: PixelModuleFeMask_create_db.py:69
SGImplSvc::addToStore
virtual StatusCode addToStore(CLID id, SG::DataProxy *proxy) override final
Raw addition of a proxy to the store.
Definition: SGImplSvc.cxx:794
SGImplSvc::m_pCLIDSvc
ServiceHandle< IClassIDSvc > m_pCLIDSvc
Definition: SGImplSvc.h:675
SGImplSvc::addAlias
StatusCode addAlias(const std::string &aliasKey, SG::DataProxy *dp)
Definition: SGImplSvc.cxx:680
REPORT_MESSAGE
#define REPORT_MESSAGE(LVL)
Report a message.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:365
IIOVSvc.h
SGImplSvc::handle
virtual void handle(const Incident &) override final
triggered by Incident service
Definition: SGImplSvc.cxx:232
python.TrigPSCPythonDbSetup.outputLevel
outputLevel
Definition: TrigPSCPythonDbSetup.py:30
SG::IAuxStore
Interface for non-const operations on an auxiliary store.
Definition: IAuxStore.h:48
SG::VersionedKey::key
const std::string & key() const
Definition: SGVersionedKey.cxx:71
CLIDRegistry.h
a static registry of CLID->typeName entries. NOT for general use. Use ClassIDSvc instead.
python.AthDsoLogger.fname
string fname
Definition: AthDsoLogger.py:66
ir
int ir
counter of the current depth
Definition: fastadd.cxx:49
python.PyAthena.v
v
Definition: PyAthena.py:154
SG::DataProxy::isValidObject
bool isValidObject() const
is the object valid?
SG::ArenaHeader::defaultHeader
static ArenaHeader * defaultHeader()
Return the global default Header instance.
Definition: ArenaHeader.cxx:164
python.DataFormatRates.c2
c2
Definition: DataFormatRates.py:123
SG::DataStore::addToStore
virtual StatusCode addToStore(const CLID &id, DataProxy *proxy) override
add proxy to store.
Definition: Control/SGTools/src/DataStore.cxx:142
SG::DataProxy::hasAlias
bool hasAlias(const std::string &key) const
Test to see if a given string is in the alias set.
SGImplSvc::transientProxy
SG::DataProxy * transientProxy(const CLID &id, const std::string &key) const
get proxy with given id and key.
Definition: SGImplSvc.cxx:964
SG::DataStore::proxy_exact
virtual SG::DataProxy * proxy_exact(sgkey_t sgkey) const override
get proxy with given key.
Definition: Control/SGTools/src/DataStore.cxx:526
a
TList * a
Definition: liststreamerinfos.cxx:10
SG::DataProxy::reset
void reset(bool hard=false)
Other methods of DataProxy (not in Interface IRegistry):
Definition: DataProxy.cxx:241
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
SGImplSvc::m_pIOVSvc
ServiceHandle< IIOVSvc > m_pIOVSvc
get the IOVSvc "just in time" (breaks recursion at initialize)
Definition: SGImplSvc.h:697
h
SGImplSvc::makeCurrent
void makeCurrent()
The current store is becoming the active store.
Definition: SGImplSvc.cxx:1779
SG::DataProxy::transientID
bool transientID(CLID id) const
return the list of transient IDs (primary or symLinked):
SGImplSvc::m_trash
std::list< DataObject * > m_trash
The Recycle Bin.
Definition: SGImplSvc.h:686
StoreID::type
type
Definition: StoreID.h:24
SG::DataStore
Hold DataProxy instances associated with a store.
Definition: Control/SGTools/SGTools/DataStore.h:74
SG::DataStore::proxies
const std::vector< DataProxy * > & proxies() const
All proxies managed by this store.
Definition: Control/SGTools/src/DataStore.cxx:629
copySelective.target
string target
Definition: copySelective.py:36
TransientAddress.h
StoreID::findStoreID
static StoreID::type findStoreID(const std::string &storeName)
Definition: StoreID.cxx:21
SG::SourceID
std::string SourceID
Definition: AthenaKernel/AthenaKernel/SourceID.h:25
python.TriggerHandler.verbose
verbose
Definition: TriggerHandler.py:296
DeMoScan.first
bool first
Definition: DeMoScan.py:534
DEBUG
#define DEBUG
Definition: page_access.h:11
SG::SGKeyMap
std::unordered_map< sgkey_t, T > SGKeyMap
A map using sgkey_t as a key.
Definition: CxxUtils/CxxUtils/sgkey_t.h:93
SG::BaseInfoBase
The non-template portion of the BaseInfo implementation.
Definition: Control/AthenaKernel/AthenaKernel/BaseInfo.h:451
SG::DataStore::t2pRemove
void t2pRemove(const void *const pTrans)
Definition: Control/SGTools/SGTools/DataStore.h:256
SG::detail::IteratorBase
Definition: SGIterator.h:37
SGImplSvc::store
SG::DataStore * store()
Definition: SGImplSvc.cxx:562
SGImplSvc::stop
virtual StatusCode stop() override final
Service stop.
Definition: SGImplSvc.cxx:214
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
IAuxStore.h
Interface for non-const operations on an auxiliary store.
SGImplSvc::m_pPPS
IProxyProviderSvc * m_pPPS
Definition: SGImplSvc.h:681
DataBucketBase::relinquish
virtual void relinquish()=0
Give up ownership of the DataBucket contents.
python.SystemOfUnits.s
float s
Definition: SystemOfUnits.py:147
SG::DataStore::pRange
StatusCode pRange(const CLID &id, SG::ConstProxyIterator &f, SG::ConstProxyIterator &e) const
Return an iterator over proxy for a given CLID:
Definition: Control/SGTools/src/DataStore.cxx:576
SGImplSvc::lock_t
std::lock_guard< mutex_t > lock_t
Definition: SGImplSvc.h:721
IProxyProviderSvc.h
SG::DataStore::removeProxy
StatusCode removeProxy(DataProxy *proxy, bool forceRemove, bool hard)
remove proxy from store, unless proxy is reset only.
Definition: Control/SGTools/src/DataStore.cxx:199
SG::StringPool::merge
bool merge(const StringPool &other)
Merge another pool into this one.
Definition: StringPool.cxx:365
copySelective.source
string source
Definition: copySelective.py:31
str
Definition: BTagTrackIpAccessor.cxx:11
SGImplSvc::setSlotNumber
void setSlotNumber(int slot, int numSlots)
Set the Hive slot number for this store.
Definition: SGImplSvc.cxx:922
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
StoreID::EVENT_STORE
@ EVENT_STORE
Definition: StoreID.h:26
SG::DataObjectSharedPtr
Smart pointer to manage DataObject reference counts.
Definition: DataObjectSharedPtr.h:45
SGImplSvc::createKey
std::string createKey(const CLID &dataID)
creates a key internally if none specified by client
Definition: SGImplSvc.cxx:262
SGImplSvc::proxy_exact
virtual SG::DataProxy * proxy_exact(SG::sgkey_t sgkey) const override final
Get proxy given a hashed key+clid.
Definition: SGImplSvc.cxx:910
SG::StringPool::stringToKey
sgkey_t stringToKey(const std::string &str, sgaux_t aux=0)
Find the key for a string.
Definition: StringPool.cxx:250
IConstAuxStore.h
Interface for const operations on an auxiliary store.
SG::RemapImpl::remap_t
Definition: SGImplSvc.cxx:88
get_generator_info.error
error
Definition: get_generator_info.py:40
SG::IConstAuxStore
Interface for const operations on an auxiliary store.
Definition: IConstAuxStore.h:64
SGImplSvc::m_mutex
mutex_t m_mutex
Definition: SGImplSvc.h:722
checker_macros.h
Define macros for attributes used to control the static checker.
SGImplSvc::t2pRemove
void t2pRemove(const void *const pTrans)
forwarded to DataStore
Definition: SGImplSvc.cxx:1279
python.PyAthena.obj
obj
Definition: PyAthena.py:132
SGImplSvc::m_pPPSHandle
ServiceHandle< IProxyProviderSvc > m_pPPSHandle
Definition: SGImplSvc.h:678
SG::DataProxy
Definition: DataProxy.h:45
SGImplSvc::regFcn
StatusCode regFcn(const CallBackID &c1, const CallBackID &c2, const IOVSvcCallBackFcn &fcn, bool trigger=false)
register a callback function(2) with an already registered function(1)
Definition: SGImplSvc.cxx:499
SGImplSvc::start
virtual StatusCode start() override final
Service start.
Definition: SGImplSvc.cxx:199
SGImplSvc::proxy
virtual SG::DataProxy * proxy(const void *const pTransient) const override final
get proxy for a given data object address in memory
Definition: SGImplSvc.cxx:718
SGImplSvc::isSymLinked
bool isSymLinked(const CLID &linkID, SG::DataProxy *dp)
Definition: SGImplSvc.cxx:492
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
SG::DataStore::tRange
StatusCode tRange(ConstStoreIterator &f, ConstStoreIterator &e) const
Return an iterator over the StoreMap:
Definition: Control/SGTools/src/DataStore.cxx:598
SGImplSvc::t2pRegister
StatusCode t2pRegister(const void *const pTrans, SG::DataProxy *const pPers)
forwarded to DataStore
Definition: SGImplSvc.cxx:1272
SG::DataStore::proxy_exact_unlocked
SG::DataProxy * proxy_exact_unlocked(sgkey_t sgkey, std::recursive_mutex &mutex) const
Like proxy_exact, but intended to be called without holding the store lock.
Definition: Control/SGTools/src/DataStore.cxx:545
SG::RemapImpl::remap_map_t
SGKeyMap< remap_t > remap_map_t
Definition: SGImplSvc.cxx:92
StoreGateSvc.h
python.compressB64.c
def c
Definition: compressB64.py:93
python.ParticleTypeUtil.info
def info
Definition: ParticleTypeUtil.py:87
SG::ArenaBase::name
const std::string & name() const
Return this Arena's name.
Definition: ArenaBase.cxx:114
SGImplSvc::typeless_retrievePrivateCopy
DataObject * typeless_retrievePrivateCopy(const CLID clid, const std::string &key)
Definition: SGImplSvc.cxx:1624
SG::ConstProxyIterator
ProxyMap::const_iterator ConstProxyIterator
Definition: ProxyMap.h:28
SG::StringPool::registerKey
bool registerKey(sgkey_t key, const std::string &str, sgaux_t aux=0)
Remember an additional mapping from key to string.
Definition: StringPool.cxx:321
SGImplSvc::addAutoSymLinks
void addAutoSymLinks(const std::string &key, CLID clid, SG::DataProxy *dp, const std::type_info *tinfo, bool warn_nobib=true)
Add automatically-made symlinks for DP.
Definition: SGImplSvc.cxx:1674
SGImplSvc::m_remap_impl
SG::RemapImpl * m_remap_impl
Definition: SGImplSvc.h:703
SGImplSvc::transientSwap
bool transientSwap(const CLID &id, const std::string &keyA, const std::string &keyB)
swap the content of 2 keys payload A indexed by keyA will now be accessed via keyB and vice versa Not...
Definition: SGImplSvc.cxx:988
SGImplSvc::keys
void keys(const CLID &id, std::vector< std::string > &vkeys, bool includeAlias=false, bool onlyValid=true)
provide list of all StoreGate keys associated with an object.
Definition: SGImplSvc.cxx:483
SGImplSvc::m_remapMutex
mutex_t m_remapMutex
Definition: SGImplSvc.h:723
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
SGImplSvc::loadEventProxies
StatusCode loadEventProxies()
load proxies at begin event
Definition: SGImplSvc.cxx:243
DataProxy.h