| # Gaudi Framework, version v22r4 |

Home |  | Generated: Fri Sep 2 2011

# 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
    00028 class BaseObjectMemberFunction {
    00029 public:
    00031   virtual ~BaseObjectMemberFunction() {};
    00032
    00033   virtual StatusCode operator() () const = 0;
    00034
    00035   virtual BaseObjectMemberFunction *makeCopy() const = 0;
    00036
    00037   virtual const std::type_info &type() const = 0;
    00038
    00039   virtual bool match(BaseObjectMemberFunction *) const = 0;
    00040
    00041   virtual DataObject* castToDataObject() const = 0;
    00042   virtual ValidDataObject* castToValidDataObject() const = 0;
    00043   virtual void* castToVoid() const = 0;
    00044 };
    00045
    00053 template <class CallerClass>
    00054 class ObjectMemberFunction: public BaseObjectMemberFunction {
    00055 public:
    00057   typedef       StatusCode (CallerClass::*MemberFunctionType)();
    00058
    00060   virtual ~ObjectMemberFunction() {};
    00061
    00064   virtual StatusCode operator() () const {
    00065     return (m_memberFunction != NULL)?
    00066       (m_instance->*m_memberFunction)() :
    00067       StatusCode::SUCCESS;
    00068   }
    00069
    00072   virtual BaseObjectMemberFunction *makeCopy() const {
    00073     return new ObjectMemberFunction<CallerClass>(m_instance,m_memberFunction);
    00074   }
    00075
    00077   virtual const std::type_info &type() const { return typeid(CallerClass); }
    00078
    00080   virtual bool match(BaseObjectMemberFunction *bmf) const {
    00081     if ( bmf == (BaseObjectMemberFunction *)this ) return true;
    00082     if (type() == bmf->type()) {
    00083       ObjectMemberFunction * mf = dynamic_cast<ObjectMemberFunction *>(bmf);
    00084       return m_instance == mf->m_instance &&
    00085         m_memberFunction == mf->m_memberFunction;
    00086     }
    00087     return false;
    00088   }
    00089
    00091   virtual DataObject* castToDataObject() const {
    00092     return dynamic_cast<DataObject*>(m_instance);
    00093   }
    00094
    00096   virtual ValidDataObject* castToValidDataObject() const {
    00097     return dynamic_cast<ValidDataObject*>(m_instance);
    00098   }
    00099
    00101   virtual void* castToVoid() const {
    00102     return dynamic_cast<void*>(m_instance);
    00103   }
    00104
    00105 protected:
    00106
    00108   ObjectMemberFunction(CallerClass *instance, const MemberFunctionType &mf):
    00109     m_instance(instance),m_memberFunction(mf){}
    00110
    00112   CallerClass *m_instance;
    00113
    00115   MemberFunctionType m_memberFunction;
    00116
    00117   friend class IUpdateManagerSvc;
    00118 };
    00119
    00127 class BasePtrSetter {
    00128 public:
    00130   virtual ~BasePtrSetter() {}
    00132   virtual void set(DataObject *) = 0;
    00134   virtual bool isNull() = 0;
    00135 };
    00136
    00144 template<class ActualType>
    00145 class PtrSetter: public BasePtrSetter {
    00146 public:
    00147   typedef ActualType dest_type;
    00148
    00150   PtrSetter(dest_type *&dest):m_storage(&dest) {
    00151     *m_storage = NULL;
    00152   }
    00153
    00155   virtual ~PtrSetter() {}
    00157   virtual void set(DataObject *obj) {
    00158     *m_storage = dynamic_cast<dest_type *>(obj);
    00159   }
    00161   virtual bool isNull() { return *m_storage == NULL; }
    00162
    00163 private:
    00165   dest_type **m_storage;
    00166 };
    00167
    00175 class GAUDI_API IUpdateManagerSvc: virtual public IInterface {
    00176 public:
    00178   DeclareInterfaceID(IUpdateManagerSvc,2,0);
    00179
    00181   virtual IDataProviderSvc *dataProvider() const = 0;
    00182
    00184   virtual IDetDataSvc *detDataSvc() const = 0;
    00185
    00192   template <class CallerClass>
    00193   inline void registerCondition(CallerClass *instance, const std::string &condition = "",
    00194                                 typename ObjectMemberFunction<CallerClass>::MemberFunctionType mf = NULL){
    00195     i_registerCondition(condition, new ObjectMemberFunction<CallerClass>(instance,mf));
    00196   }
    00197
    00198   template <class CallerClass, class CondType>
    00199   inline void registerCondition(CallerClass *instance, const std::string &condition,
    00200                                 typename ObjectMemberFunction<CallerClass>::MemberFunctionType mf,
    00201                                 CondType *&condPtrDest){
    00202     i_registerCondition(condition, new ObjectMemberFunction<CallerClass>(instance,mf),
    00203                         new PtrSetter<CondType>(condPtrDest));
    00204   }
    00205
    00207   template <class CallerClass>
    00208   inline void registerCondition(CallerClass *instance, const char *condition,
    00209                                 typename ObjectMemberFunction<CallerClass>::MemberFunctionType mf = NULL){
    00210     i_registerCondition(std::string(condition), new ObjectMemberFunction<CallerClass>(instance,mf));
    00211   }
    00212
    00216   template <class CallerClass, class ObjectClass>
    00217   inline void registerCondition(CallerClass *instance, ObjectClass *obj,
    00218                                 typename ObjectMemberFunction<CallerClass>::MemberFunctionType mf = NULL){
    00219         i_registerCondition(dynamic_cast<void*>(obj), new ObjectMemberFunction<CallerClass>(instance,mf));
    00220   }
    00221
    00225   template <class CallerClass>
    00226   inline void unregister(CallerClass *instance) {
    00227     i_unregister(dynamic_cast<void*>(instance));
    00228   }
    00229
    00232   template <class CallerClass>
    00233   inline void invalidate(CallerClass *instance) {i_invalidate(dynamic_cast<void*>(instance));}
    00234
    00237   virtual bool getValidity(const std::string path, Gaudi::Time& since, Gaudi::Time &until, bool path_to_db = false) = 0;
    00238
    00242   virtual void setValidity(const std::string path,
    00243                            const Gaudi::Time& since, const Gaudi::Time &until,
    00244                            bool path_to_db = false) = 0;
    00245
    00247   virtual StatusCode newEvent() = 0;
    00251   virtual StatusCode newEvent(const Gaudi::Time &) = 0;
    00252
    00255   template <class CallerClass>
    00256   inline StatusCode update(CallerClass *instance){
    00257     return i_update(dynamic_cast<void*>(instance));
    00258   }
    00259
    00261   virtual void dump() = 0;
    00262
    00264   virtual void acquireLock() = 0;
    00266   virtual void releaseLock() = 0;
    00267
    00271   virtual void purge() = 0;
    00272
    00277   class PythonHelper;
    00278
    00279 protected:
    00280
    00281   //virtual StatusCode i_registerCondition(const std::string &condition, BaseObjectMemberFunction *mf) = 0;
    00282   virtual void       i_registerCondition(const std::string &condition, BaseObjectMemberFunction *mf,
    00283                                          BasePtrSetter *ptr_dest = NULL) = 0;
    00284   virtual void       i_registerCondition(void *obj, BaseObjectMemberFunction *mf) = 0;
    00285   virtual StatusCode i_update(void *instance) = 0;
    00286   virtual void       i_unregister(void *instance) = 0;
    00287   virtual void       i_invalidate(void *instance) = 0;
    00288
    00289   friend class PythonHelper;
    00290
    00291 private:
    00292
    00293 };
    00294 #endif // GAUDIKERNEL_IUPDATEMANAGERSVC_H

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines