DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
ConditionsManagerObject.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 #ifndef DDCOND_CONDITIONSMANAGEROBJECT_H
14 #define DDCOND_CONDITIONSMANAGEROBJECT_H
15 
16 // Framework include files
17 #include "DD4hep/Conditions.h"
18 #include "DD4hep/NamedObject.h"
19 #include "DDCond/ConditionsPool.h"
20 #include "DDCond/ConditionsSlice.h"
22 
23 // C/C++ include files
24 #include <memory>
25 #include <vector>
26 #include <set>
27 
29 namespace dd4hep {
30 
31  // Forward declarations
32  class IOVType;
33 
35  namespace cond {
36 
37  // Forward declarations
38  class ConditionsIOVPool;
39  class ConditionsListener;
40 
42 
54  {
55  public:
57  typedef std::pair<ConditionsListener*,void*> Listener;
58  typedef std::set<Listener> Listeners;
59  typedef std::unique_ptr<ConditionsDataLoader> Loader;
61 
62  protected:
72  bool m_doLoad = true;
74  bool m_doOutputUnloaded = false;
75 
77  void registerCallee(Listeners& listeners, const Listener& callee, bool add);
78 
79  public:
80 
82  ConditionsManagerObject(Detector& description);
83 
85  virtual ~ConditionsManagerObject();
86 
88  Detector& detectorDescription() const { return m_detDesc; }
89 
91  ConditionsDataLoader* loader() const { return m_loader.get(); }
92 
94  bool doLoadConditions() const { return m_doLoad; }
95 
97  bool doOutputUnloaded() const { return m_doOutputUnloaded; }
98 
100  void onRegister(Condition condition);
101 
103  void onRemove(Condition condition);
104 
106  void callOnRegister(const Listener& callee, bool add);
107 
109  void callOnRemove(const Listener& callee, bool add);
110 
112  const std::vector<const IOVType*> iovTypesUsed() const;
113 
115  void fromString(const std::string& iov_str, IOV& iov);
116 
118  ConditionsPool* registerIOV(const std::string& data);
119 
121  virtual void initialize() = 0;
123 
125  virtual const std::vector<IOVType>& iovTypes () const = 0;
126 
128  virtual const IOVType* iovType (size_t iov_type) const = 0;
129 
131  virtual const IOVType* iovType (const std::string& iov_name) const = 0;
132 
134 
137  virtual std::pair<bool, const IOVType*> registerIOVType(size_t iov_type, const std::string& iov_name) = 0;
138 
140  virtual ConditionsPool* registerIOV(const IOVType& typ, IOV::Key key) = 0;
141 
143  virtual ConditionsIOVPool* iovPool(const IOVType& type) const = 0;
144 #if 0
145  virtual Condition get(key_type key, const IOV& req_validity) = 0;
147 
149  virtual RangeConditions getRange(key_type key, const IOV& req_validity) = 0;
150 #endif
151 
155  virtual void pushUpdates() = 0;
156 
158  virtual bool registerUnlocked(ConditionsPool& pool, Condition cond) = 0;
159 
161  virtual size_t blockRegister(ConditionsPool& pool, const std::vector<Condition>& cond) const = 0;
162 
164  virtual std::unique_ptr<UserPool> createUserPool(const IOVType* iovT) const = 0;
165 
167  virtual Result prepare(const IOV& req_iov, ConditionsSlice& slice, ConditionUpdateUserContext* ctx=0) = 0;
168 
170  virtual Result load(const IOV& required_validity,
171  ConditionsSlice& slice,
172  ConditionUpdateUserContext* ctxt=0) = 0;
173 
175  virtual Result compute(const IOV& required_validity,
176  ConditionsSlice& slice,
177  ConditionUpdateUserContext* ctxt=0) = 0;
178 
180 
185  virtual void adoptCleanup(ConditionsCleanup* cleaner) = 0;
186 
188 
189  virtual int clean(const IOVType* typ, int max_age) = 0;
190 
192  virtual std::pair<int,int> clean(const ConditionsCleanup& cleaner) = 0;
193 
195 
196  virtual std::pair<int,int> clear() = 0;
197 
198  };
199  } /* End namespace detail */
200 } /* End namespace dd4hep */
201 #endif // DDCOND_CONDITIONSMANAGEROBJECT_H
dd4hep::RangeConditions
std::vector< Condition > RangeConditions
Definition: Conditions.h:491
ConditionsSlice.h
cond
AlignmentCondition::Object * cond
Definition: AlignmentsCalculator.cpp:68
dd4hep::cond::ConditionsManagerObject::iovPool
virtual ConditionsIOVPool * iovPool(const IOVType &type) const =0
Access conditions multi IOV pool by iov type.
dd4hep::cond::ConditionsManagerObject::registerUnlocked
virtual bool registerUnlocked(ConditionsPool &pool, Condition cond)=0
Register new condition with the conditions store. Unlocked version, not multi-threaded.
dd4hep::cond::ConditionsManagerObject::load
virtual Result load(const IOV &required_validity, ConditionsSlice &slice, ConditionUpdateUserContext *ctxt=0)=0
Load all updates to the clients with the defined IOV (1rst step of prepare)
dd4hep::cond::ConditionsManagerObject::~ConditionsManagerObject
virtual ~ConditionsManagerObject()
Default destructor.
Definition: ConditionsManager.cpp:56
dd4hep::cond::ConditionsManagerObject::createUserPool
virtual std::unique_ptr< UserPool > createUserPool(const IOVType *iovT) const =0
Create empty user pool object.
dd4hep::cond::ConditionsManagerObject::m_loader
Loader m_loader
Reference to the data loader userd by this instance.
Definition: ConditionsManagerObject.h:70
dd4hep::PropertyConfigurable
Property object as base class for all objects supporting properties.
Definition: ComponentProperties.h:258
dd4hep::cond::ConditionsManagerObject::iovTypes
virtual const std::vector< IOVType > & iovTypes() const =0
Access IOV by its type.
ConditionsDataLoader.h
dd4hep::cond::ConditionsManagerObject::iovType
virtual const IOVType * iovType(size_t iov_type) const =0
Access IOV by its type.
dd4hep::IOV::Key
std::pair< Key_value_type, Key_value_type > Key
Definition: IOV.h:74
dd4hep::cond::ConditionsManagerObject::doOutputUnloaded
bool doOutputUnloaded() const
Access to flag to indicate if unloaded items should be saved to the slice (or not)
Definition: ConditionsManagerObject.h:97
dd4hep::cond::ConditionsManagerObject::registerIOVType
virtual std::pair< bool, const IOVType * > registerIOVType(size_t iov_type, const std::string &iov_name)=0
Register new IOV type if it does not (yet) exist.
dd4hep::cond::ConditionUpdateUserContext
ConditionUpdateUserContext class used by the derived conditions calculation mechanism.
Definition: ConditionDerived.h:49
dd4hep::cond::ConditionsManagerObject::m_onRegister
Listeners m_onRegister
Conditions listeners on registration of new conditions.
Definition: ConditionsManagerObject.h:66
dd4hep::IOVType
Class describing the interval of validty type.
Definition: IOV.h:37
dd4hep::cond::ConditionsManagerObject::iovType
virtual const IOVType * iovType(const std::string &iov_name) const =0
Access IOV by its name.
dd4hep::cond::ConditionsManagerObject::adoptCleanup
virtual void adoptCleanup(ConditionsCleanup *cleaner)=0
Adopt cleanup handler. If a handler is registered, it is invoked at every "prepare" step.
dd4hep::cond::ConditionsManagerObject::fromString
void fromString(const std::string &iov_str, IOV &iov)
Create IOV from string.
Definition: ConditionsManager.cpp:104
dd4hep::cond::ConditionsManagerObject
Basic conditions manager implementation.
Definition: ConditionsManagerObject.h:54
dd4hep::Condition
Main condition object handle.
Definition: Conditions.h:51
dd4hep::IOV
Class describing the interval of validty.
Definition: IOV.h:67
dd4hep::cond::ConditionsManagerObject::detectorDescription
Detector & detectorDescription() const
Access to the detector description instance.
Definition: ConditionsManagerObject.h:88
dd4hep::cond::ConditionsManagerObject::blockRegister
virtual size_t blockRegister(ConditionsPool &pool, const std::vector< Condition > &cond) const =0
Register a whole block of conditions with identical IOV.
dd4hep::cond::ConditionsManagerObject::m_onRemove
Listeners m_onRemove
Conditions listeners on de-registration of new conditions.
Definition: ConditionsManagerObject.h:68
dd4hep::cond::ConditionsManagerObject::iovTypesUsed
const std::vector< const IOVType * > iovTypesUsed() const
Access the used/registered IOV types.
Definition: ConditionsManager.cpp:94
dd4hep::cond::ConditionsManagerObject::initialize
virtual void initialize()=0
Initialize the object after having set the properties.
dd4hep::cond::ConditionsManagerObject::registerCallee
void registerCallee(Listeners &listeners, const Listener &callee, bool add)
Register callback listener object.
Definition: ConditionsManager.cpp:62
dd4hep::cond::ConditionsPool
Class implementing the conditions collection for a given IOV type.
Definition: ConditionsPool.h:54
dd4hep::cond::ConditionsManagerObject::key_type
Condition::key_type key_type
Definition: ConditionsManagerObject.h:56
dd4hep::cond::ConditionsManagerObject::onRegister
void onRegister(Condition condition)
Listener invocation when a condition is registered to the cache.
Definition: ConditionsManager.cpp:82
dd4hep::cond::ConditionsManagerObject::pushUpdates
virtual void pushUpdates()=0
Push all pending updates to the conditions store.
dd4hep::cond::ConditionsManagerObject::Result
ConditionsManager::Result Result
Definition: ConditionsManagerObject.h:60
dd4hep::cond::ConditionsManagerObject::prepare
virtual Result prepare(const IOV &req_iov, ConditionsSlice &slice, ConditionUpdateUserContext *ctx=0)=0
Prepare all updates to the clients with the defined IOV.
dd4hep::cond::ConditionsManagerObject::Listener
std::pair< ConditionsListener *, void * > Listener
Definition: ConditionsManagerObject.h:57
NamedObject.h
dd4hep::cond::ConditionsManagerObject::doLoadConditions
bool doLoadConditions() const
Access to load flag.
Definition: ConditionsManagerObject.h:94
dd4hep::cond::ConditionsManagerObject::compute
virtual Result compute(const IOV &required_validity, ConditionsSlice &slice, ConditionUpdateUserContext *ctxt=0)=0
Compute all derived conditions with the defined IOV (2nd step of prepare)
Conditions.h
dd4hep::cond::ConditionsManagerObject::m_detDesc
Detector & m_detDesc
Reference to main detector description object.
Definition: ConditionsManagerObject.h:64
dd4hep::cond::ConditionsManagerObject::registerIOV
virtual ConditionsPool * registerIOV(const IOVType &typ, IOV::Key key)=0
Register IOV with type and key (much more performant...)
dd4hep::Condition::key_type
unsigned long long int key_type
Forward definition of the key type.
Definition: Conditions.h:54
dd4hep::cond::ConditionsManagerObject::registerIOV
ConditionsPool * registerIOV(const std::string &data)
Register IOV using new string data.
Definition: ConditionsManager.cpp:143
dd4hep::cond::ConditionsManagerObject::callOnRegister
void callOnRegister(const Listener &callee, bool add)
(Un)Registration of conditions listeners with callback when a new condition is registered
Definition: ConditionsManager.cpp:72
key
unsigned char key
Definition: AlignmentsCalculator.cpp:69
dd4hep::cond::ConditionsManager::Result
Result of a prepare call to the conditions manager.
Definition: ConditionsManager.h:59
dd4hep::cond::ConditionsDataLoader
Interface for a generic conditions loader.
Definition: ConditionsDataLoader.h:46
dd4hep::cond::ConditionsCleanup
Base class to handle conditions cleanups.
Definition: ConditionsCleanup.h:32
dd4hep::cond::ConditionsManagerObject::ConditionsManagerObject
ConditionsManagerObject(Detector &description)
Default constructor.
Definition: ConditionsManager.cpp:47
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::NamedObject
Implementation of a named object.
Definition: NamedObject.h:30
dd4hep::cond::ConditionsManagerObject::onRemove
void onRemove(Condition condition)
Listener invocation when a condition is deregistered from the cache.
Definition: ConditionsManager.cpp:88
dd4hep::cond::ConditionsManagerObject::Listeners
std::set< Listener > Listeners
Definition: ConditionsManagerObject.h:58
dd4hep::cond::ConditionsManagerObject::loader
ConditionsDataLoader * loader() const
Access to the data loader.
Definition: ConditionsManagerObject.h:91
dd4hep::Detector
The main interface to the dd4hep detector description package.
Definition: Detector.h:90
dd4hep::cond::ConditionsManagerObject::clean
virtual std::pair< int, int > clean(const ConditionsCleanup &cleaner)=0
Invoke cache cleanup with user defined policy.
ConditionsPool.h
dd4hep::cond::ConditionsManagerObject::callOnRemove
void callOnRemove(const Listener &callee, bool add)
(Un)Registration of conditions listeners with callback when a condition is unregistered
Definition: ConditionsManager.cpp:77
dd4hep::NamedObject::type
std::string type
The object type.
Definition: NamedObject.h:35
dd4hep::cond::ConditionsIOVPool
Pool of conditions satisfying one IOV type (epoch, run, fill, etc)
Definition: ConditionsIOVPool.h:38
dd4hep::cond::ConditionsManagerObject::Loader
std::unique_ptr< ConditionsDataLoader > Loader
Definition: ConditionsManagerObject.h:59
dd4hep::cond::ConditionsManagerObject::clean
virtual int clean(const IOVType *typ, int max_age)=0
Clean conditions, which are above the age limit.
dd4hep::cond::ConditionsManagerObject::m_doLoad
bool m_doLoad
Property: Flag to indicate if items should be loaded (or not)
Definition: ConditionsManagerObject.h:72
dd4hep::cond::ConditionsSlice
Conditions slice object. Defines which conditions should be loaded by the ConditionsManager.
Definition: ConditionsSlice.h:53
dd4hep::cond::ConditionsManagerObject::clear
virtual std::pair< int, int > clear()=0
Full cleanup of all managed conditions.
dd4hep::cond::ConditionsManagerObject::m_doOutputUnloaded
bool m_doOutputUnloaded
Property: Flag to indicate if unloaded items should be saved to the slice (or not)
Definition: ConditionsManagerObject.h:74