ATLAS Offline Software
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
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. More...
 
StatusCode initialize ()
 Gaudi Service Interface method implementations: More...
 
StatusCode finalize ()
 
StatusCode connectOutput (const std::string &file)
 Connect the output file to the service. More...
 
StatusCode connectOutput (const std::string &file, const std::string &mode)
 Connect the output file to the service with open mode. More...
 
StatusCode commitOutput (const std::string &output, bool do_commit)
 Commit pending output. More...
 
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. More...
 
StatusCode convertAddress (const IOpaqueAddress *pAddress, std::string &refAddress)
 Convert an address to string form. More...
 
StatusCode createAddress (long svc_type, const CLID &clid, const std::string &refAddress, IOpaqueAddress *&refpAddress)
 Convert an address in string form to object form. More...
 
StatusCode updateServiceState (IOpaqueAddress *pAddress)
 Update state of the service. More...
 

Protected Member Functions

IConverter * createConverter (long typ, const CLID &clid, const ICnvFactory *fac)
 Create new converter using factory. More...
 
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. More...
 
ITPCnvBasegetTPConverter (const CLID &clid) const
 Get T/P converter for a transient class. More...
 

Private Member Functions

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

Private Attributes

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

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 }

◆ 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 }

◆ 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 }

◆ 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 }

◆ 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 }

◆ finalize()

StatusCode Athena::RootCnvSvc::finalize ( )

Definition at line 54 of file RootCnvSvc.cxx.

54  {
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 }

◆ 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 }

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:
Athena::RootCnvSvc::m_rootSvc
ServiceHandle< ::IRootSvc > m_rootSvc
ServiceHandle to the root service.
Definition: RootCnvSvc.h:106
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:50
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
Placement
This class holds all the necessary information to guide the writing of an object in a physical place.
Definition: Placement.h:19
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
Athena::RootCnvSvc::m_dictSvc
ServiceHandle< ::IDictLoaderSvc > m_dictSvc
ServiceHandle to the dictionary service.
Definition: RootCnvSvc.h:102
Athena::RootCnvSvc::connectOutput
StatusCode connectOutput(const std::string &file)
Connect the output file to the service.
Definition: RootCnvSvc.cxx:78
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
Placement::setContainerName
Placement & setContainerName(const std::string &containerName)
Set container name.
Definition: Placement.h:34
Token
This class provides a token that identifies in a unique way objects on the persistent storage.
Definition: Token.h:21
ITPCnvBase::transToPersUntyped
virtual void transToPersUntyped(const void *trans, void *pers, MsgStream &msg)=0
Convert transient object representation to persistent.
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
file
TFile * file
Definition: tile_monitor.h:29
find_tgc_unfilled_channelids.ip
ip
Definition: find_tgc_unfilled_channelids.py:3
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Preparation.mode
mode
Definition: Preparation.py:94
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:29
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
Placement::setTechnology
Placement & setTechnology(int technology)
Set technology type.
Definition: Placement.h:38
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
Athena::RootCnvSvc::m_treeName
std::string m_treeName
ROOT TTree name.
Definition: RootCnvSvc.h:109
Athena::RootCnv
This class provides the abstract converter to translate an object to/from its persistent ROOT represe...
Definition: RootCnv.h:37
AthCnvSvc::initialize
virtual StatusCode initialize() override
Gaudi Service Implementation.
Definition: AthCnvSvc.cxx:104
Athena::RootCnvSvc::m_tpCnvSvc
ServiceHandle< ::ITPCnvSvc > m_tpCnvSvc
ServiceHandle to the T/P conversion service.
Definition: RootCnvSvc.h:104
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37