The Gaudi Framework  master (01b473db)
IUpdateManagerSvc.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2025 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 #pragma once
12 
13 #include <GaudiKernel/IInterface.h>
14 #include <string>
15 #include <typeinfo>
16 
17 class DataObject;
18 class ValidDataObject;
19 class IUpdateManagerSvc;
20 class IDataProviderSvc;
21 class IDetDataSvc;
22 namespace Gaudi {
23  class Time;
24 }
25 
34 public:
35  virtual ~BaseObjectMemberFunction() = default;
36 
37  virtual StatusCode operator()() const = 0;
38 
39  virtual BaseObjectMemberFunction* makeCopy() const = 0;
40 
41  virtual const std::type_info& type() const = 0;
42 
43  virtual bool match( BaseObjectMemberFunction* ) const = 0;
44 
45  virtual DataObject* castToDataObject() const = 0;
46  virtual ValidDataObject* castToValidDataObject() const = 0;
47  virtual void* castToVoid() const = 0;
48 };
49 
57 template <class CallerClass>
59 public:
61  typedef StatusCode ( CallerClass::*MemberFunctionType )();
62 
65  StatusCode operator()() const override {
67  }
68 
71  BaseObjectMemberFunction* makeCopy() const override {
73  }
74 
76  const std::type_info& type() const override { return typeid( CallerClass ); }
77 
79  bool match( BaseObjectMemberFunction* bmf ) const override {
80  if ( bmf == (BaseObjectMemberFunction*)this ) return true;
81  if ( type() == bmf->type() ) {
82  ObjectMemberFunction* mf = dynamic_cast<ObjectMemberFunction*>( bmf );
84  }
85  return false;
86  }
87 
89  DataObject* castToDataObject() const override { return dynamic_cast<DataObject*>( m_instance ); }
90 
92  ValidDataObject* castToValidDataObject() const override { return dynamic_cast<ValidDataObject*>( m_instance ); }
93 
95  void* castToVoid() const override { return dynamic_cast<void*>( m_instance ); }
96 
97 protected:
99  ObjectMemberFunction( CallerClass* instance, const MemberFunctionType& mf )
100  : m_instance( instance ), m_memberFunction( mf ) {}
101 
103  CallerClass* m_instance;
104 
107 
108  friend class IUpdateManagerSvc;
109 };
110 
119 public:
120  virtual ~BasePtrSetter() = default;
122  virtual void set( DataObject* ) = 0;
124  virtual bool isNull() = 0;
125 };
126 
134 class GAUDI_API IUpdateManagerSvc : virtual public IInterface {
135 private:
140  template <class ActualType>
141  class PtrSetter final : public BasePtrSetter {
142  public:
143  using dest_type = ActualType;
144  PtrSetter( dest_type*& dest ) : m_storage( &dest ) { *m_storage = nullptr; }
145  void set( DataObject* obj ) override { *m_storage = dynamic_cast<dest_type*>( obj ); }
146  bool isNull() override { return *m_storage == nullptr; }
147 
148  private:
151  };
152 
153 public:
156 
158  virtual IDataProviderSvc* dataProvider() const = 0;
159 
161  virtual IDetDataSvc* detDataSvc() const = 0;
162 
169  template <class CallerClass>
170  inline void registerCondition( CallerClass* instance, const std::string& condition = "",
172  i_registerCondition( condition, new ObjectMemberFunction{ instance, mf } );
173  }
174 
175  template <class CallerClass, class CondType>
176  inline void registerCondition( CallerClass* instance, const std::string& condition,
178  CondType*& condPtrDest ) {
179  i_registerCondition( condition, new ObjectMemberFunction{ instance, mf }, new PtrSetter{ condPtrDest } );
180  }
181 
183  template <class CallerClass>
184  inline void registerCondition( CallerClass* instance, const char* condition,
186  i_registerCondition( std::string( condition ), new ObjectMemberFunction{ instance, mf } );
187  }
188 
192  template <class CallerClass, class ObjectClass>
193  inline void registerCondition( CallerClass* instance, ObjectClass* obj,
195  i_registerCondition( dynamic_cast<void*>( obj ), new ObjectMemberFunction{ instance, mf } );
196  }
197 
201  template <class CallerClass>
202  inline void unregister( CallerClass* instance ) {
203  i_unregister( dynamic_cast<void*>( instance ) );
204  }
205 
208  template <class CallerClass>
209  inline void invalidate( CallerClass* instance ) {
210  i_invalidate( dynamic_cast<void*>( instance ) );
211  }
212 
215  virtual bool getValidity( const std::string path, Gaudi::Time& since, Gaudi::Time& until,
216  bool path_to_db = false ) = 0;
217 
222  virtual void setValidity( const std::string path, const Gaudi::Time& since, const Gaudi::Time& until,
223  bool path_to_db = false ) = 0;
224 
226  virtual StatusCode newEvent() = 0;
230  virtual StatusCode newEvent( const Gaudi::Time& ) = 0;
231 
234  template <class CallerClass>
235  inline StatusCode update( CallerClass* instance ) {
236  return i_update( dynamic_cast<void*>( instance ) );
237  }
238 
240  virtual void dump() = 0;
241 
243  virtual void acquireLock() = 0;
245  virtual void releaseLock() = 0;
246 
250  virtual void purge() = 0;
251 
256  class PythonHelper;
257 
258 protected:
259  // virtual StatusCode i_registerCondition(const std::string &condition, BaseObjectMemberFunction *mf) = 0;
260  virtual void i_registerCondition( const std::string& condition, BaseObjectMemberFunction* mf,
261  BasePtrSetter* ptr_dest = nullptr ) = 0;
262  virtual void i_registerCondition( void* obj, BaseObjectMemberFunction* mf ) = 0;
263  virtual StatusCode i_update( void* instance ) = 0;
264  virtual void i_unregister( void* instance ) = 0;
265  virtual void i_invalidate( void* instance ) = 0;
266 
267  friend class PythonHelper;
268 };
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:92
BasePtrSetter::~BasePtrSetter
virtual ~BasePtrSetter()=default
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...
ObjectMemberFunction::match
bool match(BaseObjectMemberFunction *bmf) const override
Comparison between two BaseObjectMemberFunction instances.
Definition: IUpdateManagerSvc.h:79
ObjectMemberFunction::m_memberFunction
MemberFunctionType m_memberFunction
Pointer to the member function.
Definition: IUpdateManagerSvc.h:106
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:65
IUpdateManagerSvc::PtrSetter::PtrSetter
PtrSetter(dest_type *&dest)
Definition: IUpdateManagerSvc.h:144
IUpdateManagerSvc::PtrSetter::m_storage
dest_type ** m_storage
pointer to the pointer to fill provided by the user.
Definition: IUpdateManagerSvc.h:150
AtlasMCRecoFullPrecedenceDump.path
path
Definition: AtlasMCRecoFullPrecedenceDump.py:49
IUpdateManagerSvc::i_invalidate
virtual void i_invalidate(void *instance)=0
IDetDataSvc
Definition: IDetDataSvc.h:31
BaseObjectMemberFunction
Definition: IUpdateManagerSvc.h:33
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:118
BaseObjectMemberFunction::~BaseObjectMemberFunction
virtual ~BaseObjectMemberFunction()=default
BaseObjectMemberFunction::type
virtual const std::type_info & type() const =0
ObjectMemberFunction::m_instance
CallerClass * m_instance
Pointer to the object.
Definition: IUpdateManagerSvc.h:103
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:235
ObjectMemberFunction::MemberFunctionType
StatusCode(CallerClass::* MemberFunctionType)()
MemberFunctionType is the type for a pointer to a member function of class CallerClass.
Definition: IUpdateManagerSvc.h:61
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:71
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:209
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:170
StatusCode
Definition: StatusCode.h:64
IInterface.h
IUpdateManagerSvc::update
StatusCode update(CallerClass *instance)
Update the given instance.
Definition: IUpdateManagerSvc.h:235
IUpdateManagerSvc::registerCondition
void registerCondition(CallerClass *instance, const std::string &condition, typename ObjectMemberFunction< CallerClass >::MemberFunctionType mf, CondType *&condPtrDest)
Definition: IUpdateManagerSvc.h:176
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:202
ObjectMemberFunction::ObjectMemberFunction
ObjectMemberFunction(CallerClass *instance, const MemberFunctionType &mf)
Standard constructor. Protected so that can be called only by itself or IUpdateManagerSvc.
Definition: IUpdateManagerSvc.h:99
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:193
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:99
IUpdateManagerSvc::PtrSetter
Definition: IUpdateManagerSvc.h:141
ObjectMemberFunction::castToDataObject
DataObject * castToDataObject() const override
Cast the object to DataObject.
Definition: IUpdateManagerSvc.h:89
IUpdateManagerSvc::DeclareInterfaceID
DeclareInterfaceID(IUpdateManagerSvc, 2, 0)
InterfaceID.
ObjectMemberFunction
Definition: IUpdateManagerSvc.h:58
IUpdateManagerSvc
Definition: IUpdateManagerSvc.h:134
IUpdateManagerSvc::PtrSetter::isNull
bool isNull() override
tells if the internal pointer is nullptr.
Definition: IUpdateManagerSvc.h:146
BaseObjectMemberFunction::castToVoid
virtual void * castToVoid() const =0
IInterface
Definition: IInterface.h:225
IUpdateManagerSvc::PtrSetter::dest_type
ActualType dest_type
Definition: IUpdateManagerSvc.h:143
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:184
IUpdateManagerSvc::acquireLock
virtual void acquireLock()=0
Force the update manager service to wait before entering the newEvent loop.
DataObject
Definition: DataObject.h:37
ObjectMemberFunction::castToVoid
void * castToVoid() const override
Cast the object to void with dynamic_cast.
Definition: IUpdateManagerSvc.h:95
BaseObjectMemberFunction::operator()
virtual StatusCode operator()() const =0
IDataProviderSvc
Definition: IDataProviderSvc.h:48
IUpdateManagerSvc::PtrSetter::set
void set(DataObject *obj) override
sets the internal pointer to the provided data object (with a dynamic_cast).
Definition: IUpdateManagerSvc.h:145
ObjectMemberFunction::type
const std::type_info & type() const override
Returns the type_info of the CallerClass.
Definition: IUpdateManagerSvc.h:76
BaseObjectMemberFunction::match
virtual bool match(BaseObjectMemberFunction *) const =0
PythonHelper
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:49
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