The Gaudi Framework  master (b9786168)
Loading...
Searching...
No Matches
Converter.h
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations *
3* *
4* This software is distributed under the terms of the Apache version 2 licence, *
5* copied verbatim in the file "LICENSE". *
6* *
7* In applying this licence, CERN does not waive the privileges and immunities *
8* granted to it by virtue of its status as an Intergovernmental Organization *
9* or submit itself to any jurisdiction. *
10\***********************************************************************************/
11#pragma once
12
13// generic experiment headers
20
21// Forward declarations
22class IMessageSvc;
23class IRegistry;
24
33class GAUDI_API Converter : public implements<IConverter> {
34public:
35 using Factory = Gaudi::PluginService::Factory<IConverter*( ISvcLocator* )>;
36
38 StatusCode initialize() override;
39
41 StatusCode finalize() override;
42
45
48
51
53 SmartIF<IConversionSvc>& conversionSvc() const override;
54
56 StatusCode setAddressCreator( IAddressCreator* creator ) override;
57
60
62 const CLID& objType() const override;
63
65 // MSF: Masked to generate compiler error due to interface change
66 virtual long i_repSvcType() const;
67
69 StatusCode createObj( IOpaqueAddress* pAddress, DataObject*& refpObject ) override;
70
72 StatusCode fillObjRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
73
75 StatusCode updateObj( IOpaqueAddress* pAddress, DataObject* refpObject ) override;
76
78 StatusCode updateObjRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
79
81 StatusCode createRep( DataObject* pObject, IOpaqueAddress*& refpAddress ) override;
82
84 StatusCode fillRepRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
85
87 StatusCode updateRep( IOpaqueAddress* pAddress, DataObject* pObject ) override;
88
90 StatusCode updateRepRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
91
93 Converter( long storage_type, const CLID& class_type, ISvcLocator* svc = 0 );
94
96 SmartIF<IService> service( const std::string& name, const bool createIf = true ) const;
97
98protected:
105
106private:
123};
124
125// Identified class for converters' factories
127public:
128 ConverterID( long stype, CLID clid ) : m_stype( stype ), m_clid( clid ) {}
129 inline bool operator==( const ConverterID& id ) const { return m_stype == id.m_stype && m_clid == id.m_clid; }
130
131private:
132 friend std::ostream& operator<<( std::ostream&, const ConverterID& );
135};
136
137inline std::ostream& operator<<( std::ostream& s, const ConverterID& id ) {
138 return s << "CNV_" << id.m_stype << "_" << id.m_clid;
139}
140
141// Macro to declare component factories
142#define DECLARE_CONVERTER( x ) DECLARE_COMPONENT_WITH_ID( x, ConverterID( x::storageType(), x::classID() ) )
std::ostream & operator<<(std::ostream &s, AlgsExecutionStates::State x)
Streaming of State values.
unsigned int CLID
Class ID definition.
Definition ClassID.h:16
std::ostream & operator<<(std::ostream &s, const ConverterID &id)
Definition Converter.h:137
#define GAUDI_API
Definition Kernel.h:49
StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Resolve the references of the converted object.
Definition Converter.cpp:43
StatusCode setAddressCreator(IAddressCreator *creator) override
Set address creator facility.
Definition Converter.cpp:92
SmartIF< IAddressCreator > m_addressCreator
Pointer to the address creation service interface.
Definition Converter.h:112
StatusCode initialize() override
Initialize the converter.
Definition Converter.cpp:52
SmartIF< ISvcLocator > & serviceLocator() const
Retrieve pointer to service locator.
const CLID m_classType
Class type the converter can handle.
Definition Converter.h:110
StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Update the references of an already converted object.
Definition Converter.cpp:49
SmartIF< IMessageSvc > & msgSvc() const
Retrieve pointer to message service.
SmartIF< IDataManagerSvc > & dataManager() const
Get Data Manager service.
Definition Converter.cpp:80
SmartIF< IDataProviderSvc > m_dataProvider
Pointer to data provider service.
Definition Converter.h:114
SmartIF< IDataProviderSvc > & dataProvider() const override
Get Data provider service.
Definition Converter.cpp:77
StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject) override
Update the transient object from the other representation.
Definition Converter.cpp:34
SmartIF< IConversionSvc > & conversionSvc() const override
Get conversion service the converter is connected to.
Definition Converter.cpp:89
StatusCode finalize() override
Initialize the converter.
Definition Converter.cpp:59
SmartIF< IConversionSvc > m_conversionSvc
Pointer to the connected conversion service.
Definition Converter.h:118
StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Update the references of an updated transient object.
Definition Converter.cpp:37
StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject) override
Create the transient representation of an object.
Definition Converter.cpp:28
StatusCode setDataProvider(IDataProviderSvc *svc) override
Set Data provider service.
Definition Converter.cpp:70
const CLID & objType() const override
Retrieve the class type of objects the converter produces.
Definition Converter.cpp:22
SmartIF< IMessageSvc > m_messageSvc
MessageSvc reference.
Definition Converter.h:122
StatusCode updateRep(IOpaqueAddress *pAddress, DataObject *pObject) override
Update the converted representation of a transient object.
Definition Converter.cpp:46
SmartIF< IService > service(const std::string &name, const bool createIf=true) const
Return a pointer to the service identified by name (or "type/name")
StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress) override
Convert the transient object to the requested representation.
Definition Converter.cpp:40
Converter(long storage_type, const CLID &class_type, ISvcLocator *svc=0)
Standard Constructor.
SmartIF< ISvcLocator > m_svcLocator
Service Locator reference.
Definition Converter.h:120
long m_storageType
Storage type.
Definition Converter.h:108
SmartIF< IDataManagerSvc > m_dataManager
Pointer to data manager service.
Definition Converter.h:116
StatusCode setConversionSvc(IConversionSvc *svc) override
Set conversion service the converter is connected to.
Definition Converter.cpp:83
Gaudi::PluginService::Factory< IConverter *(ISvcLocator *)> Factory
Definition Converter.h:35
virtual long i_repSvcType() const
Retrieve the class type of the data store the converter uses.
Definition Converter.cpp:25
SmartIF< IAddressCreator > & addressCreator() const override
Retrieve address creator facility.
Definition Converter.cpp:98
StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Resolve the references of the created transient object.
Definition Converter.cpp:31
bool operator==(const ConverterID &id) const
Definition Converter.h:129
ConverterID(long stype, CLID clid)
Definition Converter.h:128
A DataObject is the base class of any identifiable object on any data store.
Definition DataObject.h:37
IAddressCreator interface definition.
The data converters are responsible to translate data from one representation into another.
Definition IConverter.h:65
Data provider interface definition.
The IMessage is the interface implemented by the message service.
Definition IMessageSvc.h:34
Opaque address interface definition.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition IRegistry.h:29
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition ISvcLocator.h:42
Small smart pointer class with automatic reference counting for IInterface.
Definition SmartIF.h:28
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64