18 #define PERSISTENCYSVC_PERSISTENCYSVC_CPP
35 #define ON_DEBUG if (UNLIKELY(outputLevel() <= MSG::DEBUG))
36 #define ON_VERBOSE if (UNLIKELY(outputLevel() <= MSG::VERBOSE))
38 #define DEBMSG ON_DEBUG debug()
39 #define VERMSG ON_VERBOSE verbose()
69 if ( 0 != pAddress ) {
70 long svc_type = pAddress->
svcType();
86 status = svc->
createObj(pAddress, pObject);
92 status = svc->
updateObj(pAddress, pObject);
98 status = svc->
createRep(pObject, pAddress);
104 status = svc->
updateRep(pAddress, pObject);
168 return (*it).second.addrCreator();
174 return (*it).second.addrCreator();
181 (*i).second.conversionSvc()->setDataProvider(
m_dataSvc).ignore();
209 if ( 0 != pConverter ) {
225 iret = (*i).second.conversionSvc()->removeConverter(clid);
226 if ( iret.isSuccess() ) {
243 if ( (*it).second.service()->name() == tn.
name() ) {
254 info() <<
"Cannot access Conversion service:" << nam <<
endmsg;
261 typedef std::vector<std::string> SvcNames;
265 return (*it).second.conversionSvc();
269 for ( SvcNames::const_iterator
i = theNames.begin();
i != theNames.end();
i++ ) {
272 long typ = svc->repSvcType();
292 if ( type == def_typ ) {
295 if ( cnv_svc != servc ) {
302 if ( 0 != cnv_svc ) {
305 std::pair<Services::iterator, bool> p =
308 info() <<
"Added successfully Conversion service:" << isvc->
name() <<
endmsg;
314 info() <<
"Cannot add Conversion service of type " << isvc->
name() <<
endmsg;
321 info() <<
"Cannot add Conversion service of type " << type <<
endmsg;
335 (*it).second.service()->release();
336 (*it).second.addrCreator()->release();
357 const std::string& ) {
374 const std::string* pars,
375 const unsigned long* ipars,
381 status = svc->
createAddress(svc_type, clid, pars, ipars, refpAddress);
388 std::string& refAddress)
395 if ( 0 != pAddress ) {
396 svc_type = pAddress->
svcType();
397 clid = pAddress->
clID();
409 refAddress += address;
417 const std::string& refAddress,
423 long new_svc_type = 0;
425 std::string address_trailer;
426 decodeAddrHdr(refAddress, new_svc_type, new_clid, address_trailer);
430 status = svc->
createAddress( new_svc_type, new_clid, address_trailer, refpAddress);
438 std::string& address)
const
442 std::stringstream stream;
443 int svctyp = service_type;
444 stream <<
"<address_header service_type=\"" << svctyp <<
"\" clid=\"" << clid <<
"\" /> ";
445 address = stream.str();
452 std::string& address_trailer)
const
458 address_trailer =
"";
461 size_t pos = address.find(
"<address_header");
462 if (std::string::npos != pos) {
464 pos = address.find(
"service_type=\"");
465 if (std::string::npos != pos) {
467 size_t end = address.find(
'"', pos);
468 if (std::string::npos != end) {
469 std::istringstream str(address.substr(pos, end-pos));
472 pos = address.find(
"clid=\"");
473 if (std::string::npos != pos) {
475 end = address.find(
'\"', pos);
476 if (std::string::npos != end) {
478 str.str(address.substr(pos, end-pos));
481 pos = address.find(
'>');
482 if (pos < (address.size()-2)) {
484 address_trailer = address.substr(pos+1);
509 refpSvc =
service(service_type);
515 const char* imp = service_type.c_str();
516 long len = service_type.length();
517 if ( ::strncasecmp(imp,
"SICB", len) == 0 )
519 else if ( ::strncasecmp(imp,
"ZEBRA", len) == 0 )
521 else if ( ::strncasecmp(imp,
"MS Access", len) == 0 )
523 else if ( ::strncasecmp(imp,
"Microsoft Access", strlen(
"Microsoft Access")) == 0 )
525 else if ( ::strncasecmp(imp,
"SQL Server", len) == 0 )
527 else if ( ::strncasecmp(imp,
"Microsoft ODBC for Oracle", len) == 0 )
529 else if ( ::strncasecmp(imp,
"Oracle ODBC", strlen(
"Oracle ODBC")) == 0 )
531 else if ( ::strncasecmp(imp,
"Oracle OCI", strlen(
"Oracle OCI")) == 0 )
533 else if ( ::strncasecmp(imp,
"MySQL", len) == 0 )
535 else if ( ::strncasecmp(imp,
"ROOT", len) == 0 )
537 else if ( ::strncasecmp(imp,
"OBJY", len) == 0 )
539 else if ( ::strncasecmp(imp,
"OBJYECTI", 7) == 0 )
541 else if ( ::strncasecmp(imp,
"POOL_ROOTKEY", 12) == 0 )
543 else if ( ::strncasecmp(imp,
"POOL_ROOTTREE", 12) == 0 )
545 else if ( ::strncasecmp(imp,
"POOL_ROOT", 9) == 0 )
547 else if ( ::strncasecmp(imp,
"POOL_MySQL", 8) == 0 )
549 else if ( ::strncasecmp(imp,
"POOL_ORACLE", 8) == 0 )
551 else if ( ::strncasecmp(imp,
"POOL_ACCESS", 8) == 0 )
553 else if ( ::strncasecmp(imp,
"POOL", 4) == 0 )
560 if ( svc->name() == service_type ) {
573 for(std::vector<std::string>::const_iterator
i=names.begin();
i != names.end();
i++) {
575 if ( itm.
name() == service_type || itm.
type() == service_type ) {
597 error() <<
"Error initializing Service base class." <<
endmsg;
SmartIF< IAddressCreator > m_addrCreator
Pointer to the IAddressCreator interface of this, for addressCreator().
SmartIF< IConversionSvc > & service(const std::string &nam)
Retrieve conversion service by name.
const long TEST_StorageType
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...
The data converters are responsible to translate data from one representation into another...
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject)=0
Create the transient representation of an object.
Invalid address information.
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
virtual StatusCode createAddress(long svc_type, const CLID &clid, const std::string *par, const unsigned long *ipar, IOpaqueAddress *&refpAddress)=0
Create a Generic address using explicit arguments to identify a single object.
virtual StatusCode setDataProvider(IDataProviderSvc *pStore)
Define transient datastore.
bool isSuccess() const
Test for a status code of SUCCESS.
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.
const long ACCESS_StorageType
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.
IAddressCreator interface definition.
virtual StatusCode setDataProvider(IDataProviderSvc *pService)=0
Set Data provider service.
bool m_enable
Flag to indicate that the service is enabled.
virtual StatusCode setConversionSvc(IConversionSvc *svc)
Set conversion service the converter is connected to.
virtual StatusCode addConverter(IConverter *pConverter)=0
Add converter object to conversion service.
virtual SmartIF< IConversionSvc > & conversionSvc() const =0
Get conversion service the converter is connected to.
StatusCode makeCall(int typ, IOpaqueAddress *&pAddress, DataObject *&pObject)
Implementation helper.
long repSvcType() const
Return default service type.
StringArrayProperty m_svcNames
Names of services to be requested from the service locator and added by default.
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)=0
Convert the transient object to the requested representation.
const long MYSQL_StorageType
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.
virtual long svcType() const =0
Retrieve service type.
virtual StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the references of an already converted object.
const long POOL_MYSQL_StorageType
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject)=0
Update the transient object from the other representation.
virtual StatusCode getService(long service_type, IConversionSvc *&refpSvc)
Retrieve conversion service identified by technology.
#define DECLARE_COMPONENT(type)
virtual StatusCode finalize()
stop the service.
virtual const std::string & name() const =0
Retrieve the name of the instance.
const long POOL_ROOTKEY_StorageType
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.
virtual void declareUpdateHandler(PropertyCallbackFunctor *pf)
set new callback for update
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.
const long POOL_ACCESS_StorageType
Helper class to parse a string of format "type/name".
virtual const CLID & clID() const =0
Retrieve class information from link.
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.
virtual long repSvcType() const =0
Retrieve the class type of the data store the converter uses.
General service interface definition.
This class is used for returning status codes from appropriate routines.
virtual StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the references of an updated transient object.
virtual StatusCode setDefaultCnvService(long type)
Set default service type.
const long POOL_ORACLE_StorageType
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.
const long ROOT_StorageType
virtual StatusCode removeConverter(const CLID &clid)
Remove converter object from conversion service (if present).
virtual StatusCode updateRep(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the converted representation of a transient object.
unsigned int CLID
Class ID definition.
virtual SmartIF< IDataProviderSvc > & dataProvider() const
Access reference to transient datastore.
const long ORACLE_StorageType
const long POOL_ROOT_StorageType
const TYPE & value() const
explicit conversion
virtual IConverter * converter(const CLID &clid)
Retrieve converter from list.
No proper converter is available to the service.
virtual StatusCode setAddressCreator(IAddressCreator *creator)=0
Set address creator facility.
const long POOL_StorageType
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".
virtual StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the created transient object.
virtual unsigned long release()=0
Release Interface instance.
virtual StatusCode setAddressCreator(IAddressCreator *creator)
Set address creator facility.
virtual StatusCode initialize()
Initialization (from CONFIGURED to INITIALIZED).
const long POOL_ROOTTREE_StorageType
const CLID & objType() const
Retrieve the class type of objects the converter produces. (DUMMY)
virtual StatusCode convertAddress(const IOpaqueAddress *pAddress, std::string &refAddress)=0
Convert an address to string form.
const std::string & type() const
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.
Templated class to add the standard messaging functionalities.
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
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.
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn't already exist.
const long SQLSERVER_StorageType
const std::string & name() const
Opaque address interface definition.
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
const long OBJY_StorageType
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
virtual ~PersistencySvc()
Standard Destructor.
const long SICB_StorageType
A DataObject is the base class of any identifiable object on any data store.
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the converted object.
static const InterfaceID & interfaceID()
Return an instance of InterfaceID identifying the interface.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
virtual StatusCode queryInterface(const InterfaceID &ti, void **pp)=0
Set the void** to the pointer to the requested interface of the instance.
SmartIF< IDataProviderSvc > m_dataSvc
Pointer to datma provider service.