| # Gaudi Framework, version v20r2
Generated: 18 Jul 2008

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

- Search for |

- File List
- File Members

# IUpdateManagerSvc.h

Go to the documentation of this file.

    00001 // $Id: IUpdateManagerSvc.h,v 1.5 2007/10/31 19:02:17 marcocle Exp $
    00002 #ifndef GAUDIKERNEL_IUPDATEMANAGERSVC_H
    00003 #define GAUDIKERNEL_IUPDATEMANAGERSVC_H 1
    00004
    00005 // Include files
    00006 // from STL
    00007 #include <string>
    00008 #include <typeinfo>
    00009
    00010 // from Gaudi
    00011 #include "GaudiKernel/IInterface.h"
    00012
    00013 // forward declarations
    00014 class DataObject;
    00015 class ValidDataObject;
    00016 class IUpdateManagerSvc;
    00017 class IDataProviderSvc;
    00018 class IDetDataSvc;
    00019 namespace Gaudi { class Time; }
    00020
    00021 static const InterfaceID IID_IUpdateManagerSvc ( "IUpdateManagerSvc", 1, 0 );
    00022
    00030 class BaseObjectMemberFunction {
    00031 public:
    00033   virtual ~BaseObjectMemberFunction() {};
    00034
    00035   virtual StatusCode operator() () const = 0;
    00036
    00037   virtual BaseObjectMemberFunction *makeCopy() const = 0;
    00038
    00039   virtual const std::type_info &type() const = 0;
    00040
    00041   virtual bool match(BaseObjectMemberFunction *) const = 0;
    00042
    00043   virtual DataObject* castToDataObject() const = 0;
    00044   virtual ValidDataObject* castToValidDataObject() const = 0;
    00045   virtual void* castToVoid() const = 0;
    00046 };
    00047
    00055 template <class CallerClass>
    00056 class ObjectMemberFunction: public BaseObjectMemberFunction {
    00057 public:
    00059   typedef       StatusCode (CallerClass::*MemberFunctionType)();
    00060
    00062   virtual ~ObjectMemberFunction() {};
    00063
    00066   virtual StatusCode operator() () const {
    00067     return (m_memberFunction != NULL)?
    00068       (m_instance->*m_memberFunction)() :
    00069       StatusCode::SUCCESS;
    00070   }
    00071
    00074   virtual BaseObjectMemberFunction *makeCopy() const {
    00075     return new ObjectMemberFunction<CallerClass>(m_instance,m_memberFunction);
    00076   }
    00077
    00079   virtual const std::type_info &type() const { return typeid(CallerClass); }
    00080
    00082   virtual bool match(BaseObjectMemberFunction *bmf) const {
    00083     if ( bmf == (BaseObjectMemberFunction *)this ) return true;
    00084     if (type() == bmf->type()) {
    00085       ObjectMemberFunction * mf = dynamic_cast<ObjectMemberFunction *>(bmf);
    00086       return m_instance == mf->m_instance &&
    00087         m_memberFunction == mf->m_memberFunction;
    00088     }
    00089     return false;
    00090   }
    00091
    00093   virtual DataObject* castToDataObject() const {
    00094     return dynamic_cast<DataObject*>(m_instance);
    00095   }
    00096
    00098   virtual ValidDataObject* castToValidDataObject() const {
    00099     return dynamic_cast<ValidDataObject*>(m_instance);
    00100   }
    00101
    00103   virtual void* castToVoid() const {
    00104     return dynamic_cast<void*>(m_instance);
    00105   }
    00106
    00107 protected:
    00108
    00110   ObjectMemberFunction(CallerClass *instance, const MemberFunctionType &mf):
    00111     m_instance(instance),m_memberFunction(mf){}
    00112
    00114   CallerClass *m_instance;
    00115
    00117   MemberFunctionType m_memberFunction;
    00118
    00119   friend class IUpdateManagerSvc;
    00120 };
    00121
    00129 class BasePtrSetter {
    00130 public:
    00132   virtual ~BasePtrSetter() {}
    00134   virtual void set(DataObject *) = 0;
    00136   virtual bool isNull() = 0;
    00137 };
    00138
    00146 template<class ActualType>
    00147 class PtrSetter: public BasePtrSetter {
    00148 public:
    00149   typedef ActualType dest_type;
    00150
    00152   PtrSetter(dest_type *&dest):m_storage(&dest) {
    00153     *m_storage = NULL;
    00154   }
    00155
    00157   virtual ~PtrSetter() {}
    00159   virtual void set(DataObject *obj) {
    00160     *m_storage = dynamic_cast<dest_type *>(obj);
    00161   }
    00163   virtual bool isNull() { return *m_storage == NULL; }
    00164
    00165 private:
    00167   dest_type **m_storage;
    00168 };
    00169
    00177 class IUpdateManagerSvc : virtual public IInterface {
    00178 public:
    00179
    00181   static const InterfaceID& interfaceID() { return IID_IUpdateManagerSvc; }
    00182
    00184   virtual IDataProviderSvc *dataProvider() const = 0;
    00185
    00187   virtual IDetDataSvc *detDataSvc() const = 0;
    00188
    00195   template <class CallerClass>
    00196   inline void registerCondition(CallerClass *instance, const std::string &condition = "",
    00197                                 typename ObjectMemberFunction<CallerClass>::MemberFunctionType mf = NULL){
    00198     i_registerCondition(condition, new ObjectMemberFunction<CallerClass>(instance,mf));
    00199   }
    00200
    00201   template <class CallerClass, class CondType>
    00202   inline void registerCondition(CallerClass *instance, const std::string &condition,
    00203                                 typename ObjectMemberFunction<CallerClass>::MemberFunctionType mf,
    00204                                 CondType *&condPtrDest){
    00205     i_registerCondition(condition, new ObjectMemberFunction<CallerClass>(instance,mf),
    00206                         new PtrSetter<CondType>(condPtrDest));
    00207   }
    00208
    00210   template <class CallerClass>
    00211   inline void registerCondition(CallerClass *instance, const char *condition,
    00212                                 typename ObjectMemberFunction<CallerClass>::MemberFunctionType mf = NULL){
    00213     i_registerCondition(std::string(condition), new ObjectMemberFunction<CallerClass>(instance,mf));
    00214   }
    00215
    00219   template <class CallerClass, class ObjectClass>
    00220   inline void registerCondition(CallerClass *instance, ObjectClass *obj,
    00221                                 typename ObjectMemberFunction<CallerClass>::MemberFunctionType mf = NULL){
    00222         i_registerCondition(dynamic_cast<void*>(obj), new ObjectMemberFunction<CallerClass>(instance,mf));
    00223   }
    00224
    00228   template <class CallerClass>
    00229   inline void unregister(CallerClass *instance) {
    00230     i_unregister(dynamic_cast<void*>(instance));
    00231   }
    00232
    00235   template <class CallerClass>
    00236   inline void invalidate(CallerClass *instance) {i_invalidate(dynamic_cast<void*>(instance));}
    00237
    00240   virtual bool getValidity(const std::string path, Gaudi::Time& since, Gaudi::Time &until, bool path_to_db = false) = 0;
    00241
    00245   virtual void setValidity(const std::string path,
    00246                            const Gaudi::Time& since, const Gaudi::Time &until,
    00247                            bool path_to_db = false) = 0;
    00248
    00250   virtual StatusCode newEvent() = 0;
    00254   virtual StatusCode newEvent(const Gaudi::Time &) = 0;
    00255
    00258   template <class CallerClass>
    00259   inline StatusCode update(CallerClass *instance){
    00260     return i_update(dynamic_cast<void*>(instance));
    00261   }
    00262
    00264   virtual void dump() = 0;
    00265
    00267   virtual void acquireLock() = 0;
    00269   virtual void releaseLock() = 0;
    00270
    00274   virtual void purge() = 0;
    00275
    00280   class PythonHelper;
    00281
    00282 protected:
    00283
    00284   //virtual StatusCode i_registerCondition(const std::string &condition, BaseObjectMemberFunction *mf) = 0;
    00285   virtual void       i_registerCondition(const std::string &condition, BaseObjectMemberFunction *mf,
    00286                                          BasePtrSetter *ptr_dest = NULL) = 0;
    00287   virtual void       i_registerCondition(void *obj, BaseObjectMemberFunction *mf) = 0;
    00288   virtual StatusCode i_update(void *instance) = 0;
    00289   virtual void       i_unregister(void *instance) = 0;
    00290   virtual void       i_invalidate(void *instance) = 0;
    00291
    00292   friend class PythonHelper;
    00293
    00294 private:
    00295
    00296 };
    00297 #endif // GAUDIKERNEL_IUPDATEMANAGERSVC_H