All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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"
19 
20 // STL include files
21 #include <map>
22 #include <algorithm>
23 #include <functional>
24 
49 class PersistencySvc : public extends3<Service,
50  IConversionSvc,
51  IPersistencySvc,
52  IAddressCreator> {
53 protected:
54 
55  class ServiceEntry {
60  public:
62  SmartIF<IService>& svc,
66  m_addrCreator = cr;
67  m_cnvService = cnv;
68  m_service = svc;
69  }
71  IService* svc,
72  IConversionSvc* cnv,
73  IAddressCreator* cr) {
75  m_addrCreator = cr;
76  m_cnvService = cnv;
77  m_service = svc;
78  }
79  ServiceEntry(const ServiceEntry& copy) {
83  m_service = copy.m_service;
84  }
85  virtual ~ServiceEntry() {
86  }
88  return m_service;
89  }
91  return m_cnvService;
92  }
94  return m_addrCreator;
95  }
96  long svcType() const {
97  return m_serviceType;
98  }
99  };
100  typedef std::map<long,ServiceEntry> Services;
101 /*
102  class SvcTest : public std::unary_function<ServiceEntry, bool> {
103  public:
104  SvcTest(long test) : m_test(test) {
105  }
106  virtual ~SvcTest() {
107  }
108  bool operator()( const ServiceEntry& testee ) {
109  return m_test == testee.svcType() ? true : false;
110  }
111  protected:
112  long m_test;
113  };
114 */
115 public:
116 
119  long repSvcType() const;
121 
123  const CLID& objType() const;
124 
126  virtual StatusCode createObj(IOpaqueAddress* pAddress,DataObject*& refpObject);
127 
129  virtual StatusCode fillObjRefs(IOpaqueAddress* pAddress, DataObject* pObject);
130 
132  virtual StatusCode updateObj(IOpaqueAddress* pAddress, DataObject* refpObject);
133 
135  virtual StatusCode updateObjRefs(IOpaqueAddress* pAddress, DataObject* pObject);
136 
138  virtual StatusCode createRep(DataObject* pObject, IOpaqueAddress*& refpAddress);
139 
141  virtual StatusCode fillRepRefs(IOpaqueAddress* pAddress,DataObject* pObject);
142 
144  virtual StatusCode updateRep(IOpaqueAddress* pAddress, DataObject* pObject);
145 
147  virtual StatusCode updateRepRefs(IOpaqueAddress* pAddress, DataObject* pObject);
148 
151 
153  virtual SmartIF<IDataProviderSvc>& dataProvider() const;
154 
157 
159  virtual SmartIF<IConversionSvc>& conversionSvc() const;
160 
162  virtual StatusCode setAddressCreator(IAddressCreator* creator);
163 
165  virtual SmartIF<IAddressCreator>& addressCreator() const;
166 
168  virtual StatusCode addConverter(IConverter* pConverter);
169 
171  virtual StatusCode addConverter(const CLID& clid);
172 
174  virtual IConverter* converter(const CLID& clid);
175 
177  virtual StatusCode removeConverter(const CLID& clid);
178 
180  virtual StatusCode connectOutput(const std::string& outputFile,
181  const std::string& openMode);
183  virtual StatusCode connectOutput(const std::string& outputFile);
184 
186  virtual StatusCode commitOutput(const std::string& output, bool do_commit);
187 
189  virtual StatusCode createAddress(long svc_type,
190  const CLID& clid,
191  const std::string* pars,
192  const unsigned long* ipars,
193  IOpaqueAddress*& refpAddress);
194 
196  virtual StatusCode convertAddress( const IOpaqueAddress* pAddress,
197  std::string& refAddress);
198 
200  virtual StatusCode createAddress( long svc_type,
201  const CLID& clid,
202  const std::string& refAddress,
203  IOpaqueAddress*& refpAddress);
205 
210 
212  virtual StatusCode removeCnvService(long type);
213 
215  virtual StatusCode setDefaultCnvService(long type);
216 
218  virtual StatusCode getService(long service_type, IConversionSvc*& refpSvc);
219 
221  virtual StatusCode getService(const std::string& service_type, IConversionSvc*& refpSvc);
223 
226  virtual StatusCode initialize();
228 
230  virtual StatusCode finalize();
232 
235  PersistencySvc(const std::string& name, ISvcLocator* svc);
237 
239  virtual ~PersistencySvc();
240 protected:
241 
243  SmartIF<IConversionSvc>& service(const std::string& nam);
244 
246  SmartIF<IConversionSvc>& service(long service_type);
247 
249  SmartIF<IAddressCreator>& addressCreator(long service_type);
250 
252  void encodeAddrHdr(long service_type,
253  const CLID& clid,
254  std::string& address) const;
255 
257  void decodeAddrHdr(const std::string& address,
258  long& service_type,
259  CLID& clid,
260  std::string& address_trailer) const;
261 
262 
264  StatusCode makeCall(int typ, IOpaqueAddress*& pAddress, DataObject*& pObject);
265 
267  bool enable(bool value);
269 
271  void svcNamesHandler( Property& theProp );
272 
286  bool m_enable;
287 
290 };
291 #endif // PERSISTENCYSVC_PERSISTENCYSVC_H
SmartIF< IAddressCreator > m_addrCreator
Pointer to the IAddressCreator interface of this, for addressCreator().
long svcType() const
SmartIF< IConversionSvc > & service(const std::string &nam)
Retrieve conversion service by name.
SmartIF< IConversionSvc > & conversionSvc() const
SmartIF< IAddressCreator > & addrCreator() const
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject)
Implementation of IConverter: Update the transient object from the other representation.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:26
The data converters are responsible to translate data from one representation into another...
Definition: IConverter.h:57
long m_cnvDefType
Default service type.
virtual StatusCode setDataProvider(IDataProviderSvc *pStore)
Define transient datastore.
virtual StatusCode convertAddress(const IOpaqueAddress *pAddress, std::string &refAddress)
Convert an address to string form.
virtual StatusCode connectOutput(const std::string &outputFile, const std::string &openMode)
Connect the output file to the service with open mode.
virtual StatusCode createAddress(long svc_type, const CLID &clid, const std::string *pars, const unsigned long *ipars, IOpaqueAddress *&refpAddress)
Create a Generic address using explicit arguments to identify a single object.
virtual StatusCode initialize()
Initialize the service.
virtual StatusCode addConverter(IConverter *pConverter)
Add converter object to conversion service.
virtual StatusCode addCnvService(IConversionSvc *service)
Add a new Service.
virtual StatusCode removeCnvService(long type)
Remove a Service.
SmartIF< IService > & service() const
IAddressCreator interface definition.
bool m_enable
Flag to indicate that the service is enabled.
virtual StatusCode setConversionSvc(IConversionSvc *svc)
Set conversion service the converter is connected to.
StatusCode makeCall(int typ, IOpaqueAddress *&pAddress, DataObject *&pObject)
Implementation helper.
long repSvcType() const
Return default service type.
SmartIF< IService > m_service
StringArrayProperty m_svcNames
Names of services to be requested from the service locator and added by default.
virtual StatusCode commitOutput(const std::string &output, bool do_commit)
Commit pending output.
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)
Implementation of IConverter: Resolve the references of the converted object.
Data provider interface definition.
PersistencySvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
Base class used to extend a class implementing other interfaces.
Definition: extends.h:140
virtual StatusCode getService(long service_type, IConversionSvc *&refpSvc)
Retrieve conversion service identified by technology.
virtual StatusCode finalize()
stop the service.
ServiceEntry(long type, SmartIF< IService > &svc, SmartIF< IConversionSvc > &cnv, SmartIF< IAddressCreator > &cr)
virtual StatusCode updateRep(IOpaqueAddress *pAddress, DataObject *pObject)
Implementation of IConverter: Update the converted representation of a transient object.
virtual StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)
Implementation of IConverter: Resolve the references of the created transient object.
bool enable(bool value)
Set enabled flag.
std::map< long, ServiceEntry > Services
virtual SmartIF< IConversionSvc > & conversionSvc() const
Get conversion service the converter is connected to.
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)
Implementation of IConverter: Convert the transient object to the requested representation.
virtual SmartIF< IAddressCreator > & addressCreator() const
Retrieve address creator facility.
string type
Definition: gaudirun.py:126
void encodeAddrHdr(long service_type, const CLID &clid, std::string &address) const
Retrieve string from storage type and clid.
void svcNamesHandler(Property &theProp)
Handlers for Service Names Property.
General service interface definition.
Definition: IService.h:19
virtual ~ServiceEntry()
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
ServiceEntry(long type, IService *svc, IConversionSvc *cnv, IAddressCreator *cr)
virtual StatusCode setDefaultCnvService(long type)
Set default service type.
SmartIF< IConversionSvc > m_cnvDefault
Default output service.
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject)
Implementation of IConverter: Create the transient representation of an object.
PersistencySvc class implementation definition.
virtual StatusCode removeConverter(const CLID &clid)
Remove converter object from conversion service (if present).
SmartIF< IConversionSvc > m_cnvService
unsigned int CLID
Class ID definition.
Definition: ClassID.h:9
virtual SmartIF< IDataProviderSvc > & dataProvider() const
Access reference to transient datastore.
virtual const std::string & name() const
Retrieve name of the service.
Definition: Service.cpp:331
virtual IConverter * converter(const CLID &clid)
Retrieve converter from list.
virtual StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)
Implementation of IConverter: Update the references of an already converted object.
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:43
virtual StatusCode setAddressCreator(IAddressCreator *creator)
Set address creator facility.
long m_serviceType
const CLID & objType() const
Retrieve the class type of objects the converter produces. (DUMMY)
virtual StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)
Implementation of IConverter: Update the references of an updated transient object.
Services m_cnvServices
List of convermsion workers.
ServiceEntry(const ServiceEntry &copy)
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.
virtual ~PersistencySvc()
Standard Destructor.
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:31
SmartIF< IDataProviderSvc > m_dataSvc
Pointer to datma provider service.