| The Gaudi Framework v32r1 (f65d50dc)

IUpdateManagerSvc.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_IUPDATEMANAGERSVC_H
2 #define GAUDIKERNEL_IUPDATEMANAGERSVC_H 1
3
4 // Include files
5 // from STL
6 #include <string>
7 #include <typeinfo>
8
9 // from Gaudi
10 #include "GaudiKernel/IInterface.h"
11
12 // forward declarations
13 class DataObject;
14 class ValidDataObject;
15 class IUpdateManagerSvc;
16 class IDataProviderSvc;
17 class IDetDataSvc;
18 namespace Gaudi {
19 class Time;
20 }
21
29 class BaseObjectMemberFunction {
30 public:
32 virtual ~BaseObjectMemberFunction() = default;
33
34 virtual StatusCode operator()() const = 0;
35
36 virtual BaseObjectMemberFunction* makeCopy() const = 0;
37
38 virtual const std::type_info& type() const = 0;
39
40 virtual bool match( BaseObjectMemberFunction* ) const = 0;
41
42 virtual DataObject* castToDataObject() const = 0;
43 virtual ValidDataObject* castToValidDataObject() const = 0;
44 virtual void* castToVoid() const = 0;
45 };
46
54 template <class CallerClass>
55 class ObjectMemberFunction final : public BaseObjectMemberFunction {
56 public:
58 typedef StatusCode ( CallerClass::*MemberFunctionType )();
59
62 StatusCode operator()() const override {
63 return m_memberFunction ? ( m_instance->*m_memberFunction )() : StatusCode::SUCCESS;
64 }
65
68 BaseObjectMemberFunction* makeCopy() const override {
69 return new ObjectMemberFunction<CallerClass>( m_instance, m_memberFunction );
70 }
71
73 const std::type_info& type() const override { return typeid( CallerClass ); }
74
76 bool match( BaseObjectMemberFunction* bmf ) const override {
77 if ( bmf == (BaseObjectMemberFunction*)this ) return true;
78 if ( type() == bmf->type() ) {
79 ObjectMemberFunction* mf = dynamic_cast<ObjectMemberFunction*>( bmf );
80 return m_instance == mf->m_instance && m_memberFunction == mf->m_memberFunction;
81 }
82 return false;
83 }
84
86 DataObject* castToDataObject() const override { return dynamic_cast<DataObject*>( m_instance ); }
87
89 ValidDataObject* castToValidDataObject() const override { return dynamic_cast<ValidDataObject*>( m_instance ); }
90
92 void* castToVoid() const override { return dynamic_cast<void*>( m_instance ); }
93
94 protected:
96 ObjectMemberFunction( CallerClass* instance, const MemberFunctionType& mf )
97 : m_instance( instance ), m_memberFunction( mf ) {}
98
100 CallerClass* m_instance;
101
103 MemberFunctionType m_memberFunction;
104
105 friend class IUpdateManagerSvc;
106 };
107
115 class BasePtrSetter {
116 public:
118 virtual ~BasePtrSetter() = default;
120 virtual void set( DataObject* ) = 0;
122 virtual bool isNull() = 0;
123 };
124
132 class GAUDI_API IUpdateManagerSvc : virtual public IInterface {
133 private:
138 template <class ActualType>
139 class PtrSetter final : public BasePtrSetter {
140 public:
141 using dest_type = ActualType;
142 PtrSetter( dest_type*& dest ) : m_storage( &dest ) { *m_storage = nullptr; }
143 void set( DataObject* obj ) override { *m_storage = dynamic_cast<dest_type*>( obj ); }
144 bool isNull() override { return *m_storage == nullptr; }
145
146 private:
148 dest_type** m_storage;
149 };
150
151 public:
153 DeclareInterfaceID( IUpdateManagerSvc, 2, 0 );
154
156 virtual IDataProviderSvc* dataProvider() const = 0;
157
159 virtual IDetDataSvc* detDataSvc() const = 0;
160
167 template <class CallerClass>
168 inline void registerCondition( CallerClass* instance, const std::string& condition = "",
169 typename ObjectMemberFunction<CallerClass>::MemberFunctionType mf = nullptr ) {
170 i_registerCondition( condition, new ObjectMemberFunction<CallerClass>( instance, mf ) );
171 }
172
173 template <class CallerClass, class CondType>
174 inline void registerCondition( CallerClass* instance, const std::string& condition,
175 typename ObjectMemberFunction<CallerClass>::MemberFunctionType mf,
176 CondType*& condPtrDest ) {
177 i_registerCondition( condition, new ObjectMemberFunction<CallerClass>( instance, mf ),
178 new PtrSetter<CondType>( condPtrDest ) );
179 }
180
182 template <class CallerClass>
183 inline void registerCondition( CallerClass* instance, const char* condition,
184 typename ObjectMemberFunction<CallerClass>::MemberFunctionType mf = nullptr ) {
185 i_registerCondition( std::string( condition ), new ObjectMemberFunction<CallerClass>( instance, mf ) );
186 }
187
191 template <class CallerClass, class ObjectClass>
192 inline void registerCondition( CallerClass* instance, ObjectClass* obj,
193 typename ObjectMemberFunction<CallerClass>::MemberFunctionType mf = nullptr ) {
194 i_registerCondition( dynamic_cast<void*>( obj ), new ObjectMemberFunction<CallerClass>( instance, mf ) );
195 }
196
200 template <class CallerClass>
201 inline void unregister( CallerClass* instance ) {
202 i_unregister( dynamic_cast<void*>( instance ) );
203 }
204
207 template <class CallerClass>
208 inline void invalidate( CallerClass* instance ) {
209 i_invalidate( dynamic_cast<void*>( instance ) );
210 }
211
214 virtual bool getValidity( const std::string path, Gaudi::Time& since, Gaudi::Time& until,
215 bool path_to_db = false ) = 0;
216
221 virtual void setValidity( const std::string path, const Gaudi::Time& since, const Gaudi::Time& until,
222 bool path_to_db = false ) = 0;
223
225 virtual StatusCode newEvent() = 0;
229 virtual StatusCode newEvent( const Gaudi::Time& ) = 0;
230
233 template <class CallerClass>
234 inline StatusCode update( CallerClass* instance ) {
235 return i_update( dynamic_cast<void*>( instance ) );
236 }
237
239 virtual void dump() = 0;
240
242 virtual void acquireLock() = 0;
244 virtual void releaseLock() = 0;
245
249 virtual void purge() = 0;
250
255 class PythonHelper;
256
257 protected:
258 // virtual StatusCode i_registerCondition(const std::string &condition, BaseObjectMemberFunction *mf) = 0;
259 virtual void i_registerCondition( const std::string& condition, BaseObjectMemberFunction* mf,
260 BasePtrSetter* ptr_dest = nullptr ) = 0;
261 virtual void i_registerCondition( void* obj, BaseObjectMemberFunction* mf ) = 0;
262 virtual StatusCode i_update( void* instance ) = 0;
263 virtual void i_unregister( void* instance ) = 0;
264 virtual void i_invalidate( void* instance ) = 0;
265
266 friend class PythonHelper;
267 };
268 #endif // GAUDIKERNEL_IUPDATEMANAGERSVC_H
IUpdateManagerSvc::PtrSetter::PtrSetter
PtrSetter(dest_type *&dest)
Definition: IUpdateManagerSvc.h:142
BaseObjectMemberFunction::castToDataObject
virtual DataObject * castToDataObject() const =0
ObjectMemberFunction::m_memberFunction
MemberFunctionType m_memberFunction
Pointer to the member function.
Definition: IUpdateManagerSvc.h:103
BasePtrSetter::isNull
virtual bool isNull()=0
tells if the internal pointer is nullptr.
ObjectMemberFunction::castToValidDataObject
ValidDataObject * castToValidDataObject() const override
Cast the object to ValidDataObject.
Definition: IUpdateManagerSvc.h:89
BasePtrSetter
Base class to set the pointer to an object of a class derived from DataObject in a generic way.
Definition: IUpdateManagerSvc.h:115
BaseObjectMemberFunction::castToVoid
virtual void * castToVoid() const =0
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:932
ObjectMemberFunction::match
bool match(BaseObjectMemberFunction *bmf) const override
Comparison between two BaseObjectMemberFunction instances.
Definition: IUpdateManagerSvc.h:76
IUpdateManagerSvc::invalidate
void invalidate(CallerClass *instance)
Invalidate the given object in the dependency network.
Definition: IUpdateManagerSvc.h:208
IUpdateManagerSvc::PtrSetter
Templated specialization of BasePtrSetter.
Definition: IUpdateManagerSvc.h:139
IDetDataSvc
Abstract interface for a DataSvc manipulating condition data (i.e.
Definition: IDetDataSvc.h:22
IUpdateManagerSvc::PtrSetter::dest_type
ActualType dest_type
Definition: IUpdateManagerSvc.h:141
IUpdateManagerSvc::PtrSetter::isNull
bool isNull() override
tells if the internal pointer is nullptr.
Definition: IUpdateManagerSvc.h:144
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
IUpdateManagerSvc::PtrSetter::set
void set(DataObject *obj) override
sets the internal pointer to the provided data object (with a dynamic_cast).
Definition: IUpdateManagerSvc.h:143
ObjectMemberFunction::makeCopy
BaseObjectMemberFunction * makeCopy() const override
Clone method to be able to copy an ObjectMemberFunction from the BaseObjectMemberFunction interface.
Definition: IUpdateManagerSvc.h:68
IUpdateManagerSvc::unregister
void unregister(CallerClass *instance)
Generic objects can be unregistered from the UpdateManagerSvc.
Definition: IUpdateManagerSvc.h:201
BaseObjectMemberFunction::match
virtual bool match(BaseObjectMemberFunction *) const =0
IDataProviderSvc
Data provider interface definition.
Definition: IDataProviderSvc.h:43
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:192
BaseObjectMemberFunction::makeCopy
virtual BaseObjectMemberFunction * makeCopy() const =0
std::type_info
std::string
STL class.
BaseObjectMemberFunction::operator()
virtual StatusCode operator()() const =0
ObjectMemberFunction::m_instance
CallerClass * m_instance
Pointer to the object.
Definition: IUpdateManagerSvc.h:100
IUpdateManagerSvc::registerCondition
void registerCondition(CallerClass *instance, const std::string &condition, typename ObjectMemberFunction< CallerClass >::MemberFunctionType mf, CondType *&condPtrDest)
Definition: IUpdateManagerSvc.h:174
Gaudi::Time
Based on seal::Time.
Definition: Time.h:231
gaudirun.dest
dest
Definition: gaudirun.py:201
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
ObjectMemberFunction::MemberFunctionType
StatusCode(CallerClass::* MemberFunctionType)()
MemberFunctionType is the type for a pointer to a member function of class CallerClass.
Definition: IUpdateManagerSvc.h:58
IInterface
Definition of the basic interface.
Definition: IInterface.h:244
IUpdateManagerSvc::PythonHelper
Helper class implemented in the python dictionary to allow access from python to template member func...
BasePtrSetter::set
virtual void set(DataObject *)=0
sets the internal pointer to the provided data object (with a dynamic_cast).
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:168
IUpdateManagerSvc
Interface class to the Update Manager service.
Definition: IUpdateManagerSvc.h:132
BaseObjectMemberFunction::type
virtual const std::type_info & type() const =0
IUpdateManagerSvc::PtrSetter::m_storage
dest_type ** m_storage
pointer to the pointer to fill provided by the user.
Definition: IUpdateManagerSvc.h:148
DeclareInterfaceID
#define DeclareInterfaceID(iface, major, minor)
Macro to declare the interface ID when using the new mechanism of extending and implementing interfac...
Definition: IInterface.h:13
IUpdateManagerSvc::update
StatusCode update(CallerClass *instance)
Update the given instance.
Definition: IUpdateManagerSvc.h:234
ObjectMemberFunction::ObjectMemberFunction
ObjectMemberFunction(CallerClass *instance, const MemberFunctionType &mf)
Standard constructor. Protected so that can be called only by itself or IUpdateManagerSvc.
Definition: IUpdateManagerSvc.h:96
ObjectMemberFunction
This class is used by IUpdateManagerSvc to keep pairs made of a member function and a pointer to the ...
Definition: IUpdateManagerSvc.h:55
BasePtrSetter::~BasePtrSetter
virtual ~BasePtrSetter()=default
Empty virtual destructor.
BaseObjectMemberFunction::~BaseObjectMemberFunction
virtual ~BaseObjectMemberFunction()=default
Virtual destructor.
ObjectMemberFunction::castToDataObject
DataObject * castToDataObject() const override
Cast the object to DataObject.
Definition: IUpdateManagerSvc.h:86
GaudiKernel.Configurable.purge
def purge()
Definition: Configurable.py:1665
ObjectMemberFunction::castToVoid
void * castToVoid() const override
Cast the object to void with dynamic_cast.
Definition: IUpdateManagerSvc.h:92
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:71
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
IInterface.h
BaseObjectMemberFunction::castToValidDataObject
virtual ValidDataObject * castToValidDataObject() const =0
Gaudi
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
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:183
ObjectMemberFunction::type
const std::type_info & type() const override
Returns the type_info of the CallerClass.
Definition: IUpdateManagerSvc.h:73
ObjectMemberFunction::operator()
StatusCode operator()() const override
Calls the member function of the object and returns the StatusCode.
Definition: IUpdateManagerSvc.h:62
BaseObjectMemberFunction
Base class of ObjectMemberFunction.
Definition: IUpdateManagerSvc.h:29