| # Gaudi Framework, version v21r7p1 |

Home |  | Generated: 15 Feb 2010

# 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 extends3<Service,
    00054                                         IConversionSvc,
    00055                                         IPersistencySvc,
    00056                                         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     mutable SmartIF<IService>        m_service;
    00064     mutable SmartIF<IConversionSvc>  m_cnvService;
    00065     mutable SmartIF<IAddressCreator> m_addrCreator;
    00066   public:
    00067     ServiceEntry( long type,
    00068         SmartIF<IService>& svc,
    00069         SmartIF<IConversionSvc>& cnv,
    00070         SmartIF<IAddressCreator>& cr)  {
    00071       m_serviceType  = type;
    00072       m_addrCreator  = cr;
    00073       m_cnvService   = cnv;
    00074       m_service      = svc;
    00075     }
    00076     ServiceEntry( long type,
    00077         IService* svc,
    00078         IConversionSvc* cnv,
    00079         IAddressCreator* cr)  {
    00080       m_serviceType  = type;
    00081       m_addrCreator  = cr;
    00082       m_cnvService   = cnv;
    00083       m_service      = svc;
    00084     }
    00085     ServiceEntry(const ServiceEntry& copy)  {
    00086       m_serviceType  = copy.m_serviceType;
    00087       m_addrCreator  = copy.m_addrCreator;
    00088       m_cnvService   = copy.m_cnvService;
    00089       m_service      = copy.m_service;
    00090     }
    00091     virtual ~ServiceEntry()  {
    00092     }
    00093     SmartIF<IService>&           service()   const   {
    00094       return m_service;
    00095     }
    00096     SmartIF<IConversionSvc>&     conversionSvc()  const    {
    00097       return m_cnvService;
    00098     }
    00099     SmartIF<IAddressCreator>&    addrCreator()  const    {
    00100       return m_addrCreator;
    00101     }
    00102     long svcType()  const {
    00103       return m_serviceType;
    00104     }
    00105   };
    00106   typedef std::map<long,ServiceEntry> Services;
    00107 /*
    00108   class SvcTest : public std::unary_function<ServiceEntry, bool>   {
    00109   public:
    00110     SvcTest(long test) : m_test(test)    {
    00111     }
    00112     virtual ~SvcTest()    {
    00113     }
    00114     bool operator()( const ServiceEntry& testee )  {
    00115         return m_test == testee.svcType() ? true : false;
    00116     }
    00117   protected:
    00118        long m_test;
    00119   };
    00120 */
    00121 public:
    00122
    00125
    00126   long repSvcType() const;
    00127
    00129   const CLID& objType() const;
    00130
    00132   virtual StatusCode createObj(IOpaqueAddress* pAddress,DataObject*& refpObject);
    00133
    00135   virtual StatusCode fillObjRefs(IOpaqueAddress* pAddress, DataObject* pObject);
    00136
    00138   virtual StatusCode updateObj(IOpaqueAddress* pAddress, DataObject* refpObject);
    00139
    00141   virtual StatusCode updateObjRefs(IOpaqueAddress* pAddress, DataObject* pObject);
    00142
    00144   virtual StatusCode createRep(DataObject* pObject, IOpaqueAddress*& refpAddress);
    00145
    00147   virtual StatusCode fillRepRefs(IOpaqueAddress* pAddress,DataObject* pObject);
    00148
    00150   virtual StatusCode updateRep(IOpaqueAddress* pAddress, DataObject* pObject);
    00151
    00153   virtual StatusCode updateRepRefs(IOpaqueAddress* pAddress, DataObject* pObject);
    00154
    00156   virtual StatusCode setDataProvider(IDataProviderSvc* pStore);
    00157
    00159   virtual SmartIF<IDataProviderSvc>& dataProvider()    const;
    00160
    00162   virtual StatusCode setConversionSvc(IConversionSvc* svc);
    00163
    00165   virtual SmartIF<IConversionSvc>& conversionSvc()    const;
    00166
    00168   virtual StatusCode setAddressCreator(IAddressCreator* creator);
    00169
    00171   virtual SmartIF<IAddressCreator>& addressCreator()   const;
    00172
    00174   virtual StatusCode addConverter(IConverter* pConverter);
    00175
    00177   virtual StatusCode addConverter(const CLID& clid);
    00178
    00180   virtual IConverter* converter(const CLID& clid);
    00181
    00183   virtual StatusCode removeConverter(const CLID& clid);
    00184
    00186   virtual StatusCode connectOutput(const std::string& outputFile,
    00187                                    const std::string& openMode);
    00189   virtual StatusCode connectOutput(const std::string& outputFile);
    00190
    00192   virtual StatusCode commitOutput(const std::string& output, bool do_commit);
    00193
    00195   virtual StatusCode createAddress(long svc_type,
    00196                                    const CLID& clid,
    00197                                    const std::string* pars,
    00198                                    const unsigned long* ipars,
    00199                                    IOpaqueAddress*& refpAddress);
    00200
    00202   virtual StatusCode convertAddress( const IOpaqueAddress* pAddress,
    00203                                      std::string& refAddress);
    00204
    00206   virtual StatusCode createAddress( long svc_type,
    00207                                     const CLID& clid,
    00208                                     const std::string& refAddress,
    00209                                     IOpaqueAddress*& refpAddress);
    00211
    00214
    00215   virtual StatusCode addCnvService(IConversionSvc* service);
    00216
    00218   virtual StatusCode removeCnvService(long type);
    00219
    00221   virtual StatusCode setDefaultCnvService(long type);
    00222
    00224   virtual StatusCode getService(long service_type, IConversionSvc*& refpSvc);
    00225
    00227   virtual StatusCode getService(const std::string& service_type, IConversionSvc*& refpSvc);
    00229
    00232
    00233   virtual StatusCode initialize();
    00234
    00236   virtual StatusCode finalize();
    00238
    00241
    00242   PersistencySvc(const std::string& name, ISvcLocator* svc);
    00243
    00245   virtual ~PersistencySvc();
    00246 protected:
    00247
    00249   SmartIF<IConversionSvc>& service(const std::string& nam);
    00250
    00252   SmartIF<IConversionSvc>& service(long service_type);
    00253
    00255   SmartIF<IAddressCreator>& addressCreator(long service_type);
    00256
    00258   void encodeAddrHdr(long service_type,
    00259                      const CLID& clid,
    00260                      std::string& address) const;
    00261
    00263   void decodeAddrHdr(const std::string& address,
    00264                      long& service_type,
    00265                      CLID& clid,
    00266                      std::string& address_trailer) const;
    00267
    00268
    00270   StatusCode makeCall(int typ, IOpaqueAddress*& pAddress, DataObject*& pObject);
    00271
    00273   bool enable(bool value);
    00275
    00277   void svcNamesHandler( Property& theProp );
    00278
    00280   long                m_cnvDefType;
    00282   mutable SmartIF<IDataProviderSvc>   m_dataSvc;
    00284   Services            m_cnvServices;
    00286   mutable SmartIF<IConversionSvc>     m_cnvDefault;
    00290   StringArrayProperty m_svcNames;
    00292   bool                m_enable;
    00293
    00295   mutable SmartIF<IAddressCreator> m_addrCreator;
    00296 };
    00297 #endif // PERSISTENCYSVC_PERSISTENCYSVC_H