| The Gaudi Framework v27r1

- 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 { class Time; }
19
27 class BaseObjectMemberFunction {
28 public:
30 virtual ~BaseObjectMemberFunction() = default;
31
32 virtual StatusCode operator() () const = 0;
33
34 virtual BaseObjectMemberFunction *makeCopy() const = 0;
35
36 virtual const std::type_info &type() const = 0;
37
38 virtual bool match(BaseObjectMemberFunction *) const = 0;
39
40 virtual DataObject* castToDataObject() const = 0;
41 virtual ValidDataObject* castToValidDataObject() const = 0;
42 virtual void* castToVoid() const = 0;
43 };
44
52 template <class CallerClass>
53 class ObjectMemberFunction final : public BaseObjectMemberFunction {
54 public:
56 typedef StatusCode (CallerClass::*MemberFunctionType)();
57
59 ~ObjectMemberFunction() override = default;
60
63 StatusCode operator() () const override {
64 return m_memberFunction? (m_instance->*m_memberFunction)()
65 : StatusCode::SUCCESS;
66 }
67
70 BaseObjectMemberFunction *makeCopy() const override {
71 return new ObjectMemberFunction<CallerClass>(m_instance,m_memberFunction);
72 }
73
75 const std::type_info &type() const override { return typeid(CallerClass); }
76
78 bool match(BaseObjectMemberFunction *bmf) const override {
79 if ( bmf == (BaseObjectMemberFunction *)this ) return true;
80 if (type() == bmf->type()) {
81 ObjectMemberFunction * mf = dynamic_cast<ObjectMemberFunction *>(bmf);
82 return m_instance == mf->m_instance &&
83 m_memberFunction == mf->m_memberFunction;
84 }
85 return false;
86 }
87
89 DataObject* castToDataObject() const override {
90 return dynamic_cast<DataObject*>(m_instance);
91 }
92
94 ValidDataObject* castToValidDataObject() const override {
95 return dynamic_cast<ValidDataObject*>(m_instance);
96 }
97
99 void* castToVoid() const override {
100 return dynamic_cast<void*>(m_instance);
101 }
102
103 protected:
104
106 ObjectMemberFunction(CallerClass *instance, const MemberFunctionType &mf):
107 m_instance(instance),m_memberFunction(mf){}
108
110 CallerClass *m_instance;
111
113 MemberFunctionType m_memberFunction;
114
115 friend class IUpdateManagerSvc;
116 };
117
125 class BasePtrSetter {
126 public:
128 virtual ~BasePtrSetter() = default;
130 virtual void set(DataObject *) = 0;
132 virtual bool isNull() = 0;
133 };
134
135
143 class GAUDI_API IUpdateManagerSvc: virtual public IInterface {
144 private:
149 template<class ActualType>
150 class PtrSetter final : public BasePtrSetter {
151 public:
152 using dest_type = ActualType;
153 PtrSetter(dest_type *&dest):m_storage(&dest) {
154 *m_storage = nullptr;
155 }
156 void set(DataObject *obj) override {
157 *m_storage = dynamic_cast<dest_type *>(obj);
158 }
159 bool isNull() override { return *m_storage == nullptr; }
160
161 private:
163 dest_type **m_storage;
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 i_registerCondition(condition, new ObjectMemberFunction<CallerClass>(instance,mf));
185 }
186
187 template <class CallerClass, class CondType>
188 inline void registerCondition(CallerClass *instance, const std::string &condition,
189 typename ObjectMemberFunction<CallerClass>::MemberFunctionType mf,
190 CondType *&condPtrDest){
191 i_registerCondition(condition, new ObjectMemberFunction<CallerClass>(instance,mf),
192 new PtrSetter<CondType>(condPtrDest));
193 }
194
196 template <class CallerClass>
197 inline void registerCondition(CallerClass *instance, const char *condition,
198 typename ObjectMemberFunction<CallerClass>::MemberFunctionType mf = nullptr){
199 i_registerCondition(std::string(condition), new ObjectMemberFunction<CallerClass>(instance,mf));
200 }
201
205 template <class CallerClass, class ObjectClass>
206 inline void registerCondition(CallerClass *instance, ObjectClass *obj,
207 typename ObjectMemberFunction<CallerClass>::MemberFunctionType mf = nullptr){
208 i_registerCondition(dynamic_cast<void*>(obj), new ObjectMemberFunction<CallerClass>(instance,mf));
209 }
210
214 template <class CallerClass>
215 inline void unregister(CallerClass *instance) {
216 i_unregister(dynamic_cast<void*>(instance));
217 }
218
221 template <class CallerClass>
222 inline void invalidate(CallerClass *instance) {i_invalidate(dynamic_cast<void*>(instance));}
223
226 virtual bool getValidity(const std::string path, Gaudi::Time& since, Gaudi::Time &until, bool path_to_db = false) = 0;
227
231 virtual void setValidity(const std::string path,
232 const Gaudi::Time& since, const Gaudi::Time &until,
233 bool path_to_db = false) = 0;
234
236 virtual StatusCode newEvent() = 0;
240 virtual StatusCode newEvent(const Gaudi::Time &) = 0;
241
244 template <class CallerClass>
245 inline StatusCode update(CallerClass *instance){
246 return i_update(dynamic_cast<void*>(instance));
247 }
248
250 virtual void dump() = 0;
251
253 virtual void acquireLock() = 0;
255 virtual void releaseLock() = 0;
256
260 virtual void purge() = 0;
261
266 class PythonHelper;
267
268 protected:
269
270 //virtual StatusCode i_registerCondition(const std::string &condition, BaseObjectMemberFunction *mf) = 0;
271 virtual void i_registerCondition(const std::string &condition, BaseObjectMemberFunction *mf,
272 BasePtrSetter *ptr_dest = nullptr) = 0;
273 virtual void i_registerCondition(void *obj, BaseObjectMemberFunction *mf) = 0;
274 virtual StatusCode i_update(void *instance) = 0;
275 virtual void i_unregister(void *instance) = 0;
276 virtual void i_invalidate(void *instance) = 0;
277
278 friend class PythonHelper;
279 };
280 #endif // GAUDIKERNEL_IUPDATEMANAGERSVC_H
IUpdateManagerSvc::PtrSetter::PtrSetter
PtrSetter(dest_type *&dest)
Definition: IUpdateManagerSvc.h:153
BaseObjectMemberFunction::castToDataObject
virtual DataObject * castToDataObject() const =0
ObjectMemberFunction::m_memberFunction
MemberFunctionType m_memberFunction
Pointer to the member function.
Definition: IUpdateManagerSvc.h:113
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:94
BasePtrSetter
Base class to set the pointer to an object of a class derived from DataObject in a generic way...
Definition: IUpdateManagerSvc.h:125
BaseObjectMemberFunction::castToVoid
virtual void * castToVoid() const =0
ObjectMemberFunction::match
bool match(BaseObjectMemberFunction *bmf) const override
Comparison between two BaseObjectMemberFunction instances.
Definition: IUpdateManagerSvc.h:78
IUpdateManagerSvc::invalidate
void invalidate(CallerClass *instance)
Invalidate the given object in the dependency network.
Definition: IUpdateManagerSvc.h:222
IUpdateManagerSvc::PtrSetter
Templated specialization of BasePtrSetter.
Definition: IUpdateManagerSvc.h:150
IDetDataSvc
Definition: IDetDataSvc.h:20
IUpdateManagerSvc::PtrSetter::dest_type
ActualType dest_type
Definition: IUpdateManagerSvc.h:152
IUpdateManagerSvc::PtrSetter::isNull
bool isNull() override
tells if the internal pointer is nullptr.
Definition: IUpdateManagerSvc.h:159
IUpdateManagerSvc::PtrSetter::set
void set(DataObject *obj) override
sets the internal pointer to the provided data object (with a dynamic_cast).
Definition: IUpdateManagerSvc.h:156
ObjectMemberFunction::makeCopy
BaseObjectMemberFunction * makeCopy() const override
Clone method to be able to copy an ObjectMemberFunction from the BaseObjectMemberFunction interface...
Definition: IUpdateManagerSvc.h:70
IUpdateManagerSvc::unregister
void unregister(CallerClass *instance)
Generic objects can be unregistered from the UpdateManagerSvc.
Definition: IUpdateManagerSvc.h:215
BaseObjectMemberFunction::match
virtual bool match(BaseObjectMemberFunction *) const =0
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:206
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:110
IUpdateManagerSvc::registerCondition
void registerCondition(CallerClass *instance, const std::string &condition, typename ObjectMemberFunction< CallerClass >::MemberFunctionType mf, CondType *&condPtrDest)
Definition: IUpdateManagerSvc.h:188
Gaudi::Time
Based on seal::Time.
Definition: Time.h:213
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
IInterface
Definition of the basic interface.
Definition: IInterface.h:234
IUpdateManagerSvc::PythonHelper
Helper class implemented in the python dictionary to allow access from python to template member func...
gaudirun.dest
string dest
Definition: gaudirun.py:162
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:182
IUpdateManagerSvc
Interface class to the Update Manager service.
Definition: IUpdateManagerSvc.h:143
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:163
Gaudi::Utils::Histos::path
GAUDI_API std::string path(const AIDA::IBaseHistogram *aida)
get the path in THS for AIDA histogram
Definition: HistoTableFormat.cpp:191
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:14
IUpdateManagerSvc::update
StatusCode update(CallerClass *instance)
Update the given instance.
Definition: IUpdateManagerSvc.h:245
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
ObjectMemberFunction
This class is used by IUpdateManagerSvc to keep pairs made of a member function and a pointer to the ...
Definition: IUpdateManagerSvc.h:53
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:89
GaudiKernel.Configurable.purge
def purge()
Definition: Configurable.py:1501
ObjectMemberFunction::castToVoid
void * castToVoid() const override
Cast the object to void with dynamic_cast.
Definition: IUpdateManagerSvc.h:99
ObjectMemberFunction::~ObjectMemberFunction
~ObjectMemberFunction() override=default
Virtual destructor.
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:107
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
Helper functions to set/get the application return code.
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:197
ObjectMemberFunction::type
const std::type_info & type() const override
Returns the type_info of the CallerClass.
Definition: IUpdateManagerSvc.h:75
ObjectMemberFunction::operator()
StatusCode operator()() const override
Calls the member function of the object and returns the StatusCode.
Definition: IUpdateManagerSvc.h:63
BaseObjectMemberFunction
Base class of ObjectMemberFunction.
Definition: IUpdateManagerSvc.h:27
ObjectMemberFunction::MemberFunctionType
StatusCode(CallerClass::* MemberFunctionType)()
MemberFunctionType is the type for a pointer to a member function of class CallerClass.
Definition: IUpdateManagerSvc.h:56