| # Gaudi Framework, version v20r4
Generated: 8 Jan 2009

# PersistencySvc.h

Go to the documentation of this file.

    00001 //      ============================================================
    00002 //
    00003 //      PersistencySvc.h
    00004 //      ------------------------------------------------------------
    00005 //
    00006 //      Package   : PersistencySvc
    00007 //
    00008 //      Author    : Markus Frank
    00009 //
    00010 //      ===========================================================
    00011 #ifndef PERSISTENCYSVC_PERSISTENCYSVC_H
    00012 #define PERSISTENCYSVC_PERSISTENCYSVC_H 1
    00013
    00014 // Framework include files
    00015 #include "GaudiKernel/Service.h"
    00016 #include "GaudiKernel/IConversionSvc.h"
    00017 #include "GaudiKernel/IPersistencySvc.h"
    00018 #include "GaudiKernel/IAddressCreator.h"
    00019
    00020 // STL include files
    00021 #include <map>
    00022 #include <algorithm>
    00023 #include <functional>
    00024
    00025 // Forward declarations
    00026 template <class TYPE> class SvcFactory;
    00027 namespace { template <class P, class S> class Factory; }
    00028
    00053 class PersistencySvc  : public Service,
    00054                         virtual public IConversionSvc,
    00055                         virtual public IPersistencySvc,
    00056                         virtual public IAddressCreator  {
    00057 protected:
    00058   friend class SvcFactory<PersistencySvc>;
    00059   friend class Factory<PersistencySvc,IService* (std::string,ISvcLocator *)>;
    00060
    00061   class ServiceEntry {
    00062     long             m_serviceType;
    00063     IService*        m_service;
    00064     IConversionSvc*  m_cnvService;
    00065     IAddressCreator* m_addrCreator;
    00066   public:
    00067     ServiceEntry( long type,
    00068                   IService* svc,
    00069                   IConversionSvc* cnv,
    00070                   IAddressCreator* cr)  {
    00071       m_serviceType  = type;
    00072       m_addrCreator  = cr;
    00073       m_cnvService   = cnv;
    00074       m_service      = svc;
    00075     }
    00076     ServiceEntry(const ServiceEntry& copy)  {
    00077       m_serviceType  = copy.m_serviceType;
    00078       m_addrCreator  = copy.m_addrCreator;
    00079       m_cnvService   = copy.m_cnvService;
    00080       m_service      = copy.m_service;
    00081     }
    00082     virtual ~ServiceEntry()  {
    00083     }
    00084     IService*           service()   const   {
    00085       return m_service;
    00086     }
    00087     IConversionSvc*     conversionSvc()  const    {
    00088       return m_cnvService;
    00089     }
    00090     IAddressCreator*    addrCreator()  const    {
    00091       return m_addrCreator;
    00092     }
    00093     long svcType()  const {
    00094       return m_serviceType;
    00095     }
    00096   };
    00097   typedef std::map<long,ServiceEntry> Services;
    00098 /*
    00099   class SvcTest : public std::unary_function<ServiceEntry, bool>   {
    00100   public:
    00101     SvcTest(long test) : m_test(test)    {
    00102     }
    00103     virtual ~SvcTest()    {
    00104     }
    00105     bool operator()( const ServiceEntry& testee )  {
    00106         return m_test == testee.svcType() ? true : false;
    00107     }
    00108   protected:
    00109        long m_test;
    00110   };
    00111 */
    00112 public:
    00113
    00116
    00117   long repSvcType() const;
    00118
    00120   const CLID& objType() const;
    00121
    00123   virtual StatusCode createObj(IOpaqueAddress* pAddress,DataObject*& refpObject);
    00124
    00126   virtual StatusCode fillObjRefs(IOpaqueAddress* pAddress, DataObject* pObject);
    00127
    00129   virtual StatusCode updateObj(IOpaqueAddress* pAddress, DataObject* refpObject);
    00130
    00132   virtual StatusCode updateObjRefs(IOpaqueAddress* pAddress, DataObject* pObject);
    00133
    00135   virtual StatusCode createRep(DataObject* pObject, IOpaqueAddress*& refpAddress);
    00136
    00138   virtual StatusCode fillRepRefs(IOpaqueAddress* pAddress,DataObject* pObject);
    00139
    00141   virtual StatusCode updateRep(IOpaqueAddress* pAddress, DataObject* pObject);
    00142
    00144   virtual StatusCode updateRepRefs(IOpaqueAddress* pAddress, DataObject* pObject);
    00145
    00147   virtual StatusCode setDataProvider(IDataProviderSvc* pStore);
    00148
    00150   virtual IDataProviderSvc* dataProvider()    const;
    00151
    00153   virtual StatusCode setConversionSvc(IConversionSvc* svc);
    00154
    00156   virtual IConversionSvc* conversionSvc()    const;
    00157
    00159   virtual StatusCode setAddressCreator(IAddressCreator* creator);
    00160
    00162   virtual IAddressCreator* addressCreator()   const;
    00163
    00165   virtual StatusCode addConverter(IConverter* pConverter);
    00166
    00168   virtual StatusCode addConverter(const CLID& clid);
    00169
    00171   virtual IConverter* converter(const CLID& clid);
    00172
    00174   virtual StatusCode removeConverter(const CLID& clid);
    00175
    00177   virtual StatusCode connectOutput(const std::string& outputFile,
    00178                                    const std::string& openMode);
    00180   virtual StatusCode connectOutput(const std::string& outputFile);
    00181
    00183   virtual StatusCode commitOutput(const std::string& output, bool do_commit);
    00184
    00186   virtual StatusCode createAddress(long svc_type,
    00187                                    const CLID& clid,
    00188                                    const std::string* pars,
    00189                                    const unsigned long* ipars,
    00190                                    IOpaqueAddress*& refpAddress);
    00191
    00193   virtual StatusCode convertAddress( const IOpaqueAddress* pAddress,
    00194                                      std::string& refAddress);
    00195
    00197   virtual StatusCode createAddress( long svc_type,
    00198                                     const CLID& clid,
    00199                                     const std::string& refAddress,
    00200                                     IOpaqueAddress*& refpAddress);
    00202
    00205
    00206   virtual StatusCode addCnvService(IConversionSvc* service);
    00207
    00209   virtual StatusCode removeCnvService(long type);
    00210
    00212   virtual StatusCode setDefaultCnvService(long type);
    00213
    00215   virtual StatusCode getService(long service_type, IConversionSvc*& refpSvc);
    00216
    00218   virtual StatusCode getService(const std::string& service_type, IConversionSvc*& refpSvc);
    00220
    00223
    00224   virtual StatusCode initialize();
    00225
    00227   virtual StatusCode finalize();
    00229
    00232
    00233   StatusCode queryInterface(const InterfaceID& riid, void** ppvUnknown);
    00235
    00237
    00238   PersistencySvc(const std::string& name, ISvcLocator* svc);
    00239
    00241   virtual ~PersistencySvc();
    00242 protected:
    00243
    00245   IConversionSvc* service(const std::string& nam);
    00246
    00248   IConversionSvc* service(long service_type);
    00249
    00251   IAddressCreator* addressCreator(long service_type);
    00252
    00254   void encodeAddrHdr(long service_type,
    00255                      const CLID& clid,
    00256                      std::string& address) const;
    00257
    00259   void decodeAddrHdr(const std::string& address,
    00260                      long& service_type,
    00261                      CLID& clid,
    00262                      std::string& address_trailer) const;
    00263
    00264
    00266   StatusCode makeCall(int typ, IOpaqueAddress*& pAddress, DataObject*& pObject);
    00267
    00269   bool enable(bool value);
    00271
    00273   void svcNamesHandler( Property& theProp );
    00274
    00276   long                m_cnvDefType;
    00278   IDataProviderSvc*   m_dataSvc;
    00280   Services            m_cnvServices;
    00282   IConversionSvc*     m_cnvDefault;
    00286   StringArrayProperty m_svcNames;
    00288   bool                m_enable;
    00289 };
    00290 #endif // PERSISTENCYSVC_PERSISTENCYSVC_H