ATLAS Offline Software
CondSvc.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef IOVSVC_CONDSVC_H
6 #define IOVSVC_CONDSVC_H 1
7 
8 #include "GaudiKernel/ICondSvc.h"
9 #include "GaudiKernel/Service.h"
10 #include "StoreGate/StoreGateSvc.h"
12 #include "ICondSvcSetupDone.h"
13 
14 #include <unordered_map>
15 #include <map>
16 #include <set>
17 #include <vector>
18 #include <mutex>
19 
20 class ConditionSlotFuture;
21 class ICondtionIOSvc;
22 
23 class CondSvc: public extends<AthService, ICondSvc, ICondSvcSetupDone> {
24 public:
25 
26  CondSvc(const std::string& name, ISvcLocator* svc);
27  ~CondSvc();
28 
29  virtual StatusCode initialize() override;
30  virtual StatusCode finalize() override;
31  virtual StatusCode start() override;
32  virtual StatusCode stop() override;
33 
34  // from ICondSvc
35 public:
36  virtual StatusCode regHandle(IAlgorithm* alg, const Gaudi::DataHandle& id) override;
37 
38  virtual bool getInvalidIDs(const EventContext&, DataObjIDColl& ids);
39  virtual bool getValidIDs(const EventContext&, DataObjIDColl& ids);
40  virtual bool getIDValidity(const EventContext&, DataObjIDColl& validIDs,
41  DataObjIDColl& invalidIDs);
42  virtual bool isValidID(const EventContext&, const DataObjID&) const override;
43 
44  virtual const std::set<IAlgorithm*>& condAlgs() const override { return m_condAlgs; }
45 
46  virtual bool isRegistered(const DataObjID&) const override;
47  virtual bool isRegistered(IAlgorithm*) const override;
48 
49  virtual const DataObjIDColl& conditionIDs() const override;
50 
51  virtual StatusCode validRanges( std::vector<EventIDRange>& ranges,
52  const DataObjID& id ) const override;
53 
54  // virtual void dump() const;
55  virtual void dump(std::ostream&) const override;
56 
60  virtual StatusCode setupDone() override;
61 
62 
63 public:
64  // unimplemented interfaces
65 
67  virtual ConditionSlotFuture* startConditionSetup(const EventContext&) override {
68  return nullptr;
69  }
70 
73  virtual StatusCode registerConditionIOSvc(IConditionIOSvc*) override {
74  return StatusCode::FAILURE;
75  }
76 
77 
78 
79 private:
80 
81  class iAlgHasher {
82  public:
83  std::size_t operator()(const IAlgorithm * a) const {
84  return ( iAlgHasher()(*a));
85  }
86  std::size_t operator()(const IAlgorithm& a) const {
87  return (a.nameKey().__hash__());
88  }
89 
90  bool operator()(const IAlgorithm* lhs, const IAlgorithm* rhs) const {
91  return ( iAlgHasher()(*lhs,*rhs));
92  }
93  bool operator()(const IAlgorithm& lhs, const IAlgorithm& rhs) const {
94  return ( lhs.nameKey() < rhs.nameKey() );
95  }
96 
97  };
98 
99  StatusCode regHandle_i(IAlgorithm* alg, const Gaudi::DataHandle& id);
100 
102 
103  typedef std::set<IAlgorithm*, iAlgHasher> IAlgHashSet;
104  typedef std::map<DataObjID, IAlgHashSet> id_map_t;
105  typedef std::map<IAlgorithm*, DataObjIDColl, iAlgHasher> alg_map_t;
108 
109  // std::map<std::string, DataObjID> m_keyMap;
110  std::set<IAlgorithm*> m_condAlgs;
111 
112  DataObjIDColl m_condIDs;
113 
114  // Map from keys to CondContBase instances.
115  // Populated by startConditionSetup().
116  typedef std::unordered_map<std::string, const CondContBase*> CondContMap_t;
118 
120  mutable mutex_t m_lock;
121 
122 };
123 
124 #endif
ICondSvcSetupDone.h
Interface to tell CondSvc to cache conditions containers.
trigbs_pickEvents.ranges
ranges
Definition: trigbs_pickEvents.py:60
CondSvc::initialize
virtual StatusCode initialize() override
Definition: CondSvc.cxx:52
CondSvc::m_sgs
ServiceHandle< StoreGateSvc > m_sgs
Definition: CondSvc.h:101
CondSvc::isValidID
virtual bool isValidID(const EventContext &, const DataObjID &) const override
Definition: CondSvc.cxx:352
SGout2dot.alg
alg
Definition: SGout2dot.py:243
CondSvc::startConditionSetup
virtual ConditionSlotFuture * startConditionSetup(const EventContext &) override
Asynchronously setup conditions.
Definition: CondSvc.h:67
CondSvc::finalize
virtual StatusCode finalize() override
Definition: CondSvc.cxx:126
CondSvc::iAlgHasher::operator()
std::size_t operator()(const IAlgorithm *a) const
Definition: CondSvc.h:83
CondSvc::alg_map_t
std::map< IAlgorithm *, DataObjIDColl, iAlgHasher > alg_map_t
Definition: CondSvc.h:105
CondSvc::iAlgHasher::operator()
std::size_t operator()(const IAlgorithm &a) const
Definition: CondSvc.h:86
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
CondSvc::regHandle
virtual StatusCode regHandle(IAlgorithm *alg, const Gaudi::DataHandle &id) override
Definition: CondSvc.cxx:160
CondSvc::m_condConts
CondContMap_t m_condConts
Definition: CondSvc.h:117
CondSvc::mutex_t
std::mutex mutex_t
Definition: CondSvc.h:119
CondSvc::dump
virtual void dump(std::ostream &) const override
Definition: CondSvc.cxx:87
CondSvc::CondContMap_t
std::unordered_map< std::string, const CondContBase * > CondContMap_t
Definition: CondSvc.h:116
CondSvc::isRegistered
virtual bool isRegistered(const DataObjID &) const override
Definition: CondSvc.cxx:386
CondSvc::validRanges
virtual StatusCode validRanges(std::vector< EventIDRange > &ranges, const DataObjID &id) const override
Definition: CondSvc.cxx:26
CondSvc::~CondSvc
~CondSvc()
Definition: CondSvc.cxx:21
CondSvc::condAlgs
virtual const std::set< IAlgorithm * > & condAlgs() const override
Definition: CondSvc.h:44
CondSvc
Definition: CondSvc.h:23
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CondSvc::CondSvc
CondSvc(const std::string &name, ISvcLocator *svc)
Definition: CondSvc.cxx:13
CondSvc::id_map_t
std::map< DataObjID, IAlgHashSet > id_map_t
Definition: CondSvc.h:104
CondSvc::getInvalidIDs
virtual bool getInvalidIDs(const EventContext &, DataObjIDColl &ids)
Definition: CondSvc.cxx:240
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
CondSvc::iAlgHasher::operator()
bool operator()(const IAlgorithm *lhs, const IAlgorithm *rhs) const
Definition: CondSvc.h:90
CondSvc::m_condIDs
DataObjIDColl m_condIDs
Definition: CondSvc.h:112
CondSvc::conditionIDs
virtual const DataObjIDColl & conditionIDs() const override
Definition: CondSvc.cxx:406
CondSvc::stop
virtual StatusCode stop() override
Definition: CondSvc.cxx:142
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
python.subdetectors.mmg.ids
ids
Definition: mmg.py:8
CondSvc::m_algMap
alg_map_t m_algMap
Definition: CondSvc.h:107
CondSvc::m_lock
mutex_t m_lock
Definition: CondSvc.h:120
CondSvc::m_condAlgs
std::set< IAlgorithm * > m_condAlgs
Definition: CondSvc.h:110
CondSvc::regHandle_i
StatusCode regHandle_i(IAlgorithm *alg, const Gaudi::DataHandle &id)
Definition: CondSvc.cxx:171
CondSvc::registerConditionIOSvc
virtual StatusCode registerConditionIOSvc(IConditionIOSvc *) override
register an IConditionIOSvc (alternative to Algorithm processing of Conditions)
Definition: CondSvc.h:73
a
TList * a
Definition: liststreamerinfos.cxx:10
CondSvc::m_idMap
id_map_t m_idMap
Definition: CondSvc.h:106
AthService.h
CondSvc::start
virtual StatusCode start() override
Definition: CondSvc.cxx:133
CondSvc::iAlgHasher::operator()
bool operator()(const IAlgorithm &lhs, const IAlgorithm &rhs) const
Definition: CondSvc.h:93
CondSvc::IAlgHashSet
std::set< IAlgorithm *, iAlgHasher > IAlgHashSet
Definition: CondSvc.h:103
StoreGateSvc.h
CondSvc::getIDValidity
virtual bool getIDValidity(const EventContext &, DataObjIDColl &validIDs, DataObjIDColl &invalidIDs)
Definition: CondSvc.cxx:276
CondSvc::getValidIDs
virtual bool getValidIDs(const EventContext &, DataObjIDColl &ids)
Definition: CondSvc.cxx:316
CondSvc::iAlgHasher
Definition: CondSvc.h:81
ServiceHandle< StoreGateSvc >
CondSvc::setupDone
virtual StatusCode setupDone() override
To be called after changes to the set of conditions containers in the conditions store.
Definition: CondSvc.cxx:415