The Gaudi Framework  v30r3 (a5ef0a68)
PersistencySvc.h
Go to the documentation of this file.
1 // ============================================================
2 //
3 // PersistencySvc.h
4 // ------------------------------------------------------------
5 //
6 // Package : PersistencySvc
7 //
8 // Author : Markus Frank
9 //
10 // ===========================================================
11 #ifndef PERSISTENCYSVC_PERSISTENCYSVC_H
12 #define PERSISTENCYSVC_PERSISTENCYSVC_H 1
13 
14 // Framework include files
19 #include "GaudiKernel/Service.h"
20 
21 // STL include files
22 #include <algorithm>
23 #include <functional>
24 #include <map>
25 
50 class PersistencySvc : public extends<Service, IConversionSvc, IPersistencySvc, IAddressCreator>
51 {
52 protected:
53  class ServiceEntry final
54  {
59 
60  public:
62  : m_serviceType( type )
63  , m_service( std::move( svc ) )
64  , m_cnvService( std::move( cnv ) )
65  , m_addrCreator( std::move( cr ) )
66  {
67  }
69  {
70  m_serviceType = type;
71  m_addrCreator = cr;
72  m_cnvService = cnv;
73  m_service = svc;
74  }
75  ServiceEntry( const ServiceEntry& ) = default;
76 
77  SmartIF<IService>& service() const { return m_service; }
80  long svcType() const { return m_serviceType; }
81  };
83  /*
84  class SvcTest final {
85  public:
86  SvcTest(long test) : m_test(test) {
87  }
88  bool operator()( const ServiceEntry& testee ) const {
89  return m_test == testee.svcType();
90  }
91  private:
92  long m_test;
93  };
94  */
95 public:
98  long repSvcType() const override;
100 
102  const CLID& objType() const override;
103 
105  StatusCode createObj( IOpaqueAddress* pAddress, DataObject*& refpObject ) override;
106 
108  StatusCode fillObjRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
109 
111  StatusCode updateObj( IOpaqueAddress* pAddress, DataObject* refpObject ) override;
112 
114  StatusCode updateObjRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
115 
117  StatusCode createRep( DataObject* pObject, IOpaqueAddress*& refpAddress ) override;
118 
120  StatusCode fillRepRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
121 
123  StatusCode updateRep( IOpaqueAddress* pAddress, DataObject* pObject ) override;
124 
126  StatusCode updateRepRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
127 
129  StatusCode setDataProvider( IDataProviderSvc* pStore ) override;
130 
132  SmartIF<IDataProviderSvc>& dataProvider() const override;
133 
135  StatusCode setConversionSvc( IConversionSvc* svc ) override;
136 
138  SmartIF<IConversionSvc>& conversionSvc() const override;
139 
141  StatusCode setAddressCreator( IAddressCreator* creator ) override;
142 
144  SmartIF<IAddressCreator>& addressCreator() const override;
145 
147  StatusCode addConverter( IConverter* pConverter ) override;
148 
150  StatusCode addConverter( const CLID& clid ) override;
151 
153  IConverter* converter( const CLID& clid ) override;
154 
156  StatusCode removeConverter( const CLID& clid ) override;
157 
159  StatusCode connectOutput( const std::string& outputFile, const std::string& openMode ) override;
161  StatusCode connectOutput( const std::string& outputFile ) override;
162 
164  StatusCode commitOutput( const std::string& output, bool do_commit ) override;
165 
167  StatusCode createAddress( long svc_type, const CLID& clid, const std::string* pars, const unsigned long* ipars,
168  IOpaqueAddress*& refpAddress ) override;
169 
171  StatusCode convertAddress( const IOpaqueAddress* pAddress, std::string& refAddress ) override;
172 
174  StatusCode createAddress( long svc_type, const CLID& clid, const std::string& refAddress,
175  IOpaqueAddress*& refpAddress ) override;
177 
182 
184  StatusCode removeCnvService( long type ) override;
185 
187  StatusCode setDefaultCnvService( long type ) override;
188 
190  StatusCode getService( long service_type, IConversionSvc*& refpSvc ) override;
191 
193  StatusCode getService( const std::string& service_type, IConversionSvc*& refpSvc ) override;
195 
198  StatusCode initialize() override;
200 
202  StatusCode finalize() override;
204 
207  PersistencySvc( const std::string& name, ISvcLocator* svc );
209 
210 protected:
213 
215  SmartIF<IConversionSvc>& service( long service_type );
216 
218  SmartIF<IAddressCreator>& addressCreator( long service_type );
219 
221  void encodeAddrHdr( long service_type, const CLID& clid, std::string& address ) const;
222 
224  void decodeAddrHdr( const std::string& address, long& service_type, CLID& clid, std::string& address_trailer ) const;
225 
227  StatusCode makeCall( int typ, IOpaqueAddress*& pAddress, DataObject*& pObject );
228 
230  bool enable( bool value );
232 
235 
241  Services m_cnvServices;
244 
246  this, "CnvServices", {}, "Names of services to be requested from the service locator and added by default"};
247 
249  bool m_enable = true;
250 
253 };
254 #endif // PERSISTENCYSVC_PERSISTENCYSVC_H
SmartIF< IAddressCreator > m_addrCreator
Pointer to the IAddressCreator interface of this, for addressCreator().
long svcType() const
const long TEST_StorageType
Definition: ClassID.h:49
SmartIF< IConversionSvc > & conversionSvc() const
SmartIF< IAddressCreator > & addressCreator() const override
Retrieve address creator facility.
SmartIF< IAddressCreator > & addrCreator() const
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
The data converters are responsible to translate data from one representation into another...
Definition: IConverter.h:58
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:288
long m_cnvDefType
Default service type.
StatusCode initialize() override
Initialize the service.
Implementation of property with value of concrete type.
Definition: Property.h:381
StatusCode connectOutput(const std::string &outputFile, const std::string &openMode) override
Connect the output file to the service with open mode.
Gaudi::Property< std::vector< std::string > > m_svcNames
SmartIF< IService > & service() const
IAddressCreator interface definition.
bool m_enable
Flag to indicate that the service is enabled.
StatusCode setConversionSvc(IConversionSvc *svc) override
Set conversion service the converter is connected to.
STL namespace.
StatusCode makeCall(int typ, IOpaqueAddress *&pAddress, DataObject *&pObject)
Implementation helper.
SmartIF< IService > m_service
Data provider interface definition.
StatusCode removeConverter(const CLID &clid) override
Remove converter object from conversion service (if present).
PersistencySvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
StatusCode updateRep(IOpaqueAddress *pAddress, DataObject *pObject) override
Implementation of IConverter: Update the converted representation of a transient object.
StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Implementation of IConverter: Update the references of an updated transient object.
StatusCode addConverter(IConverter *pConverter) override
Add converter object to conversion service.
StatusCode convertAddress(const IOpaqueAddress *pAddress, std::string &refAddress) override
Convert an address to string form.
STL class.
StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Implementation of IConverter: Resolve the references of the created transient object.
bool enable(bool value)
Set enabled flag.
StatusCode setDataProvider(IDataProviderSvc *pStore) override
Define transient datastore.
void encodeAddrHdr(long service_type, const CLID &clid, std::string &address) const
Retrieve string from storage type and clid.
General service interface definition.
Definition: IService.h:18
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress) override
Implementation of IConverter: Convert the transient object to the requested representation.
StatusCode finalize() override
stop the service.
StatusCode getService(long service_type, IConversionSvc *&refpSvc) override
Retrieve conversion service identified by technology.
ServiceEntry(long type, IService *svc, IConversionSvc *cnv, IAddressCreator *cr)
ServiceEntry(long type, SmartIF< IService > svc, SmartIF< IConversionSvc > cnv, SmartIF< IAddressCreator > cr)
SmartIF< IConversionSvc > m_cnvDefault
Default output service.
StatusCode commitOutput(const std::string &output, bool do_commit) override
Commit pending output.
PersistencySvc class implementation definition.
StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Implementation of IConverter: Resolve the references of the converted object.
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
SmartIF< IDataProviderSvc > & dataProvider() const override
Access reference to transient datastore.
SmartIF< IConversionSvc > m_cnvService
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
StatusCode addCnvService(IConversionSvc *service) override
Add a new Service.
StatusCode removeCnvService(long type) override
Remove a Service.
StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject) override
Implementation of IConverter: Update the transient object from the other representation.
StatusCode createAddress(long svc_type, const CLID &clid, const std::string *pars, const unsigned long *ipars, IOpaqueAddress *&refpAddress) override
Create a Generic address using explicit arguments to identify a single object.
std::map< long, ServiceEntry > Services
void svcNamesHandler(Gaudi::Details::PropertyBase &theProp)
Handlers for Service Names Property.
long m_serviceType
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject) override
Implementation of IConverter: Create the transient representation of an object.
Services m_cnvServices
List of convermsion workers.
StatusCode setAddressCreator(IAddressCreator *creator) override
Set address creator facility.
void decodeAddrHdr(const std::string &address, long &service_type, CLID &clid, std::string &address_trailer) const
Retrieve storage type and clid from address header of string.
SmartIF< IAddressCreator > m_addrCreator
Opaque address interface definition.
StatusCode setDefaultCnvService(long type) override
Set default service type.
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
const CLID & objType() const override
Retrieve the class type of objects the converter produces. (DUMMY)
StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Implementation of IConverter: Update the references of an already converted object.
long repSvcType() const override
Return default service type.
SmartIF< IDataProviderSvc > m_dataSvc
Pointer to datma provider service.
IConverter * converter(const CLID &clid) override
Retrieve converter from list.