18 #define PERSISTENCYSVC_PERSISTENCYSVC_CPP 35 #define ON_DEBUG if ( msgLevel( MSG::DEBUG ) ) 36 #define ON_VERBOSE if ( msgLvel( MSG::VERBOSE ) ) 38 #define DEBMSG ON_DEBUG debug() 39 #define VERMSG ON_VERBOSE verbose() 68 if ( !pAddress )
return Status::INVALID_ADDRESS;
70 if ( !svc )
return Status::BAD_STORAGE_TYPE;
78 status = svc->
createObj( pAddress, pObject );
84 status = svc->
updateObj( pAddress, pObject );
90 status = svc->
createRep( pObject, pAddress );
96 status = svc->
updateRep( pAddress, pObject );
173 return it->second.addrCreator();
181 i.second.conversionSvc()->setDataProvider(
m_dataSvc ).ignore();
205 if ( !pConverter )
return Status::NO_CONVERTER;
207 return svc ? svc->
addConverter( pConverter ) : Status::BAD_STORAGE_TYPE;
216 iret = i.second.conversionSvc()->removeConverter( clid );
217 if ( iret.isSuccess() ) status = iret;
230 [&]( Services::const_reference i ) {
return i.second.
service()->name() == tn.
name(); } );
233 auto svc = Service::service<IConversionSvc>( nam, true );
238 info() <<
"Cannot access Conversion service:" << nam <<
endmsg;
252 if ( svc && svc->repSvcType() ==
type )
return svc;
261 if ( !servc )
return Status::BAD_STORAGE_TYPE;
277 info() <<
"Cannot add Conversion service of type " << isvc->name() <<
endmsg;
280 info() <<
"Added successfully Conversion service:" << isvc->name() <<
endmsg;
281 iservc->setAddressCreator(
this ).ignore();
282 iservc->setDataProvider(
m_dataSvc ).ignore();
286 info() <<
"Cannot add Conversion service of type " << type <<
endmsg;
295 it->second.
service()->release();
296 it->second.addrCreator()->release();
327 refpAddress =
nullptr;
329 return svc ? svc->
createAddress( svc_type, clid, pars, ipars, refpAddress ) : Status::BAD_STORAGE_TYPE;
341 svc_type = pAddress->
svcType();
342 clid = pAddress->
clID();
354 refAddress += address;
366 long new_svc_type = 0;
369 decodeAddrHdr( refAddress, new_svc_type, new_clid, address_trailer );
371 return svc ? svc->
createAddress( new_svc_type, new_clid, address_trailer, refpAddress ) : Status::BAD_STORAGE_TYPE;
380 int svctyp = service_type;
381 stream <<
"<address_header service_type=\"" << svctyp <<
"\" clid=\"" << clid <<
"\" /> ";
382 address = stream.
str();
393 address_trailer.
clear();
396 size_t pos = address.
find(
"<address_header" );
397 if ( std::string::npos != pos ) {
399 pos = address.
find(
"service_type=\"" );
400 if ( std::string::npos != pos ) {
402 size_t end = address.
find(
'"', pos );
403 if ( std::string::npos != end ) {
406 pos = address.
find(
"clid=\"" );
407 if ( std::string::npos != pos ) {
409 end = address.
find(
'\"', pos );
410 if ( std::string::npos != end ) {
412 str.
str( address.
substr( pos, end - pos ) );
415 pos = address.
find(
'>' );
416 if ( pos < ( address.
size() - 2 ) ) {
418 address_trailer = address.
substr( pos + 1 );
443 refpSvc =
service( service_type );
450 const char* imp = service_type.
c_str();
451 long len = service_type.
length();
452 if (::strncasecmp( imp,
"SICB", len ) == 0 )
454 else if (::strncasecmp( imp,
"ZEBRA", len ) == 0 )
456 else if (::strncasecmp( imp,
"MS Access", len ) == 0 )
458 else if (::strncasecmp( imp,
"Microsoft Access", strlen(
"Microsoft Access" ) ) == 0 )
460 else if (::strncasecmp( imp,
"SQL Server", len ) == 0 )
462 else if (::strncasecmp( imp,
"Microsoft ODBC for Oracle", len ) == 0 )
464 else if (::strncasecmp( imp,
"Oracle ODBC", strlen(
"Oracle ODBC" ) ) == 0 )
466 else if (::strncasecmp( imp,
"Oracle OCI", strlen(
"Oracle OCI" ) ) == 0 )
468 else if (::strncasecmp( imp,
"MySQL", len ) == 0 )
470 else if (::strncasecmp( imp,
"ROOT", len ) == 0 )
472 else if (::strncasecmp( imp,
"OBJY", len ) == 0 )
474 else if (::strncasecmp( imp,
"OBJYECTI", 7 ) == 0 )
476 else if (::strncasecmp( imp,
"POOL_ROOTKEY", 12 ) == 0 )
478 else if (::strncasecmp( imp,
"POOL_ROOTTREE", 12 ) == 0 )
480 else if (::strncasecmp( imp,
"POOL_ROOT", 9 ) == 0 )
482 else if (::strncasecmp( imp,
"POOL_MySQL", 8 ) == 0 )
484 else if (::strncasecmp( imp,
"POOL_ORACLE", 8 ) == 0 )
486 else if (::strncasecmp( imp,
"POOL_ACCESS", 8 ) == 0 )
488 else if (::strncasecmp( imp,
"POOL", 4 ) == 0 )
495 if ( svc->name() == service_type ) {
500 auto instance = svc.get();
510 if ( itm.
name() == service_type || itm.
type() == service_type ) {
531 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.
constexpr static const auto FAILURE
SmartIF< IConversionSvc > & conversionSvc() const
SmartIF< IAddressCreator > & addressCreator() const override
Retrieve address creator facility.
StatusCode initialize() override
SmartIF< IAddressCreator > & addrCreator() const
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 const CLID & clID() const =0
Retrieve class information from link.
const std::string & name() const override
Retrieve name of the service.
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject)=0
Create the transient representation of an object.
StatusCode initialize() override
Initialize the service.
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
StatusCode connectOutput(const std::string &outputFile, const std::string &openMode) override
Connect the output file to the service with open mode.
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.
Gaudi::Property< std::vector< std::string > > m_svcNames
const long ACCESS_StorageType
IAddressCreator interface definition.
SmartIF< IService > & service() const
bool m_enable
Flag to indicate that the service is enabled.
StatusCode setConversionSvc(IConversionSvc *svc) override
Set conversion service the converter is connected to.
virtual StatusCode addConverter(IConverter *pConverter)=0
Add converter object to conversion service.
StatusCode makeCall(int typ, IOpaqueAddress *&pAddress, DataObject *&pObject)
Implementation helper.
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)=0
Convert the transient object to the requested representation.
const long MYSQL_StorageType
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.
virtual StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the references of an already converted object.
const long POOL_MYSQL_StorageType
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.
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject)=0
Update the transient object from the other representation.
StatusCode convertAddress(const IOpaqueAddress *pAddress, std::string &refAddress) override
Convert an address to string form.
const long POOL_ROOTKEY_StorageType
#define DECLARE_COMPONENT(type)
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.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
StatusCode setDataProvider(IDataProviderSvc *pStore) override
Define transient datastore.
const long POOL_ACCESS_StorageType
Helper class to parse a string of format "type/name".
void encodeAddrHdr(long service_type, const CLID &clid, std::string &address) const
Retrieve string from storage type and clid.
General service interface definition.
This class is used for returning status codes from appropriate routines.
StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress) override
Implementation of IConverter: Convert the transient object to the requested representation.
StatusCode finalize() override
stop the service.
virtual StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the references of an updated transient object.
StatusCode getService(long service_type, IConversionSvc *&refpSvc) override
Retrieve conversion service identified by technology.
const long POOL_ORACLE_StorageType
SmartIF< IConversionSvc > m_cnvDefault
Default output service.
StatusCode commitOutput(const std::string &output, bool do_commit) override
Commit pending output.
PersistencySvc class implementation definition.
const long ROOT_StorageType
StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Implementation of IConverter: Resolve the references of the converted object.
SmartIF< IConversionSvc > & conversionSvc() const override
Get conversion service the converter is connected to.
virtual long svcType() const =0
Retrieve service type.
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
SmartIF< IDataProviderSvc > & dataProvider() const override
Access reference to transient datastore.
virtual StatusCode updateRep(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the converted representation of a transient object.
unsigned int CLID
Class ID definition.
const long ORACLE_StorageType
const long POOL_ROOT_StorageType
constexpr static const auto SUCCESS
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.
const long POOL_StorageType
virtual StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the created transient object.
virtual long repSvcType() const =0
Retrieve the class type of the data store the converter uses.
void svcNamesHandler(Gaudi::Details::PropertyBase &theProp)
Handlers for Service Names Property.
const long POOL_ROOTTREE_StorageType
virtual StatusCode convertAddress(const IOpaqueAddress *pAddress, std::string &refAddress)=0
Convert an address to string form.
StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject) override
Implementation of IConverter: Create the transient representation of an object.
const std::string & type() const
const StatusCode & ignore() const
Ignore/check StatusCode.
Services m_cnvServices
List of convermsion workers.
StatusCode setAddressCreator(IAddressCreator *creator) override
Set address creator facility.
SmartIF< IFace > make_SmartIF(IFace *iface)
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.
const long SQLSERVER_StorageType
const std::string & name() const
virtual SmartIF< IConversionSvc > & conversionSvc() const =0
Get conversion service the converter is connected to.
Opaque address interface definition.
const long OBJY_StorageType
StatusCode setDefaultCnvService(long type) override
Set default service type.
const long SICB_StorageType
A DataObject is the base class of any identifiable object on any data store.
const CLID & objType() const override
Retrieve the class type of objects the converter produces. (DUMMY)
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the converted object.
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.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
SmartIF< IDataProviderSvc > m_dataSvc
Pointer to datma provider service.
IConverter * converter(const CLID &clid) override
Retrieve converter from list.