ATLAS Offline Software
Loading...
Searching...
No Matches
Athena::NtupleCnvSvc Class Reference

#include <NtupleCnvSvc.h>

Inheritance diagram for Athena::NtupleCnvSvc:
Collaboration diagram for Athena::NtupleCnvSvc:

Public Member Functions

 NtupleCnvSvc (const std::string &name, ISvcLocator *pSvcLocator)
 Constructor with parameters:
virtual ~NtupleCnvSvc ()
 Destructor:
virtual StatusCode initialize ()
 Gaudi Service Implementation.
virtual StatusCode finalize ()
virtual StatusCode updateServiceState (IOpaqueAddress *pAddress)
 IConversionSvc and IConverter interfaces
virtual StatusCode createObj (IOpaqueAddress *pAddress, DataObject *&refpObject)
 Implementation of IConverter: Create the transient representation of an object from persistent state.
virtual StatusCode createRep (DataObject *pObject, IOpaqueAddress *&refpAddress)
 Implementation of IConverter: Convert the transient object to the requested representation.
virtual StatusCode fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Implementation of IConverter: Resolve the references of the converted object.
virtual StatusCode connectOutput (const std::string &outputConnectionSpec, const std::string &openMode)
 Connect the output connection specification to the service with open mode.
virtual StatusCode connectOutput (const std::string &outputConnectionSpec)
 Connect the output connection specification to the service with open mode.
virtual StatusCode commitOutput (const std::string &outputConnectionSpec, bool doCommit)
 Commit pending output.
virtual StatusCode createAddress (long svcType, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress)
 IAddressCreator interfaces
virtual StatusCode convertAddress (const IOpaqueAddress *pAddress, std::string &refAddress)
 Convert address to string form.
virtual StatusCode createAddress (long svcType, const CLID &clid, const std::string &refAddress, IOpaqueAddress *&refpAddress)
 Create address from string form.

Protected Member Functions

virtual IConverter * createConverter (long typ, const CLID &clid, const ICnvFactory *fac)
 Create new Converter using factory (override AthCnvSvc::createConverter)

Private Member Functions

 NtupleCnvSvc ()
 Default constructor:

Detailed Description

Definition at line 29 of file NtupleCnvSvc.h.

Constructor & Destructor Documentation

◆ NtupleCnvSvc() [1/2]

Athena::NtupleCnvSvc::NtupleCnvSvc ( const std::string & name,
ISvcLocator * pSvcLocator )

Constructor with parameters:

Definition at line 35 of file NtupleCnvSvc.cxx.

36 :
37 base_class( name, pSvcLocator, ROOT_StorageType )
38{
39}

◆ ~NtupleCnvSvc()

Athena::NtupleCnvSvc::~NtupleCnvSvc ( )
virtual

Destructor:

Definition at line 43 of file NtupleCnvSvc.cxx.

44{}

◆ NtupleCnvSvc() [2/2]

Athena::NtupleCnvSvc::NtupleCnvSvc ( )
private

Default constructor:

Member Function Documentation

◆ commitOutput()

StatusCode Athena::NtupleCnvSvc::commitOutput ( const std::string & outputConnectionSpec,
bool doCommit )
virtual

Commit pending output.

Definition at line 172 of file NtupleCnvSvc.cxx.

174{
175 ATH_MSG_DEBUG("::commitOutput(" << outputConnectionSpec
176 << ", " << doCommit << ")...");
177 return StatusCode::SUCCESS;
178}
#define ATH_MSG_DEBUG(x)

◆ connectOutput() [1/2]

StatusCode Athena::NtupleCnvSvc::connectOutput ( const std::string & outputConnectionSpec)
virtual

Connect the output connection specification to the service with open mode.

Parameters
outputConnectionSpec[IN] the name of the output connection specification as string.

Definition at line 158 of file NtupleCnvSvc.cxx.

159{
160 ATH_MSG_DEBUG("::connectOutput("
161 << outputConnectionSpec << ")");
162 // std::cerr << "::connectOutput(" << outputConnectionSpec << ")...\n";
163 TFile *f = TFile::Open(outputConnectionSpec.c_str(), "recreate");
164 if (f == 0) {
165 return StatusCode::FAILURE;
166 }
167 return StatusCode::SUCCESS;
168}

◆ connectOutput() [2/2]

StatusCode Athena::NtupleCnvSvc::connectOutput ( const std::string & outputConnectionSpec,
const std::string & openMode )
virtual

Connect the output connection specification to the service with open mode.

Parameters
outputConnectionSpec[IN] the name of the output connection specification as string.
openMode[IN] the open mode of the file as string.

Definition at line 138 of file NtupleCnvSvc.cxx.

140{
141 ATH_MSG_DEBUG("::connectOutput("
142 << outputConnectionSpec << ", "
143 << openMode << ")");
144 // std::cerr << "::connectOutput(" << outputConnectionSpec << ", openmode="
145 // << openMode << ")...\n";
146 TFile *f = TFile::Open(outputConnectionSpec.c_str(), "recreate");
147 if (f == 0) {
148 return StatusCode::FAILURE;
149 }
150
151 return StatusCode::SUCCESS;
152}

◆ convertAddress()

StatusCode Athena::NtupleCnvSvc::convertAddress ( const IOpaqueAddress * pAddress,
std::string & refAddress )
virtual

Convert address to string form.

Parameters
pAddress[IN] address to be converted.
refAddress[OUT] converted string form.

Definition at line 209 of file NtupleCnvSvc.cxx.

211{
212 ATH_MSG_DEBUG("::convertAddress(" << pAddress << ", "
213 << refAddress << ")...");
214 if (pAddress) {
215 refAddress = *pAddress->par();
216 return StatusCode::SUCCESS;
217 }
218 ATH_MSG_ERROR("::convertAddress: null pointer to IOpaqueAddress !");
219 return StatusCode::FAILURE;
220}
#define ATH_MSG_ERROR(x)

◆ createAddress() [1/2]

StatusCode Athena::NtupleCnvSvc::createAddress ( long svcType,
const CLID & clid,
const std::string & refAddress,
IOpaqueAddress *& refpAddress )
virtual

Create address from string form.

Parameters
svcType[IN] service type of the address.
clid[IN] class id for the address.
refAddress[IN] string form to be converted.
refpAddress[OUT] converted address.

Definition at line 228 of file NtupleCnvSvc.cxx.

232{
233 ATH_MSG_DEBUG("::createAddress(" << svcType << ", " << clid
234 << ", " << refAddress << ", " << refpAddress
235 << ")...");
236 if (svcType != ROOT_StorageType) {
237 ATH_MSG_ERROR("::createAddress: svcType != root-type");
238 ATH_MSG_ERROR(" svcType = [" << svcType << "]");
239 ATH_MSG_ERROR(" root-type = [" << ROOT_StorageType << "]");
240 return StatusCode::FAILURE;
241 }
242 refpAddress = new GenericAddress(ROOT_StorageType, clid, refAddress);
243 return StatusCode::SUCCESS;
244}

◆ createAddress() [2/2]

StatusCode Athena::NtupleCnvSvc::createAddress ( long svcType,
const CLID & clid,
const std::string * par,
const unsigned long * ip,
IOpaqueAddress *& refpAddress )
virtual

IAddressCreator interfaces

Create a Generic address using explicit arguments to identify a single object.

Parameters
svcType[IN] service type of the address.
clid[IN] class id for the address.
par[IN] string containing the database name.
ip[IN] object identifier.
refpAddress[OUT] converted address.

Definition at line 193 of file NtupleCnvSvc.cxx.

198{
199 ATH_MSG_DEBUG("::createAddress(" << svcType << ", " << clid
200 << ", " << par << ", " << ip << ", " << refpAddress
201 << ")...");
202 return ::AthCnvSvc::createAddress(svcType, clid, par, ip, refpAddress);
203}

◆ createConverter()

IConverter * Athena::NtupleCnvSvc::createConverter ( long typ,
const CLID & clid,
const ICnvFactory * fac )
protectedvirtual

Create new Converter using factory (override AthCnvSvc::createConverter)

Definition at line 261 of file NtupleCnvSvc.cxx.

264{
265 ATH_MSG_DEBUG("::createConverter(" << typ << ", " << clid
266 << ", " << fac << ")...");
267 IConverter* cnv = new Athena::LeafCnv(clid, serviceLocator());
268 if (cnv) {
269 return cnv;
270 }
271 return AthCnvSvc::createConverter(typ, clid, fac);
272}
virtual IConverter * createConverter(long typ, const CLID &clid, const ICnvFactory *fac)
Create new Converter using factory.

◆ createObj()

StatusCode Athena::NtupleCnvSvc::createObj ( IOpaqueAddress * pAddress,
DataObject *& refpObject )
virtual

Implementation of IConverter: Create the transient representation of an object from persistent state.

Parameters
pAddress[IN] pointer to IOpaqueAddress of the representation.
refpObject[OUT] pointer to DataObject to be created.

Definition at line 83 of file NtupleCnvSvc.cxx.

84{
85 ATH_MSG_DEBUG("-->createObj(" << pAddress->par()[0] << "/" << pAddress->par()[1]
86 << ", " << refpObject << ")...");
87 GenericAddress *addr = dynamic_cast<GenericAddress*>(pAddress);
88 if (!addr) {
89 ATH_MSG_DEBUG(pAddress->par()[0] << "/" << pAddress->par()[1]
90 << " is NOT a GenericAddress!");
91 return StatusCode::FAILURE;
92 }
93 ATH_MSG_DEBUG(" par: " << pAddress->par()[0] << "/" << pAddress->par()[1]
94 << endmsg <<
95 " ipar: " << *pAddress->ipar());
96 return AthCnvSvc::createObj(pAddress, refpObject);
97}
#define endmsg
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject) override
Implementation of IConverter: Create the transient representation of an object.

◆ createRep()

StatusCode Athena::NtupleCnvSvc::createRep ( DataObject * pObject,
IOpaqueAddress *& refpAddress )
virtual

Implementation of IConverter: Convert the transient object to the requested representation.

Parameters
pObject[IN] pointer to DataObject.
refpAddress[OUT] pointer to IOpaqueAddress of the representation to be created.

Definition at line 105 of file NtupleCnvSvc.cxx.

106{
107 ATH_MSG_DEBUG("::createRep(" << refpAddress << ", " << pObject << ")...");
108 //std::cerr << "::NCS::createRep(" << this->name() << ", " << pObject << ")...\n";
109 if (0==pObject) {
110 ATH_MSG_ERROR("::createRep: received null ptr to DataObject");
111 return StatusCode::FAILURE;
112 }
113 return ::AthCnvSvc::createRep(pObject, refpAddress);
114}

◆ fillRepRefs()

StatusCode Athena::NtupleCnvSvc::fillRepRefs ( IOpaqueAddress * pAddress,
DataObject * pObject )
virtual

Implementation of IConverter: Resolve the references of the converted object.

Parameters
pAddress[IN] pointer to IOpaqueAddress of the representation to be resolved.
pObject[IN] pointer to DataObject to be created.

Definition at line 122 of file NtupleCnvSvc.cxx.

123{
124 ATH_MSG_DEBUG("::fillRepRefs(" << pAddress << ", " << pObject << ")...");
125 if (0==pAddress || 0==pObject) {
126 ATH_MSG_ERROR("::fillRepRefs: null ptr received! (paddr=" << pAddress
127 << ", pobj=" << pObject << ")");
128 return StatusCode::FAILURE;
129 }
130 return ::AthCnvSvc::fillRepRefs(pAddress, pObject);
131}

◆ finalize()

StatusCode Athena::NtupleCnvSvc::finalize ( )
virtual

Definition at line 57 of file NtupleCnvSvc.cxx.

58{
59 ATH_MSG_DEBUG ("Finalizing " << name() << "...");
60
61 return AthCnvSvc::finalize();
62}
virtual StatusCode finalize() override

◆ initialize()

StatusCode Athena::NtupleCnvSvc::initialize ( )
virtual

Gaudi Service Implementation.

Definition at line 49 of file NtupleCnvSvc.cxx.

50{
51 ATH_MSG_DEBUG ("Initializing " << name() << "...");
52
53 return AthCnvSvc::initialize();
54}
virtual StatusCode initialize() override
Gaudi Service Implementation.

◆ updateServiceState()

StatusCode Athena::NtupleCnvSvc::updateServiceState ( IOpaqueAddress * pAddress)
virtual

IConversionSvc and IConverter interfaces

update the service state (well, just check the IOpaqueAddress is in fact a GenericAddress )

Definition at line 67 of file NtupleCnvSvc.cxx.

68{
69 ATH_MSG_DEBUG("updateServiceState(" << pAddress << ")...");
70 if (pAddress) {
71 return dynamic_cast<GenericAddress*>(pAddress)
72 ? StatusCode::SUCCESS
74 }
75 return StatusCode::FAILURE;
76}
::StatusCode StatusCode
StatusCode definition for legacy code.

The documentation for this class was generated from the following files: