| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
15 #include "GaudiKernel/Service.h"
16 #include "GaudiKernel/IConversionSvc.h"
17 #include "GaudiKernel/IPersistencySvc.h"
18 #include "GaudiKernel/IAddressCreator.h"
19 #include "GaudiKernel/IDataProviderSvc.h"
20
21 // STL include files
22 #include <map>
23 #include <algorithm>
24 #include <functional>
25
50 class PersistencySvc : public extends<Service,
51 IConversionSvc,
52 IPersistencySvc,
53 IAddressCreator> {
54 protected:
55
56 class ServiceEntry final {
57 long m_serviceType;
58 mutable SmartIF<IService> m_service;
59 mutable SmartIF<IConversionSvc> m_cnvService;
60 mutable SmartIF<IAddressCreator> m_addrCreator;
61 public:
62 ServiceEntry( long type,
63 SmartIF<IService> svc,
64 SmartIF<IConversionSvc> cnv,
65 SmartIF<IAddressCreator> cr)
66 : m_serviceType ( type ),
67 m_service ( std::move(svc) ),
68 m_cnvService ( std::move(cnv) ),
69 m_addrCreator ( std::move(cr) )
70 { }
71 ServiceEntry( long type,
72 IService* svc,
73 IConversionSvc* cnv,
74 IAddressCreator* cr) {
75 m_serviceType = type;
76 m_addrCreator = cr;
77 m_cnvService = cnv;
78 m_service = svc;
79 }
80 ServiceEntry(const ServiceEntry& ) = default;
81
82 SmartIF<IService>& service() const {
83 return m_service;
84 }
85 SmartIF<IConversionSvc>& conversionSvc() const {
86 return m_cnvService;
87 }
88 SmartIF<IAddressCreator>& addrCreator() const {
89 return m_addrCreator;
90 }
91 long svcType() const {
92 return m_serviceType;
93 }
94 };
95 typedef std::map<long,ServiceEntry> Services;
96 /*
97 class SvcTest : public std::unary_function<ServiceEntry, bool> {
98 public:
99 SvcTest(long test) : m_test(test) {
100 }
101 bool operator()( const ServiceEntry& testee ) {
102 return m_test == testee.svcType() ? true : false;
103 }
104 protected:
105 long m_test;
106 };
107 */
108 public:
109
112 long repSvcType() const override;
114
116 const CLID& objType() const override;
117
119 StatusCode createObj(IOpaqueAddress* pAddress,DataObject*& refpObject) override;
120
122 StatusCode fillObjRefs(IOpaqueAddress* pAddress, DataObject* pObject) override;
123
125 StatusCode updateObj(IOpaqueAddress* pAddress, DataObject* refpObject) override;
126
128 StatusCode updateObjRefs(IOpaqueAddress* pAddress, DataObject* pObject) override;
129
131 StatusCode createRep(DataObject* pObject, IOpaqueAddress*& refpAddress) override;
132
134 StatusCode fillRepRefs(IOpaqueAddress* pAddress,DataObject* pObject) override;
135
137 StatusCode updateRep(IOpaqueAddress* pAddress, DataObject* pObject) override;
138
140 StatusCode updateRepRefs(IOpaqueAddress* pAddress, DataObject* pObject) override;
141
143 StatusCode setDataProvider(IDataProviderSvc* pStore) override;
144
146 SmartIF<IDataProviderSvc>& dataProvider() const override;
147
149 StatusCode setConversionSvc(IConversionSvc* svc) override;
150
152 SmartIF<IConversionSvc>& conversionSvc() const override;
153
155 StatusCode setAddressCreator(IAddressCreator* creator) override;
156
158 SmartIF<IAddressCreator>& addressCreator() const override;
159
161 StatusCode addConverter(IConverter* pConverter) override;
162
164 StatusCode addConverter(const CLID& clid) override;
165
167 IConverter* converter(const CLID& clid) override;
168
170 StatusCode removeConverter(const CLID& clid) override;
171
173 StatusCode connectOutput(const std::string& outputFile,
174 const std::string& openMode) override;
176 StatusCode connectOutput(const std::string& outputFile) override;
177
179 StatusCode commitOutput(const std::string& output, bool do_commit) override;
180
182 StatusCode createAddress(long svc_type,
183 const CLID& clid,
184 const std::string* pars,
185 const unsigned long* ipars,
186 IOpaqueAddress*& refpAddress) override;
187
189 StatusCode convertAddress( const IOpaqueAddress* pAddress,
190 std::string& refAddress) override;
191
193 StatusCode createAddress( long svc_type,
194 const CLID& clid,
195 const std::string& refAddress,
196 IOpaqueAddress*& refpAddress) override;
198
201 StatusCode addCnvService(IConversionSvc* service) override;
203
205 StatusCode removeCnvService(long type) override;
206
208 StatusCode setDefaultCnvService(long type) override;
209
211 StatusCode getService(long service_type, IConversionSvc*& refpSvc) override;
212
214 StatusCode getService(const std::string& service_type, IConversionSvc*& refpSvc) override;
216
219 StatusCode initialize() override;
221
223 StatusCode finalize() override;
225
228 PersistencySvc(const std::string& name, ISvcLocator* svc);
230
232 ~PersistencySvc() override = default;
233 protected:
234
236 SmartIF<IConversionSvc>& service(const std::string& nam);
237
239 SmartIF<IConversionSvc>& service(long service_type);
240
242 SmartIF<IAddressCreator>& addressCreator(long service_type);
243
245 void encodeAddrHdr(long service_type,
246 const CLID& clid,
247 std::string& address) const;
248
250 void decodeAddrHdr(const std::string& address,
251 long& service_type,
252 CLID& clid,
253 std::string& address_trailer) const;
254
255
257 StatusCode makeCall(int typ, IOpaqueAddress*& pAddress, DataObject*& pObject);
258
260 bool enable(bool value);
262
264 void svcNamesHandler( Property& theProp );
265
267 long m_cnvDefType = TEST_StorageType;
269 mutable SmartIF<IDataProviderSvc> m_dataSvc;
271 Services m_cnvServices;
273 mutable SmartIF<IConversionSvc> m_cnvDefault;
277 StringArrayProperty m_svcNames;
279 bool m_enable = true;
280
282 mutable SmartIF<IAddressCreator> m_addrCreator;
283 };
284 #endif // PERSISTENCYSVC_PERSISTENCYSVC_H
PersistencySvc::m_addrCreator
SmartIF< IAddressCreator > m_addrCreator
Pointer to the IAddressCreator interface of this, for addressCreator().
Definition: PersistencySvc.h:282
PersistencySvc::addressCreator
SmartIF< IAddressCreator > & addressCreator() const override
Retrieve address creator facility.
Definition: PersistencySvc.cpp:447
PersistencySvc::ServiceEntry::svcType
long svcType() const
Definition: PersistencySvc.h:91
PersistencySvc::service
SmartIF< IConversionSvc > & service(const std::string &nam)
Retrieve conversion service by name.
Definition: PersistencySvc.cpp:222
TEST_StorageType
const long TEST_StorageType
Definition: ClassID.h:49
PersistencySvc::ServiceEntry::conversionSvc
SmartIF< IConversionSvc > & conversionSvc() const
Definition: PersistencySvc.h:85
SmartIF< IService >
PersistencySvc::ServiceEntry::addrCreator
SmartIF< IAddressCreator > & addrCreator() const
Definition: PersistencySvc.h:88
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
IConverter
The data converters are responsible to translate data from one representation into another...
Definition: IConverter.h:57
PersistencySvc::m_cnvDefType
long m_cnvDefType
Default service type.
Definition: PersistencySvc.h:267
PersistencySvc::initialize
StatusCode initialize() override
Initialize the service.
Definition: PersistencySvc.cpp:536
IConversionSvc
Definition: IConversionSvc.h:37
PersistencySvc::connectOutput
StatusCode connectOutput(const std::string &outputFile, const std::string &openMode) override
Connect the output file to the service with open mode.
Definition: PersistencySvc.cpp:307
PersistencySvc::ServiceEntry
Definition: PersistencySvc.h:56
PersistencySvc::ServiceEntry::service
SmartIF< IService > & service() const
Definition: PersistencySvc.h:82
IAddressCreator
IAddressCreator interface definition.
Definition: IAddressCreator.h:28
PersistencySvc::m_enable
bool m_enable
Flag to indicate that the service is enabled.
Definition: PersistencySvc.h:279
PersistencySvc::setConversionSvc
StatusCode setConversionSvc(IConversionSvc *svc) override
Set conversion service the converter is connected to.
Definition: PersistencySvc.cpp:183
std
STL namespace.
PersistencySvc::makeCall
StatusCode makeCall(int typ, IOpaqueAddress *&pAddress, DataObject *&pObject)
Implementation helper.
Definition: PersistencySvc.cpp:56
PersistencySvc::ServiceEntry::m_service
SmartIF< IService > m_service
Definition: PersistencySvc.h:58
PersistencySvc::m_svcNames
StringArrayProperty m_svcNames
Names of services to be requested from the service locator and added by default.
Definition: PersistencySvc.h:277
IDataProviderSvc
Data provider interface definition.
Definition: IDataProviderSvc.h:45
PersistencySvc::removeConverter
StatusCode removeConverter(const CLID &clid) override
Remove converter object from conversion service (if present).
Definition: PersistencySvc.cpp:206
PersistencySvc::PersistencySvc
PersistencySvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
Definition: PersistencySvc.cpp:567
std::map< long, ServiceEntry >
PersistencySvc::updateRep
StatusCode updateRep(IOpaqueAddress *pAddress, DataObject *pObject) override
Implementation of IConverter: Update the converted representation of a transient object.
Definition: PersistencySvc.cpp:143
PersistencySvc::updateObjRefs
StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Implementation of IConverter: Update the references of an updated transient object.
Definition: PersistencySvc.cpp:128
PersistencySvc::addConverter
StatusCode addConverter(IConverter *pConverter) override
Add converter object to conversion service.
Definition: PersistencySvc.cpp:199
PersistencySvc::convertAddress
StatusCode convertAddress(const IOpaqueAddress *pAddress, std::string &refAddress) override
Convert an address to string form.
Definition: PersistencySvc.cpp:335
std::string
STL class.
PersistencySvc::repSvcType
long repSvcType() const override
Return default service type.
Definition: PersistencySvc.cpp:296
PersistencySvc::fillObjRefs
StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Implementation of IConverter: Resolve the references of the created transient object.
Definition: PersistencySvc.cpp:118
IPersistencySvc.h
SimpleProperty< std::vector< std::string > >
Service.h
PersistencySvc::enable
bool enable(bool value)
Set enabled flag.
Definition: PersistencySvc.cpp:560
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
PersistencySvc::Services
std::map< long, ServiceEntry > Services
Definition: PersistencySvc.h:95
PersistencySvc::setDataProvider
StatusCode setDataProvider(IDataProviderSvc *pStore) override
Define transient datastore.
Definition: PersistencySvc.cpp:169
IDataProviderSvc.h
gaudirun.type
string type
Definition: gaudirun.py:151
PersistencySvc::encodeAddrHdr
void encodeAddrHdr(long service_type, const CLID &clid, std::string &address) const
Retrieve string from storage type and clid.
Definition: PersistencySvc.cpp:381
PersistencySvc::svcNamesHandler
void svcNamesHandler(Property &theProp)
Handlers for Service Names Property.
Definition: PersistencySvc.cpp:555
PersistencySvc::objType
const CLID & objType() const override
Retrieve the class type of objects the converter produces. (DUMMY)
Definition: PersistencySvc.cpp:531
IService
General service interface definition.
Definition: IService.h:18
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
PersistencySvc::createRep
StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress) override
Implementation of IConverter: Convert the transient object to the requested representation.
Definition: PersistencySvc.cpp:133
PersistencySvc::finalize
StatusCode finalize() override
stop the service.
Definition: PersistencySvc.cpp:547
PersistencySvc::getService
StatusCode getService(long service_type, IConversionSvc *&refpSvc) override
Retrieve conversion service identified by technology.
Definition: PersistencySvc.cpp:452
PersistencySvc::ServiceEntry::ServiceEntry
ServiceEntry(long type, IService *svc, IConversionSvc *cnv, IAddressCreator *cr)
Definition: PersistencySvc.h:71
PersistencySvc::ServiceEntry::ServiceEntry
ServiceEntry(long type, SmartIF< IService > svc, SmartIF< IConversionSvc > cnv, SmartIF< IAddressCreator > cr)
Definition: PersistencySvc.h:62
PersistencySvc::m_cnvDefault
SmartIF< IConversionSvc > m_cnvDefault
Default output service.
Definition: PersistencySvc.h:273
PersistencySvc::commitOutput
StatusCode commitOutput(const std::string &output, bool do_commit) override
Commit pending output.
Definition: PersistencySvc.cpp:318
dump_component_properties.value
list value
Definition: dump_component_properties.py:12
PersistencySvc
PersistencySvc class implementation definition.
Definition: PersistencySvc.h:50
PersistencySvc::fillRepRefs
StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Implementation of IConverter: Resolve the references of the converted object.
Definition: PersistencySvc.cpp:138
PersistencySvc::ServiceEntry::m_cnvService
SmartIF< IConversionSvc > m_cnvService
Definition: PersistencySvc.h:59
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
PersistencySvc::addCnvService
StatusCode addCnvService(IConversionSvc *service) override
Add a new Service.
Definition: PersistencySvc.cpp:255
PersistencySvc::removeCnvService
StatusCode removeCnvService(long type) override
Remove a Service.
Definition: PersistencySvc.cpp:286
PersistencySvc::updateObj
StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject) override
Implementation of IConverter: Update the transient object from the other representation.
Definition: PersistencySvc.cpp:123
PersistencySvc::~PersistencySvc
~PersistencySvc() override=default
Standard Destructor.
PersistencySvc::createAddress
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.
Definition: PersistencySvc.cpp:323
PersistencySvc::conversionSvc
SmartIF< IConversionSvc > & conversionSvc() const override
Get conversion service the converter is connected to.
Definition: PersistencySvc.cpp:189
Property
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:38
PersistencySvc::ServiceEntry::m_serviceType
long m_serviceType
Definition: PersistencySvc.h:57
IAddressCreator.h
IConversionSvc.h
PersistencySvc::dataProvider
SmartIF< IDataProviderSvc > & dataProvider() const override
Access reference to transient datastore.
Definition: PersistencySvc.cpp:178
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
PersistencySvc::createObj
StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject) override
Implementation of IConverter: Create the transient representation of an object.
Definition: PersistencySvc.cpp:113
PersistencySvc::m_cnvServices
Services m_cnvServices
List of convermsion workers.
Definition: PersistencySvc.h:271
PersistencySvc::setAddressCreator
StatusCode setAddressCreator(IAddressCreator *creator) override
Set address creator facility.
Definition: PersistencySvc.cpp:438
PersistencySvc::decodeAddrHdr
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.
Definition: PersistencySvc.cpp:394
PersistencySvc::ServiceEntry::m_addrCreator
SmartIF< IAddressCreator > m_addrCreator
Definition: PersistencySvc.h:60
IOpaqueAddress
Opaque address interface definition.
Definition: IOpaqueAddress.h:23
PersistencySvc::setDefaultCnvService
StatusCode setDefaultCnvService(long type) override
Set default service type.
Definition: PersistencySvc.cpp:301
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
PersistencySvc::updateRepRefs
StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Implementation of IConverter: Update the references of an already converted object.
Definition: PersistencySvc.cpp:148
PersistencySvc::m_dataSvc
SmartIF< IDataProviderSvc > m_dataSvc
Pointer to datma provider service.
Definition: PersistencySvc.h:269
PersistencySvc::converter
IConverter * converter(const CLID &clid) override
Retrieve converter from list.
Definition: PersistencySvc.cpp:217