| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

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

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
IUpdateManagerSvc.h
Go to the documentation of this file.
1 // $Id: IUpdateManagerSvc.h,v 1.5 2007/10/31 19:02:17 marcocle Exp $
2 #ifndef GAUDIKERNEL_IUPDATEMANAGERSVC_H
3 #define GAUDIKERNEL_IUPDATEMANAGERSVC_H 1
4
5 // Include files
6 // from STL
7 #include <string>
8 #include <typeinfo>
9
10 // from Gaudi
11 #include "GaudiKernel/IInterface.h"
12
13 // forward declarations
14 class DataObject;
15 class ValidDataObject;
16 class IUpdateManagerSvc;
17 class IDataProviderSvc;
18 class IDetDataSvc;
19 namespace Gaudi { class Time; }
20
28 class BaseObjectMemberFunction {
29 public:
31 virtual ~BaseObjectMemberFunction() {};
32
33 virtual StatusCode operator() () const = 0;
34
35 virtual BaseObjectMemberFunction *makeCopy() const = 0;
36
37 virtual const std::type_info &type() const = 0;
38
39 virtual bool match(BaseObjectMemberFunction *) const = 0;
40
41 virtual DataObject* castToDataObject() const = 0;
42 virtual ValidDataObject* castToValidDataObject() const = 0;
43 virtual void* castToVoid() const = 0;
44 };
45
53 template <class CallerClass>
54 class ObjectMemberFunction: public BaseObjectMemberFunction {
55 public:
57 typedef StatusCode (CallerClass::*MemberFunctionType)();
58
60 virtual ~ObjectMemberFunction() {};
61
64 virtual StatusCode operator() () const {
65 return (m_memberFunction != NULL)?
66 (m_instance->*m_memberFunction)() :
67 StatusCode::SUCCESS;
68 }
69
72 virtual BaseObjectMemberFunction *makeCopy() const {
73 return new ObjectMemberFunction<CallerClass>(m_instance,m_memberFunction);
74 }
75
77 virtual const std::type_info &type() const { return typeid(CallerClass); }
78
80 virtual bool match(BaseObjectMemberFunction *bmf) const {
81 if ( bmf == (BaseObjectMemberFunction *)this ) return true;
82 if (type() == bmf->type()) {
83 ObjectMemberFunction * mf = dynamic_cast<ObjectMemberFunction *>(bmf);
84 return m_instance == mf->m_instance &&
85 m_memberFunction == mf->m_memberFunction;
86 }
87 return false;
88 }
89
91 virtual DataObject* castToDataObject() const {
92 return dynamic_cast<DataObject*>(m_instance);
93 }
94
96 virtual ValidDataObject* castToValidDataObject() const {
97 return dynamic_cast<ValidDataObject*>(m_instance);
98 }
99
101 virtual void* castToVoid() const {
102 return dynamic_cast<void*>(m_instance);
103 }
104
105 protected:
106
108 ObjectMemberFunction(CallerClass *instance, const MemberFunctionType &mf):
109 m_instance(instance),m_memberFunction(mf){}
110
112 CallerClass *m_instance;
113
115 MemberFunctionType m_memberFunction;
116
117 friend class IUpdateManagerSvc;
118 };
119
127 class BasePtrSetter {
128 public:
130 virtual ~BasePtrSetter() {}
132 virtual void set(DataObject *) = 0;
134 virtual bool isNull() = 0;
135 };
136
144 template<class ActualType>
145 class PtrSetter: public BasePtrSetter {
146 public:
147 typedef ActualType dest_type;
148
150 PtrSetter(dest_type *&dest):m_storage(&dest) {
151 *m_storage = NULL;
152 }
153
155 virtual ~PtrSetter() {}
157 virtual void set(DataObject *obj) {
158 *m_storage = dynamic_cast<dest_type *>(obj);
159 }
161 virtual bool isNull() { return *m_storage == NULL; }
162
163 private:
165 dest_type **m_storage;
166 };
167
175 class GAUDI_API IUpdateManagerSvc: virtual public IInterface {
176 public:
178 DeclareInterfaceID(IUpdateManagerSvc,2,0);
179
181 virtual IDataProviderSvc *dataProvider() const = 0;
182
184 virtual IDetDataSvc *detDataSvc() const = 0;
185
192 template <class CallerClass>
193 inline void registerCondition(CallerClass *instance, const std::string &condition = "",
194 typename ObjectMemberFunction<CallerClass>::MemberFunctionType mf = NULL){
195 i_registerCondition(condition, new ObjectMemberFunction<CallerClass>(instance,mf));
196 }
197
198 template <class CallerClass, class CondType>
199 inline void registerCondition(CallerClass *instance, const std::string &condition,
200 typename ObjectMemberFunction<CallerClass>::MemberFunctionType mf,
201 CondType *&condPtrDest){
202 i_registerCondition(condition, new ObjectMemberFunction<CallerClass>(instance,mf),
203 new PtrSetter<CondType>(condPtrDest));
204 }
205
207 template <class CallerClass>
208 inline void registerCondition(CallerClass *instance, const char *condition,
209 typename ObjectMemberFunction<CallerClass>::MemberFunctionType mf = NULL){
210 i_registerCondition(std::string(condition), new ObjectMemberFunction<CallerClass>(instance,mf));
211 }
212
216 template <class CallerClass, class ObjectClass>
217 inline void registerCondition(CallerClass *instance, ObjectClass *obj,
218 typename ObjectMemberFunction<CallerClass>::MemberFunctionType mf = NULL){
219 i_registerCondition(dynamic_cast<void*>(obj), new ObjectMemberFunction<CallerClass>(instance,mf));
220 }
221
225 template <class CallerClass>
226 inline void unregister(CallerClass *instance) {
227 i_unregister(dynamic_cast<void*>(instance));
228 }
229
232 template <class CallerClass>
233 inline void invalidate(CallerClass *instance) {i_invalidate(dynamic_cast<void*>(instance));}
234
237 virtual bool getValidity(const std::string path, Gaudi::Time& since, Gaudi::Time &until, bool path_to_db = false) = 0;
238
242 virtual void setValidity(const std::string path,
243 const Gaudi::Time& since, const Gaudi::Time &until,
244 bool path_to_db = false) = 0;
245
247 virtual StatusCode newEvent() = 0;
251 virtual StatusCode newEvent(const Gaudi::Time &) = 0;
252
255 template <class CallerClass>
256 inline StatusCode update(CallerClass *instance){
257 return i_update(dynamic_cast<void*>(instance));
258 }
259
261 virtual void dump() = 0;
262
264 virtual void acquireLock() = 0;
266 virtual void releaseLock() = 0;
267
271 virtual void purge() = 0;
272
277 class PythonHelper;
278
279 protected:
280
281 //virtual StatusCode i_registerCondition(const std::string &condition, BaseObjectMemberFunction *mf) = 0;
282 virtual void i_registerCondition(const std::string &condition, BaseObjectMemberFunction *mf,
283 BasePtrSetter *ptr_dest = NULL) = 0;
284 virtual void i_registerCondition(void *obj, BaseObjectMemberFunction *mf) = 0;
285 virtual StatusCode i_update(void *instance) = 0;
286 virtual void i_unregister(void *instance) = 0;
287 virtual void i_invalidate(void *instance) = 0;
288
289 friend class PythonHelper;
290
291 private:
292
293 };
294 #endif // GAUDIKERNEL_IUPDATEMANAGERSVC_H