The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
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
14#include <string>
15#include <typeinfo>
16
17class DataObject;
18class ValidDataObject;
21class IDetDataSvc;
22namespace Gaudi {
23 class Time;
24}
25
34public:
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
57template <class CallerClass>
59public:
61 typedef StatusCode ( CallerClass::*MemberFunctionType )();
62
68
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
97protected:
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
119public:
120 virtual ~BasePtrSetter() = default;
122 virtual void set( DataObject* ) = 0;
124 virtual bool isNull() = 0;
125};
126
134class GAUDI_API IUpdateManagerSvc : virtual public IInterface {
135private:
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
153public:
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
258protected:
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};
#define GAUDI_API
Definition Kernel.h:49
Base class of ObjectMemberFunction.
virtual ~BaseObjectMemberFunction()=default
virtual const std::type_info & type() const =0
virtual StatusCode operator()() const =0
virtual BaseObjectMemberFunction * makeCopy() const =0
virtual bool match(BaseObjectMemberFunction *) const =0
virtual DataObject * castToDataObject() const =0
virtual void * castToVoid() const =0
virtual ValidDataObject * castToValidDataObject() const =0
Base class to set the pointer to an object of a class derived from DataObject in a generic way.
virtual bool isNull()=0
tells if the internal pointer is nullptr.
virtual ~BasePtrSetter()=default
virtual void set(DataObject *)=0
sets the internal pointer to the provided data object (with a dynamic_cast).
A DataObject is the base class of any identifiable object on any data store.
Definition DataObject.h:37
Based on seal::Time.
Definition Time.h:235
Data provider interface definition.
Abstract interface for a DataSvc manipulating condition data (i.e.
Definition IDetDataSvc.h:31
Definition of the basic interface.
Definition IInterface.h:225
Templated specialization of BasePtrSetter.
bool isNull() override
tells if the internal pointer is nullptr.
dest_type ** m_storage
pointer to the pointer to fill provided by the user.
void set(DataObject *obj) override
sets the internal pointer to the provided data object (with a dynamic_cast).
Helper class implemented in the python dictionary to allow access from python to template member func...
Interface class to the Update Manager service.
virtual void dump()=0
Debug method: it dumps the dependency network through the message service (not very readable,...
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.
virtual StatusCode newEvent()=0
Start an update loop using the event time given by the detector data service.
virtual void acquireLock()=0
Force the update manager service to wait before entering the newEvent loop.
virtual void purge()=0
Remove all the items referring to objects present in the transient store.
virtual void i_registerCondition(void *obj, BaseObjectMemberFunction *mf)=0
virtual void i_unregister(void *instance)=0
StatusCode update(CallerClass *instance)
Update the given instance.
friend class PythonHelper
void unregister(CallerClass *instance)
Generic objects can be unregistered from the UpdateManagerSvc.
virtual void i_invalidate(void *instance)=0
void registerCondition(CallerClass *instance, const char *condition, typename ObjectMemberFunction< CallerClass >::MemberFunctionType mf=nullptr)
See above. Needed to avoid conflicts with the next one.
virtual StatusCode i_update(void *instance)=0
DeclareInterfaceID(IUpdateManagerSvc, 2, 0)
InterfaceID.
virtual IDetDataSvc * detDataSvc() const =0
Give access to the detector data service interface (usualy of the data provider itself).
void registerCondition(CallerClass *instance, const std::string &condition="", typename ObjectMemberFunction< CallerClass >::MemberFunctionType mf=nullptr)
Register an object (algorithm instance) to the service.
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...
virtual void i_registerCondition(const std::string &condition, BaseObjectMemberFunction *mf, BasePtrSetter *ptr_dest=nullptr)=0
virtual StatusCode newEvent(const Gaudi::Time &)=0
Start an update loop using the give event time.
virtual void releaseLock()=0
Let the update manager service enter the newEvent loop.
void invalidate(CallerClass *instance)
Invalidate the given object in the dependency network.
virtual IDataProviderSvc * dataProvider() const =0
Give access to the data provider.
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...
void registerCondition(CallerClass *instance, const std::string &condition, typename ObjectMemberFunction< CallerClass >::MemberFunctionType mf, CondType *&condPtrDest)
This class is used by IUpdateManagerSvc to keep pairs made of a member function and a pointer to the ...
const std::type_info & type() const override
Returns the type_info of the CallerClass.
BaseObjectMemberFunction * makeCopy() const override
Clone method to be able to copy an ObjectMemberFunction from the BaseObjectMemberFunction interface.
bool match(BaseObjectMemberFunction *bmf) const override
Comparison between two BaseObjectMemberFunction instances.
void * castToVoid() const override
Cast the object to void with dynamic_cast.
MemberFunctionType m_memberFunction
Pointer to the member function.
StatusCode(CallerClass::* MemberFunctionType)()
MemberFunctionType is the type for a pointer to a member function of class CallerClass.
DataObject * castToDataObject() const override
Cast the object to DataObject.
CallerClass * m_instance
Pointer to the object.
ObjectMemberFunction(CallerClass *instance, const MemberFunctionType &mf)
Standard constructor. Protected so that can be called only by itself or IUpdateManagerSvc.
ValidDataObject * castToValidDataObject() const override
Cast the object to ValidDataObject.
StatusCode operator()() const override
Calls the member function of the object and returns the StatusCode.
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
constexpr static const auto SUCCESS
Definition StatusCode.h:99
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition __init__.py:1