| The Gaudi Framework v29r0 (ff2e7097)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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 {
20 class Time;
21 }
22
30 class BaseObjectMemberFunction
31 {
32 public:
34 virtual ~BaseObjectMemberFunction() = default;
35
36 virtual StatusCode operator()() const = 0;
37
38 virtual BaseObjectMemberFunction* makeCopy() const = 0;
39
40 virtual const std::type_info& type() const = 0;
41
42 virtual bool match( BaseObjectMemberFunction* ) const = 0;
43
44 virtual DataObject* castToDataObject() const = 0;
45 virtual ValidDataObject* castToValidDataObject() const = 0;
46 virtual void* castToVoid() const = 0;
47 };
48
56 template <class CallerClass>
57 class ObjectMemberFunction final : public BaseObjectMemberFunction
58 {
59 public:
61 typedef StatusCode ( CallerClass::*MemberFunctionType )();
62
64 ~ObjectMemberFunction() override = default;
65
68 StatusCode operator()() const override
69 {
70 return m_memberFunction ? ( m_instance->*m_memberFunction )() : StatusCode::SUCCESS;
71 }
72
75 BaseObjectMemberFunction* makeCopy() const override
76 {
77 return new ObjectMemberFunction<CallerClass>( m_instance, m_memberFunction );
78 }
79
81 const std::type_info& type() const override { return typeid( CallerClass ); }
82
84 bool match( BaseObjectMemberFunction* bmf ) const override
85 {
86 if ( bmf == (BaseObjectMemberFunction*)this ) return true;
87 if ( type() == bmf->type() ) {
88 ObjectMemberFunction* mf = dynamic_cast<ObjectMemberFunction*>( bmf );
89 return m_instance == mf->m_instance && m_memberFunction == mf->m_memberFunction;
90 }
91 return false;
92 }
93
95 DataObject* castToDataObject() const override { return dynamic_cast<DataObject*>( m_instance ); }
96
98 ValidDataObject* castToValidDataObject() const override { return dynamic_cast<ValidDataObject*>( m_instance ); }
99
101 void* castToVoid() const override { return dynamic_cast<void*>( m_instance ); }
102
103 protected:
105 ObjectMemberFunction( CallerClass* instance, const MemberFunctionType& mf )
106 : m_instance( instance ), m_memberFunction( mf )
107 {
108 }
109
111 CallerClass* m_instance;
112
114 MemberFunctionType m_memberFunction;
115
116 friend class IUpdateManagerSvc;
117 };
118
126 class BasePtrSetter
127 {
128 public:
130 virtual ~BasePtrSetter() = default;
132 virtual void set( DataObject* ) = 0;
134 virtual bool isNull() = 0;
135 };
136
144 class GAUDI_API IUpdateManagerSvc : virtual public IInterface
145 {
146 private:
151 template <class ActualType>
152 class PtrSetter final : public BasePtrSetter
153 {
154 public:
155 using dest_type = ActualType;
156 PtrSetter( dest_type*& dest ) : m_storage( &dest ) { *m_storage = nullptr; }
157 void set( DataObject* obj ) override { *m_storage = dynamic_cast<dest_type*>( obj ); }
158 bool isNull() override { return *m_storage == nullptr; }
159
160 private:
162 dest_type** m_storage;
163 };
164
165 public:
167 DeclareInterfaceID( IUpdateManagerSvc, 2, 0 );
168
170 virtual IDataProviderSvc* dataProvider() const = 0;
171
173 virtual IDetDataSvc* detDataSvc() const = 0;
174
181 template <class CallerClass>
182 inline void registerCondition( CallerClass* instance, const std::string& condition = "",
183 typename ObjectMemberFunction<CallerClass>::MemberFunctionType mf = nullptr )
184 {
185 i_registerCondition( condition, new ObjectMemberFunction<CallerClass>( instance, mf ) );
186 }
187
188 template <class CallerClass, class CondType>
189 inline void registerCondition( CallerClass* instance, const std::string& condition,
190 typename ObjectMemberFunction<CallerClass>::MemberFunctionType mf,
191 CondType*& condPtrDest )
192 {
193 i_registerCondition( condition, new ObjectMemberFunction<CallerClass>( instance, mf ),
194 new PtrSetter<CondType>( condPtrDest ) );
195 }
196
198 template <class CallerClass>
199 inline void registerCondition( CallerClass* instance, const char* condition,
200 typename ObjectMemberFunction<CallerClass>::MemberFunctionType mf = nullptr )
201 {
202 i_registerCondition( std::string( condition ), new ObjectMemberFunction<CallerClass>( instance, mf ) );
203 }
204
208 template <class CallerClass, class ObjectClass>
209 inline void registerCondition( CallerClass* instance, ObjectClass* obj,
210 typename ObjectMemberFunction<CallerClass>::MemberFunctionType mf = nullptr )
211 {
212 i_registerCondition( dynamic_cast<void*>( obj ), new ObjectMemberFunction<CallerClass>( instance, mf ) );
213 }
214
218 template <class CallerClass>
219 inline void unregister( CallerClass* instance )
220 {
221 i_unregister( dynamic_cast<void*>( instance ) );
222 }
223
226 template <class CallerClass>
227 inline void invalidate( CallerClass* instance )
228 {
229 i_invalidate( dynamic_cast<void*>( instance ) );
230 }
231
234 virtual bool getValidity( const std::string path, Gaudi::Time& since, Gaudi::Time& until,
235 bool path_to_db = false ) = 0;
236
241 virtual void setValidity( const std::string path, const Gaudi::Time& since, const Gaudi::Time& until,
242 bool path_to_db = false ) = 0;
243
245 virtual StatusCode newEvent() = 0;
249 virtual StatusCode newEvent( const Gaudi::Time& ) = 0;
250
253 template <class CallerClass>
254 inline StatusCode update( CallerClass* instance )
255 {
256 return i_update( dynamic_cast<void*>( instance ) );
257 }
258
260 virtual void dump() = 0;
261
263 virtual void acquireLock() = 0;
265 virtual void releaseLock() = 0;
266
270 virtual void purge() = 0;
271
276 class PythonHelper;
277
278 protected:
279 // virtual StatusCode i_registerCondition(const std::string &condition, BaseObjectMemberFunction *mf) = 0;
280 virtual void i_registerCondition( const std::string& condition, BaseObjectMemberFunction* mf,
281 BasePtrSetter* ptr_dest = nullptr ) = 0;
282 virtual void i_registerCondition( void* obj, BaseObjectMemberFunction* mf ) = 0;
283 virtual StatusCode i_update( void* instance ) = 0;
284 virtual void i_unregister( void* instance ) = 0;
285 virtual void i_invalidate( void* instance ) = 0;
286
287 friend class PythonHelper;
288 };
289 #endif // GAUDIKERNEL_IUPDATEMANAGERSVC_H
IUpdateManagerSvc::PtrSetter::PtrSetter
PtrSetter(dest_type *&dest)
Definition: IUpdateManagerSvc.h:156
ObjectMemberFunction::m_memberFunction
MemberFunctionType m_memberFunction
Pointer to the member function.
Definition: IUpdateManagerSvc.h:114
StatusCode::SUCCESS
Definition: StatusCode.h:31
BasePtrSetter
Base class to set the pointer to an object of a class derived from DataObject in a generic way...
Definition: IUpdateManagerSvc.h:126
ObjectMemberFunction::type
const std::type_info & type() const override
Returns the type_info of the CallerClass.
Definition: IUpdateManagerSvc.h:81
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:895
IUpdateManagerSvc::invalidate
void invalidate(CallerClass *instance)
Invalidate the given object in the dependency network.
Definition: IUpdateManagerSvc.h:227
IUpdateManagerSvc::PtrSetter
Templated specialization of BasePtrSetter.
Definition: IUpdateManagerSvc.h:152
IDetDataSvc
Definition: IDetDataSvc.h:23
IUpdateManagerSvc::PtrSetter::dest_type
ActualType dest_type
Definition: IUpdateManagerSvc.h:155
IUpdateManagerSvc::PtrSetter::isNull
bool isNull() override
tells if the internal pointer is nullptr.
Definition: IUpdateManagerSvc.h:158
ObjectMemberFunction::castToValidDataObject
ValidDataObject * castToValidDataObject() const override
Cast the object to ValidDataObject.
Definition: IUpdateManagerSvc.h:98
IUpdateManagerSvc::unregister
void unregister(CallerClass *instance)
Generic objects can be unregistered from the UpdateManagerSvc.
Definition: IUpdateManagerSvc.h:219
IDataProviderSvc
Data provider interface definition.
Definition: IDataProviderSvc.h:45
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:209
ObjectMemberFunction::castToVoid
void * castToVoid() const override
Cast the object to void with dynamic_cast.
Definition: IUpdateManagerSvc.h:101
std::type_info
ObjectMemberFunction::makeCopy
BaseObjectMemberFunction * makeCopy() const override
Clone method to be able to copy an ObjectMemberFunction from the BaseObjectMemberFunction interface...
Definition: IUpdateManagerSvc.h:75
std::string
STL class.
ObjectMemberFunction::m_instance
CallerClass * m_instance
Pointer to the object.
Definition: IUpdateManagerSvc.h:111
ObjectMemberFunction::operator()
StatusCode operator()() const override
Calls the member function of the object and returns the StatusCode.
Definition: IUpdateManagerSvc.h:68
IUpdateManagerSvc::registerCondition
void registerCondition(CallerClass *instance, const std::string &condition, typename ObjectMemberFunction< CallerClass >::MemberFunctionType mf, CondType *&condPtrDest)
Definition: IUpdateManagerSvc.h:189
Gaudi::Time
Based on seal::Time.
Definition: Time.h:237
gaudirun.dest
dest
Definition: gaudirun.py:170
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
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
IInterface
Definition of the basic interface.
Definition: IInterface.h:277
gaudirun.type
type
Definition: gaudirun.py:133
IUpdateManagerSvc::PythonHelper
Helper class implemented in the python dictionary to allow access from python to template member func...
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:182
IUpdateManagerSvc
Interface class to the Update Manager service.
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:162
IUpdateManagerSvc::update
StatusCode update(CallerClass *instance)
Update the given instance.
Definition: IUpdateManagerSvc.h:254
ObjectMemberFunction::ObjectMemberFunction
ObjectMemberFunction(CallerClass *instance, const MemberFunctionType &mf)
Standard constructor. Protected so that can be called only by itself or IUpdateManagerSvc.
Definition: IUpdateManagerSvc.h:105
ObjectMemberFunction
This class is used by IUpdateManagerSvc to keep pairs made of a member function and a pointer to the ...
Definition: IUpdateManagerSvc.h:57
Gaudi::Functional::operator()
virtual Out operator()(const vector_of_const_< In > &inputs) const =0
ObjectMemberFunction::castToDataObject
DataObject * castToDataObject() const override
Cast the object to DataObject.
Definition: IUpdateManagerSvc.h:95
GaudiKernel.Configurable.purge
def purge()
Definition: Configurable.py:1593
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:110
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:29
IInterface.h
BaseObjectMemberFunction::type
virtual const std::type_info & type() const =0
Gaudi
Helper functions to set/get the application return code.
Definition: __init__.py:1
ObjectMemberFunction::match
bool match(BaseObjectMemberFunction *bmf) const override
Comparison between two BaseObjectMemberFunction instances.
Definition: IUpdateManagerSvc.h:84
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:199
BaseObjectMemberFunction
Base class of ObjectMemberFunction.
Definition: IUpdateManagerSvc.h:30