00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef PERSISTENCYSVC_PERSISTENCYSVC_H
00012 #define PERSISTENCYSVC_PERSISTENCYSVC_H 1
00013
00014
00015 #include "GaudiKernel/Service.h"
00016 #include "GaudiKernel/IConversionSvc.h"
00017 #include "GaudiKernel/IPersistencySvc.h"
00018 #include "GaudiKernel/IAddressCreator.h"
00019
00020
00021 #include <map>
00022 #include <algorithm>
00023 #include <functional>
00024
00025
00026 template <class TYPE> class SvcFactory;
00027
00052 class PersistencySvc : public Service,
00053 virtual public IConversionSvc,
00054 virtual public IPersistencySvc,
00055 virtual public IAddressCreator {
00056 protected:
00057 friend class SvcFactory<PersistencySvc>;
00058 class ServiceEntry {
00059 unsigned char m_serviceType;
00060 IConversionSvc* m_service;
00061 IAddressCreator* m_addrCreator;
00062 public:
00063 ServiceEntry(unsigned char type, IConversionSvc* svc, IAddressCreator* cr) {
00064 m_serviceType = type;
00065 m_addrCreator = cr;
00066 m_service = svc;
00067 }
00068 ServiceEntry(const ServiceEntry& copy) {
00069 m_serviceType = copy.m_serviceType;
00070 m_addrCreator = copy.m_addrCreator;
00071 m_service = copy.m_service;
00072 }
00073 virtual ~ServiceEntry() {
00074 }
00075 IConversionSvc* service() {
00076 return m_service;
00077 }
00078 IAddressCreator* addrCreator() {
00079 return m_addrCreator;
00080 }
00081 unsigned char svcType() const {
00082 return m_serviceType;
00083 }
00084 };
00085 typedef std::map<unsigned char,ServiceEntry> Services;
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 public:
00101
00104
00105 virtual StatusCode initialize();
00106
00108 virtual StatusCode finalize();
00109
00111 unsigned char repSvcType() const;
00112
00114 virtual StatusCode createObj(IOpaqueAddress* pAddress, DataObject*& refpObject);
00115
00117 virtual StatusCode updateObj(IOpaqueAddress* pAddress, DataObject* pObject);
00118
00120 virtual StatusCode updateReps(IDataSelector* pSelector);
00121
00123 virtual StatusCode createReps(IDataSelector* pSelector);
00124
00126 virtual StatusCode setStore(IDataProviderSvc* pStore);
00127
00129 virtual StatusCode addConverter(IConverter* pConverter);
00130
00133 virtual StatusCode addConverter(const ICnvFactory& refFactory);
00134
00136 virtual StatusCode removeConverter(const CLID& clid);
00137
00139 virtual StatusCode connectOutput(const std::string& outputFile);
00140
00142 virtual StatusCode createAddress(const GenericLinkBase & link,
00143 const std::string& dbName,
00144 const std::string& contName,
00145 const std::string& objName,
00146 IOpaqueAddress*& refpAddress);
00147
00149 virtual StatusCode createAddress(unsigned char type,
00150 const CLID& classId,
00151 const std::string& dbName,
00152 const std::string& contName,
00153 int seqId,
00154 IOpaqueAddress*& refpAddress);
00156 virtual StatusCode setAddressCreator(IAddressCreator* creator);
00158
00161
00162 virtual StatusCode addCnvService(IConversionSvc* service);
00163
00165 virtual StatusCode removeCnvService(unsigned char type);
00166
00168 virtual StatusCode setDefaultCnvService(unsigned char type);
00169
00171 virtual StatusCode getService(unsigned char service_type, IConversionSvc*& refpSvc);
00172
00174 virtual StatusCode getService(const std::string& service_type, IConversionSvc*& refpSvc);
00176
00179
00180 StatusCode queryInterface(const IID& riid, void** ppvUnknown);
00181
00182 protected:
00184 PersistencySvc(const std::string& name, ISvcLocator* svc);
00185
00187 virtual ~PersistencySvc();
00188
00190 IConversionSvc* service(unsigned char service_type);
00191
00193 IAddressCreator* addressCreator(unsigned char service_type);
00195
00197 void svcNamesHandler( Property& theProp );
00198 StatusCode decodeSvcNames( );
00199
00201 unsigned char m_cnvDefType;
00203 IDataProviderSvc* m_dataSvc;
00205 Services m_cnvServices;
00207 IConversionSvc* m_cnvDefault;
00211 StringArrayProperty m_svcNames;
00212 std::vector<IConversionSvc*> m_knownSvc;
00213 };
00214 #endif // PERSISTENCYSVC_PERSISTENCYSVC_H