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

This class provides the interface between Athena and RootSvc. More...

#include <RootCnvSvc.h>

Inheritance diagram for Athena::RootCnvSvc:
Collaboration diagram for Athena::RootCnvSvc:

Public Member Functions

 RootCnvSvc (const std::string &name, ISvcLocator *pSvcLocator)
 Standard Service Constructor.
StatusCode initialize ()
 Gaudi Service Interface method implementations:
StatusCode finalize ()
StatusCode connectOutput (const std::string &file)
 Connect the output file to the service.
StatusCode connectOutput (const std::string &file, const std::string &mode)
 Connect the output file to the service with open mode.
StatusCode commitOutput (const std::string &output, bool do_commit)
 Commit pending output.
StatusCode createAddress (long svc_type, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress)
 Create a Generic address using explicit arguments to identify a single object.
StatusCode convertAddress (const IOpaqueAddress *pAddress, std::string &refAddress)
 Convert an address to string form.
StatusCode createAddress (long svc_type, const CLID &clid, const std::string &refAddress, IOpaqueAddress *&refpAddress)
 Convert an address in string form to object form.
StatusCode updateServiceState (IOpaqueAddress *pAddress)
 Update state of the service.

Protected Member Functions

IConverter * createConverter (long typ, const CLID &clid, const ICnvFactory *fac)
 Create new converter using factory.
RootType getType (const CLID &clid) const
RootType getType (const std::type_info &type) const
const TokenwriteObject (const std::string &key, const RootType &typeDesc, const void *pObj, ITPCnvBase *tpConverter=0)
 Write object of a given class to Root, using optional T/P converter.
ITPCnvBasegetTPConverter (const CLID &clid) const
 Get T/P converter for a transient class.

Private Member Functions

 RootCnvSvc ()
 Default constructor:
 RootCnvSvc (const RootCnvSvc &)
RootCnvSvcoperator= (const RootCnvSvc &)

Private Attributes

ServiceHandle< ::IDictLoaderSvcm_dictSvc
 ServiceHandle to the dictionary service.
ServiceHandle< ::ITPCnvSvcm_tpCnvSvc
 ServiceHandle to the T/P conversion service.
ServiceHandle< ::IRootSvcm_rootSvc
 ServiceHandle to the root service.
std::string m_treeName
 ROOT TTree name.

Detailed Description

This class provides the interface between Athena and RootSvc.

Definition at line 35 of file RootCnvSvc.h.

Constructor & Destructor Documentation

◆ RootCnvSvc() [1/3]

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

Standard Service Constructor.

Definition at line 31 of file RootCnvSvc.cxx.

31 :
32 base_class(name, pSvcLocator, ROOT_StorageType),
33 m_dictSvc("AthDictLoaderSvc", name),
34 m_tpCnvSvc("AthTPCnvSvc", name),
35 m_rootSvc("Athena::RootSvc/AthenaRootSvc", name),
36 m_treeName("CollectionTree") {
37}
ServiceHandle< ::ITPCnvSvc > m_tpCnvSvc
ServiceHandle to the T/P conversion service.
Definition RootCnvSvc.h:104
ServiceHandle< ::IDictLoaderSvc > m_dictSvc
ServiceHandle to the dictionary service.
Definition RootCnvSvc.h:102
ServiceHandle< ::IRootSvc > m_rootSvc
ServiceHandle to the root service.
Definition RootCnvSvc.h:106
std::string m_treeName
ROOT TTree name.
Definition RootCnvSvc.h:109

◆ RootCnvSvc() [2/3]

Athena::RootCnvSvc::RootCnvSvc ( )
private

Default constructor:

◆ RootCnvSvc() [3/3]

Athena::RootCnvSvc::RootCnvSvc ( const RootCnvSvc & )
private

Member Function Documentation

◆ commitOutput()

StatusCode Athena::RootCnvSvc::commitOutput ( const std::string & output,
bool do_commit )

Commit pending output.

Definition at line 83 of file RootCnvSvc.cxx.

83 {
84 return m_rootSvc->commitOutput();
85}

◆ connectOutput() [1/2]

StatusCode Athena::RootCnvSvc::connectOutput ( const std::string & file)

Connect the output file to the service.

Definition at line 78 of file RootCnvSvc.cxx.

78 {
79 return m_rootSvc->connect(file);
80}
TFile * file

◆ connectOutput() [2/2]

StatusCode Athena::RootCnvSvc::connectOutput ( const std::string & file,
const std::string & mode )

Connect the output file to the service with open mode.

Definition at line 59 of file RootCnvSvc.cxx.

59 {
60 std::string fileName = file;
61 std::string::size_type inx1 = file.find('(');
62 if (inx1 != std::string::npos) {
63 std::string::size_type inx2 = file.find(')');
64 if (inx2 == std::string::npos || inx2 != file.size() - 1) {
65 return StatusCode::FAILURE;
66 }
67 m_treeName = fileName.substr(inx1 + 1, inx2 - inx1 - 1);
68 fileName.resize(inx1);//already checked that inx1!=npos
69 }
70 if (!m_rootSvc->open(fileName, mode).isSuccess()) {
71 ATH_MSG_ERROR("Could not open-recreate file [" << file << "]");
72 return StatusCode::FAILURE;
73 }
74 return this->connectOutput(fileName);
75}
#define ATH_MSG_ERROR(x)
StatusCode connectOutput(const std::string &file)
Connect the output file to the service.

◆ convertAddress()

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

Convert an address to string form.

Definition at line 102 of file RootCnvSvc.cxx.

102 {
103 ATH_MSG_VERBOSE("::convertAddress(pAddr = " << pAddress << ", refPaddr = " << refAddress << ")");
104 return StatusCode::FAILURE;
105}
#define ATH_MSG_VERBOSE(x)

◆ createAddress() [1/2]

StatusCode Athena::RootCnvSvc::createAddress ( long svc_type,
const CLID & clid,
const std::string & refAddress,
IOpaqueAddress *& refpAddress )

Convert an address in string form to object form.

Definition at line 107 of file RootCnvSvc.cxx.

110 {
111 ATH_MSG_VERBOSE("RootCnvSvc::createAddress("
112 << "svc_type=" << svc_type << ", "
113 << "clid=" << clid << ", "
114 << "refaddr=" << refAddress << ", "
115 << "refpaddr=" << refpAddress << ")");
116
117 return StatusCode::FAILURE;
118}

◆ createAddress() [2/2]

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

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

Definition at line 87 of file RootCnvSvc.cxx.

91 {
92 ATH_MSG_VERBOSE("RootCnvSvc::createAddress("
93 << "svc_type=" << svc_type << ", "
94 << "clid=" << clid << ", "
95 << "par=" << par[0] << ", " << par[1] << " "
96 << "ip=" << ip[0] << ", " << ip[1] << " "
97 << "refpaddr=" << refpAddress << ")");
98 refpAddress = new GenericAddress(ROOT_StorageType, clid, par[0], par[1], ip[0], ip[1]);
99 return StatusCode::SUCCESS;
100}

◆ createConverter()

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

Create new converter using factory.

Definition at line 161 of file RootCnvSvc.cxx.

161 {
162 ATH_MSG_VERBOSE("createConverter typ = " << typ << ", clid = " << clid);
163 if (typ == ROOT_StorageType) {
164 return new Athena::RootCnv(clid, serviceLocator().get());
165 }
166 return ::AthCnvSvc::createConverter(typ, clid, fac);
167}
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130

◆ finalize()

StatusCode Athena::RootCnvSvc::finalize ( )

Definition at line 54 of file RootCnvSvc.cxx.

54 {
55 return ::AthCnvSvc::finalize();
56}

◆ getTPConverter()

ITPCnvBase * Athena::RootCnvSvc::getTPConverter ( const CLID & clid) const
protected

Get T/P converter for a transient class.

Definition at line 155 of file RootCnvSvc.cxx.

155 {
156 ATH_MSG_VERBOSE("RootCnvSvc::getTPConverter clid = " << clid);
157 return m_tpCnvSvc->t2p_cnv(clid);
158}

◆ getType() [1/2]

RootType Athena::RootCnvSvc::getType ( const CLID & clid) const
protected

RootType-based API Load the class (dictionary) from Root.

Definition at line 127 of file RootCnvSvc.cxx.

127 {
128 return m_dictSvc->load_type(clid);
129}

◆ getType() [2/2]

RootType Athena::RootCnvSvc::getType ( const std::type_info & type) const
protected

Definition at line 131 of file RootCnvSvc.cxx.

131 {
132 return m_dictSvc->load_type(type);
133}

◆ initialize()

StatusCode Athena::RootCnvSvc::initialize ( )

Gaudi Service Interface method implementations:

Definition at line 39 of file RootCnvSvc.cxx.

39 {
40 ATH_MSG_INFO("Initializing " << name());
41 if (!::AthCnvSvc::initialize().isSuccess()) {
42 ATH_MSG_FATAL("Cannot initialize ConversionSvc base class.");
43 return StatusCode::FAILURE;
44 }
45 // Get the Dictionary service
46 ATH_CHECK(m_dictSvc.retrieve());
47 // Get the T/P conversion service
48 ATH_CHECK(m_tpCnvSvc.retrieve());
49 // Get the Root service
50 ATH_CHECK(m_rootSvc.retrieve());
51 return StatusCode::SUCCESS;
52}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
virtual StatusCode initialize() override
Gaudi Service Implementation.

◆ operator=()

RootCnvSvc & Athena::RootCnvSvc::operator= ( const RootCnvSvc & )
private

◆ updateServiceState()

StatusCode Athena::RootCnvSvc::updateServiceState ( IOpaqueAddress * pAddress)

Update state of the service.

Definition at line 120 of file RootCnvSvc.cxx.

120 {
121 ATH_MSG_VERBOSE("RootCnvSvc::updateServiceState(paddr = " << pAddress << ")");
122 return StatusCode::FAILURE;
123}

◆ writeObject()

const Token * Athena::RootCnvSvc::writeObject ( const std::string & key,
const RootType & typeDesc,
const void * pObj,
ITPCnvBase * tpConverter = 0 )
protected

Write object of a given class to Root, using optional T/P converter.

Definition at line 136 of file RootCnvSvc.cxx.

139 {
140 const Token* token = 0;
141 Placement placement;
142 placement.setContainerName(m_treeName + "(" + key + ")");
143 placement.setTechnology(ROOT_StorageType);
144 if (tpConverter == 0) {
145 token = m_rootSvc->writeObject(placement, typeDesc, pObj);
146 } else {
147 void* pers = m_rootSvc->createObject(typeDesc);
148 tpConverter->transToPersUntyped(pObj, pers, this->msg());
149 token = m_rootSvc->writeObject(placement, typeDesc, pers);
150 m_rootSvc->destructObject(typeDesc, pers); pers = 0;
151 }
152 return token;
153}
virtual void transToPersUntyped(const void *trans, void *pers, MsgStream &msg)=0
Convert transient object representation to persistent.
Placement & setContainerName(const std::string &containerName)
Set container name.
Definition Placement.h:34
Placement & setTechnology(int technology)
Set technology type.
Definition Placement.h:38
MsgStream & msg
Definition testRead.cxx:32

Member Data Documentation

◆ m_dictSvc

ServiceHandle< ::IDictLoaderSvc> Athena::RootCnvSvc::m_dictSvc
private

ServiceHandle to the dictionary service.

Definition at line 102 of file RootCnvSvc.h.

◆ m_rootSvc

ServiceHandle< ::IRootSvc> Athena::RootCnvSvc::m_rootSvc
private

ServiceHandle to the root service.

Definition at line 106 of file RootCnvSvc.h.

◆ m_tpCnvSvc

ServiceHandle< ::ITPCnvSvc> Athena::RootCnvSvc::m_tpCnvSvc
private

ServiceHandle to the T/P conversion service.

Definition at line 104 of file RootCnvSvc.h.

◆ m_treeName

std::string Athena::RootCnvSvc::m_treeName
private

ROOT TTree name.

Definition at line 109 of file RootCnvSvc.h.


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