The Gaudi Framework  master (37c0b60a)
RConverter.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 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 #ifndef ROOTHISTCNV_RCONVERTER_H
12 #define ROOTHISTCNV_RCONVERTER_H 1
13 
14 // Include files
15 #include <GaudiKernel/Converter.h>
16 #include <TDirectory.h>
17 #include <map>
18 #include <string>
19 
20 // Forward declarations
21 class ISvcLocator;
22 class TObject;
23 class TTree;
24 class TFile;
25 
27  TDirectory* m_current;
28 
29 public:
30  GlobalDirectoryRestore() { m_current = gDirectory; }
31  virtual ~GlobalDirectoryRestore() { gDirectory = m_current; }
32 };
33 
34 namespace RootHistCnv {
35 
41  class RConverter : public Converter {
42  public:
44  StatusCode createRep( DataObject* pObj, IOpaqueAddress*& refpAddr ) override;
46  static long storageType() { return ROOT_StorageType; }
47  long repSvcType() const override { return i_repSvcType(); }
48 
49  StatusCode error( const std::string& msg );
50  StatusCode regTFile( const std::string&, const TFile* );
51  StatusCode findTFile( const std::string&, TFile*& );
52 
54  std::string directory( const std::string& loc );
55  void setDirectory( const std::string& loc );
56  void setDiskDirectory( const std::string& loc );
60 
61  std::string convertId( const std::string& ) const;
62 
63  protected:
65  RConverter( const CLID& clid, ISvcLocator* svc ) : Converter( storageType(), clid, svc ) {}
67  virtual StatusCode readObject( IOpaqueAddress* pAddr, DataObject*& refpObj );
69  virtual TObject* createPersistent( DataObject* pObj );
71  StatusCode createAddress( DataObject* pObject, TDirectory* pDir, TObject* pTObject, IOpaqueAddress*& refpAddr );
72 
73  StatusCode createAddress( const std::string& rzdir, const CLID& clid, long id, TObject* pTobj,
74  IOpaqueAddress*& refpAddress );
75 
76  StatusCode createAddress( const std::string& rzdir, const CLID& clid, const std::string& title, TObject* pTobj,
77  IOpaqueAddress*& refpAddress );
78 
80  TDirectory* changeDirectory( DataObject* pObject );
81  };
82 } // namespace RootHistCnv
83 
84 #endif // RootHistCnv_RConverter_H
RootHistCnv::RConverter::convertId
std::string convertId(const std::string &) const
Definition: RConverter.cpp:322
GlobalDirectoryRestore::m_current
TDirectory * m_current
Definition: RConverter.h:27
RootHistCnv::RConverter::createPersistent
virtual TObject * createPersistent(DataObject *pObj)
Create the persistent representation of an object.
Definition: RConverter.cpp:271
std::string
STL class.
IOpaqueAddress
Definition: IOpaqueAddress.h:33
ISvcLocator
Definition: ISvcLocator.h:46
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:19
RootHistCnv::RConverter::RConverter
RConverter(const CLID &clid, ISvcLocator *svc)
Standard constructor.
Definition: RConverter.h:65
RootHistCnv::RConverter::findTFile
StatusCode findTFile(const std::string &, TFile *&)
Definition: RConverter.cpp:289
GlobalDirectoryRestore::~GlobalDirectoryRestore
virtual ~GlobalDirectoryRestore()
Definition: RConverter.h:31
RootHistCnv::RConverter::setDirectory
void setDirectory(const std::string &loc)
Definition: RConverter.cpp:118
Converter.h
RootHistCnv::RConverter::createRep
StatusCode createRep(DataObject *pObj, IOpaqueAddress *&refpAddr) override
Convert the transient object to the requested representation.
Definition: RConverter.cpp:238
RootHistCnv::RConverter::directory
std::string directory(const std::string &loc)
Definition: RConverter.cpp:111
RootHistCnv
Definition: DirectoryCnv.h:27
RootHistCnv::RConverter::regTFile
StatusCode regTFile(const std::string &, const TFile *)
Definition: RConverter.cpp:274
StatusCode
Definition: StatusCode.h:65
RootHistCnv::RConverter::diskDirectory
std::string diskDirectory(const std::string &loc)
Definition: RConverter.cpp:79
Converter
Definition: Converter.h:34
RootHistCnv::RConverter::storageType
static long storageType()
Inquire storage type.
Definition: RConverter.h:46
RootHistCnv::RConverter::getDirectory
std::string getDirectory()
Definition: RConverter.cpp:158
RootHistCnv::RConverter::createAddress
StatusCode createAddress(DataObject *pObject, TDirectory *pDir, TObject *pTObject, IOpaqueAddress *&refpAddr)
Create address of the transient object according to the requested representation.
Definition: RConverter.cpp:165
RootHistCnv::RConverter
Definition: RConverter.h:41
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:18
Converter::i_repSvcType
virtual long i_repSvcType() const
Retrieve the class type of the data store the converter uses.
Definition: Converter.cpp:26
ROOT_StorageType
const long ROOT_StorageType
Definition: ClassID.h:62
GlobalDirectoryRestore
Definition: RConverter.h:26
RootHistCnv::RConverter::error
StatusCode error(const std::string &msg)
Definition: RConverter.cpp:339
RootHistCnv::RConverter::setDiskDirectory
void setDiskDirectory(const std::string &loc)
Definition: RConverter.cpp:151
RootHistCnv::RConverter::repSvcType
long repSvcType() const override
Definition: RConverter.h:47
RootHistCnv::RConverter::createDirectory
StatusCode createDirectory(const std::string &loc)
Definition: RConverter.cpp:34
DataObject
Definition: DataObject.h:36
RootHistCnv::RConverter::readObject
virtual StatusCode readObject(IOpaqueAddress *pAddr, DataObject *&refpObj)
Create the transient representation of an object.
Definition: RConverter.cpp:260
RootHistCnv::RConverter::changeDirectory
TDirectory * changeDirectory(DataObject *pObject)
Switch to object directory (=Parent directory)
Definition: RConverter.cpp:210
GlobalDirectoryRestore::GlobalDirectoryRestore
GlobalDirectoryRestore()
Definition: RConverter.h:30
RootHistCnv::RConverter::createDiskDirectory
StatusCode createDiskDirectory(const std::string &loc)