The Gaudi Framework  master (37c0b60a)
IUpdateManagerSvc.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDIKERNEL_IUPDATEMANAGERSVC_H
12 #define GAUDIKERNEL_IUPDATEMANAGERSVC_H 1
13 
14 // Include files
15 // from STL
16 #include <string>
17 #include <typeinfo>
18 
19 // from Gaudi
20 #include <GaudiKernel/IInterface.h>
21 
22 // forward declarations
23 class DataObject;
24 class ValidDataObject;
25 class IUpdateManagerSvc;
26 class IDataProviderSvc;
27 class IDetDataSvc;
28 namespace Gaudi {
29  class Time;
30 }
31 
40 public:
42  virtual ~BaseObjectMemberFunction() = default;
43 
44  virtual StatusCode operator()() const = 0;
45 
46  virtual BaseObjectMemberFunction* makeCopy() const = 0;
47 
48  virtual const std::type_info& type() const = 0;
49 
50  virtual bool match( BaseObjectMemberFunction* ) const = 0;
51 
52  virtual DataObject* castToDataObject() const = 0;
53  virtual ValidDataObject* castToValidDataObject() const = 0;
54  virtual void* castToVoid() const = 0;
55 };
56 
64 template <class CallerClass>
66 public:
68  typedef StatusCode ( CallerClass::*MemberFunctionType )();
69 
72  StatusCode operator()() const override {
74  }
75 
78  BaseObjectMemberFunction* makeCopy() const override {
80  }
81 
83  const std::type_info& type() const override { return typeid( CallerClass ); }
84 
86  bool match( BaseObjectMemberFunction* bmf ) const override {
87  if ( bmf == (BaseObjectMemberFunction*)this ) return true;
88  if ( type() == bmf->type() ) {
89  ObjectMemberFunction* mf = dynamic_cast<ObjectMemberFunction*>( bmf );
91  }
92  return false;
93  }
94 
96  DataObject* castToDataObject() const override { return dynamic_cast<DataObject*>( m_instance ); }
97 
99  ValidDataObject* castToValidDataObject() const override { return dynamic_cast<ValidDataObject*>( m_instance ); }
100 
102  void* castToVoid() const override { return dynamic_cast<void*>( m_instance ); }
103 
104 protected:
106  ObjectMemberFunction( CallerClass* instance, const MemberFunctionType& mf )
107  : m_instance( instance ), m_memberFunction( mf ) {}
108 
110  CallerClass* m_instance;
111 
114 
115  friend class IUpdateManagerSvc;
116 };
117 
126 public:
128  virtual ~BasePtrSetter() = default;
130  virtual void set( DataObject* ) = 0;
132  virtual bool isNull() = 0;
133 };
134 
142 class GAUDI_API IUpdateManagerSvc : virtual public IInterface {
143 private:
148  template <class ActualType>
149  class PtrSetter final : public BasePtrSetter {
150  public:
151  using dest_type = ActualType;
152  PtrSetter( dest_type*& dest ) : m_storage( &dest ) { *m_storage = nullptr; }
153  void set( DataObject* obj ) override { *m_storage = dynamic_cast<dest_type*>( obj ); }
154  bool isNull() override { return *m_storage == nullptr; }
155 
156  private:
159  };
160 
161 public:
164 
166  virtual IDataProviderSvc* dataProvider() const = 0;
167 
169  virtual IDetDataSvc* detDataSvc() const = 0;
170 
177  template <class CallerClass>
178  inline void registerCondition( CallerClass* instance, const std::string& condition = "",
180  i_registerCondition( condition, new ObjectMemberFunction{ instance, mf } );
181  }
182 
183  template <class CallerClass, class CondType>
184  inline void registerCondition( CallerClass* instance, const std::string& condition,
186  CondType*& condPtrDest ) {
187  i_registerCondition( condition, new ObjectMemberFunction{ instance, mf }, new PtrSetter{ condPtrDest } );
188  }
189 
191  template <class CallerClass>
192  inline void registerCondition( CallerClass* instance, const char* condition,
194  i_registerCondition( std::string( condition ), new ObjectMemberFunction{ instance, mf } );
195  }
196 
200  template <class CallerClass, class ObjectClass>
201  inline void registerCondition( CallerClass* instance, ObjectClass* obj,
203  i_registerCondition( dynamic_cast<void*>( obj ), new ObjectMemberFunction{ instance, mf } );
204  }
205 
209  template <class CallerClass>
210  inline void unregister( CallerClass* instance ) {
211  i_unregister( dynamic_cast<void*>( instance ) );
212  }
213 
216  template <class CallerClass>
217  inline void invalidate( CallerClass* instance ) {
218  i_invalidate( dynamic_cast<void*>( instance ) );
219  }
220 
223  virtual bool getValidity( const std::string path, Gaudi::Time& since, Gaudi::Time& until,
224  bool path_to_db = false ) = 0;
225 
230  virtual void setValidity( const std::string path, const Gaudi::Time& since, const Gaudi::Time& until,
231  bool path_to_db = false ) = 0;
232 
234  virtual StatusCode newEvent() = 0;
238  virtual StatusCode newEvent( const Gaudi::Time& ) = 0;
239 
242  template <class CallerClass>
243  inline StatusCode update( CallerClass* instance ) {
244  return i_update( dynamic_cast<void*>( instance ) );
245  }
246 
248  virtual void dump() = 0;
249 
251  virtual void acquireLock() = 0;
253  virtual void releaseLock() = 0;
254 
258  virtual void purge() = 0;
259 
264  class PythonHelper;
265 
266 protected:
267  // virtual StatusCode i_registerCondition(const std::string &condition, BaseObjectMemberFunction *mf) = 0;
268  virtual void i_registerCondition( const std::string& condition, BaseObjectMemberFunction* mf,
269  BasePtrSetter* ptr_dest = nullptr ) = 0;
270  virtual void i_registerCondition( void* obj, BaseObjectMemberFunction* mf ) = 0;
271  virtual StatusCode i_update( void* instance ) = 0;
272  virtual void i_unregister( void* instance ) = 0;
273  virtual void i_invalidate( void* instance ) = 0;
274 
275  friend class PythonHelper;
276 };
277 #endif // GAUDIKERNEL_IUPDATEMANAGERSVC_H
IUpdateManagerSvc::newEvent
virtual StatusCode newEvent(const Gaudi::Time &)=0
Start an update loop using the give event time.
ObjectMemberFunction::castToValidDataObject
ValidDataObject * castToValidDataObject() const override
Cast the object to ValidDataObject.
Definition: IUpdateManagerSvc.h:99
BasePtrSetter::~BasePtrSetter
virtual ~BasePtrSetter()=default
Empty virtual destructor.
IUpdateManagerSvc::setValidity
virtual void setValidity(const std::string path, const Gaudi::Time &since, const Gaudi::Time &until, bool path_to_db=false)=0
Change the interval of validity of the given item to the specified values, updating parents if needed...
std::string
STL class.
ObjectMemberFunction::match
bool match(BaseObjectMemberFunction *bmf) const override
Comparison between two BaseObjectMemberFunction instances.
Definition: IUpdateManagerSvc.h:86
ObjectMemberFunction::m_memberFunction
MemberFunctionType m_memberFunction
Pointer to the member function.
Definition: IUpdateManagerSvc.h:113
IUpdateManagerSvc::dataProvider
virtual IDataProviderSvc * dataProvider() const =0
Give access to the data provider.
BasePtrSetter::set
virtual void set(DataObject *)=0
sets the internal pointer to the provided data object (with a dynamic_cast).
ObjectMemberFunction::operator()
StatusCode operator()() const override
Calls the member function of the object and returns the StatusCode.
Definition: IUpdateManagerSvc.h:72
IUpdateManagerSvc::PtrSetter::PtrSetter
PtrSetter(dest_type *&dest)
Definition: IUpdateManagerSvc.h:152
IUpdateManagerSvc::PtrSetter::m_storage
dest_type ** m_storage
pointer to the pointer to fill provided by the user.
Definition: IUpdateManagerSvc.h:158
AtlasMCRecoFullPrecedenceDump.path
path
Definition: AtlasMCRecoFullPrecedenceDump.py:49
IUpdateManagerSvc::i_invalidate
virtual void i_invalidate(void *instance)=0
IDetDataSvc
Definition: IDetDataSvc.h:32
BaseObjectMemberFunction
Definition: IUpdateManagerSvc.h:39
std::type_info
IUpdateManagerSvc::releaseLock
virtual void releaseLock()=0
Let the update manager service enter the newEvent loop.
IUpdateManagerSvc::dump
virtual void dump()=0
Debug method: it dumps the dependency network through the message service (not very readable,...
BasePtrSetter
Definition: IUpdateManagerSvc.h:125
BaseObjectMemberFunction::~BaseObjectMemberFunction
virtual ~BaseObjectMemberFunction()=default
Virtual destructor.
BaseObjectMemberFunction::type
virtual const std::type_info & type() const =0
ObjectMemberFunction::m_instance
CallerClass * m_instance
Pointer to the object.
Definition: IUpdateManagerSvc.h:110
IUpdateManagerSvc::i_unregister
virtual void i_unregister(void *instance)=0
IUpdateManagerSvc::newEvent
virtual StatusCode newEvent()=0
Start an update loop using the event time given by the detector data service.
IUpdateManagerSvc::i_registerCondition
virtual void i_registerCondition(void *obj, BaseObjectMemberFunction *mf)=0
Gaudi::Time
Definition: Time.h:241
ObjectMemberFunction::MemberFunctionType
StatusCode(CallerClass::* MemberFunctionType)()
MemberFunctionType is the type for a pointer to a member function of class CallerClass.
Definition: IUpdateManagerSvc.h:68
BaseObjectMemberFunction::castToDataObject
virtual DataObject * castToDataObject() const =0
BaseObjectMemberFunction::castToValidDataObject
virtual ValidDataObject * castToValidDataObject() const =0
ObjectMemberFunction::makeCopy
BaseObjectMemberFunction * makeCopy() const override
Clone method to be able to copy an ObjectMemberFunction from the BaseObjectMemberFunction interface.
Definition: IUpdateManagerSvc.h:78
BasePtrSetter::isNull
virtual bool isNull()=0
tells if the internal pointer is nullptr.
IUpdateManagerSvc::invalidate
void invalidate(CallerClass *instance)
Invalidate the given object in the dependency network.
Definition: IUpdateManagerSvc.h:217
IUpdateManagerSvc::registerCondition
void registerCondition(CallerClass *instance, const std::string &condition="", typename ObjectMemberFunction< CallerClass >::MemberFunctionType mf=nullptr)
Register an object (algorithm instance) to the service.
Definition: IUpdateManagerSvc.h:178
StatusCode
Definition: StatusCode.h:65
IInterface.h
IUpdateManagerSvc::update
StatusCode update(CallerClass *instance)
Update the given instance.
Definition: IUpdateManagerSvc.h:243
IUpdateManagerSvc::registerCondition
void registerCondition(CallerClass *instance, const std::string &condition, typename ObjectMemberFunction< CallerClass >::MemberFunctionType mf, CondType *&condPtrDest)
Definition: IUpdateManagerSvc.h:184
IUpdateManagerSvc::i_update
virtual StatusCode i_update(void *instance)=0
IUpdateManagerSvc::purge
virtual void purge()=0
Remove all the items referring to objects present in the transient store.
IUpdateManagerSvc::detDataSvc
virtual IDetDataSvc * detDataSvc() const =0
Give access to the detector data service interface (usualy of the data provider itself).
IUpdateManagerSvc::unregister
void unregister(CallerClass *instance)
Generic objects can be unregistered from the UpdateManagerSvc.
Definition: IUpdateManagerSvc.h:210
ObjectMemberFunction::ObjectMemberFunction
ObjectMemberFunction(CallerClass *instance, const MemberFunctionType &mf)
Standard constructor. Protected so that can be called only by itself or IUpdateManagerSvc.
Definition: IUpdateManagerSvc.h:106
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition: __init__.py:1
IUpdateManagerSvc::registerCondition
void registerCondition(CallerClass *instance, ObjectClass *obj, typename ObjectMemberFunction< CallerClass >::MemberFunctionType mf=nullptr)
Like the first version of registerCondition, but instead declaring the dependency on a condition of t...
Definition: IUpdateManagerSvc.h:201
gaudirun.dest
dest
Definition: gaudirun.py:224
IUpdateManagerSvc::i_registerCondition
virtual void i_registerCondition(const std::string &condition, BaseObjectMemberFunction *mf, BasePtrSetter *ptr_dest=nullptr)=0
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
IUpdateManagerSvc::PtrSetter
Definition: IUpdateManagerSvc.h:149
ObjectMemberFunction::castToDataObject
DataObject * castToDataObject() const override
Cast the object to DataObject.
Definition: IUpdateManagerSvc.h:96
IUpdateManagerSvc::DeclareInterfaceID
DeclareInterfaceID(IUpdateManagerSvc, 2, 0)
InterfaceID.
ObjectMemberFunction
Definition: IUpdateManagerSvc.h:65
IUpdateManagerSvc
Definition: IUpdateManagerSvc.h:142
IUpdateManagerSvc::PtrSetter::isNull
bool isNull() override
tells if the internal pointer is nullptr.
Definition: IUpdateManagerSvc.h:154
BaseObjectMemberFunction::castToVoid
virtual void * castToVoid() const =0
IInterface
Definition: IInterface.h:239
IUpdateManagerSvc::PtrSetter::dest_type
ActualType dest_type
Definition: IUpdateManagerSvc.h:151
IUpdateManagerSvc::registerCondition
void registerCondition(CallerClass *instance, const char *condition, typename ObjectMemberFunction< CallerClass >::MemberFunctionType mf=nullptr)
See above. Needed to avoid conflicts with the next one.
Definition: IUpdateManagerSvc.h:192
IUpdateManagerSvc::acquireLock
virtual void acquireLock()=0
Force the update manager service to wait before entering the newEvent loop.
DataObject
Definition: DataObject.h:36
ObjectMemberFunction::castToVoid
void * castToVoid() const override
Cast the object to void with dynamic_cast.
Definition: IUpdateManagerSvc.h:102
BaseObjectMemberFunction::operator()
virtual StatusCode operator()() const =0
IDataProviderSvc
Definition: IDataProviderSvc.h:53
IUpdateManagerSvc::PtrSetter::set
void set(DataObject *obj) override
sets the internal pointer to the provided data object (with a dynamic_cast).
Definition: IUpdateManagerSvc.h:153
ObjectMemberFunction::type
const std::type_info & type() const override
Returns the type_info of the CallerClass.
Definition: IUpdateManagerSvc.h:83
BaseObjectMemberFunction::match
virtual bool match(BaseObjectMemberFunction *) const =0
PythonHelper
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:81
IUpdateManagerSvc::getValidity
virtual bool getValidity(const std::string path, Gaudi::Time &since, Gaudi::Time &until, bool path_to_db=false)=0
Retrieve the interval of validity (in the UpdateManagerSvc) of the given item.
BaseObjectMemberFunction::makeCopy
virtual BaseObjectMemberFunction * makeCopy() const =0