| The Gaudi Framework v30r0 (c919700c)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

RootDatabaseCnv.cpp
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 //
3 // Implementation of class : RootDatabaseCnv
4 //
5 // Author : Markus Frank
6 //
7 //------------------------------------------------------------------------------
8 // Framework include files
9 #include "RootCnv/RootDatabaseCnv.h"
10 #include "RootCnv/RootDataConnection.h"
11
12 #include "GaudiKernel/IOpaqueAddress.h"
13 #include "GaudiKernel/IRegistry.h"
14 #include "GaudiKernel/NTuple.h"
15
16 #if 0
17 DECLARE_COMPONENT_WITH_ID(RootDatabaseCnv,
18 ConverterID(ROOT_StorageType,CLID_StatisticsFile) )
19 #endif
20
21 using namespace Gaudi;
22 using namespace std;
23
24 // Standard Constructor
25 RootDatabaseCnv::RootDatabaseCnv( long typ, const CLID& cl, ISvcLocator* svc, RootCnvSvc* mgr )
26 : RootDirectoryCnv( typ, cl, svc, mgr )
27 {
28 }
29
30 // Create database object
31 StatusCode RootDatabaseCnv::createObj( IOpaqueAddress* pAddr, DataObject*& refpObj )
32 {
33 StatusCode status = StatusCode::FAILURE;
34 if ( pAddr ) {
35 RootDataConnection* con = nullptr;
36 IRegistry* pReg = pAddr->registry();
37 const unsigned long* ipars = pAddr->ipar();
38 const string* spars = pAddr->par();
39 char mode = char( ipars[1] );
40 string fname = spars[0];
41 string oname = pReg->name();
42 bool recrea = mode == 'R';
43 bool create = mode == 'N';
44 bool update = mode == 'U';
45 bool read = mode == 'O';
46 const CLID& clid = objType();
47 status = StatusCode::SUCCESS;
48 string cntName = containerName( pReg );
49 if ( create ) {
50 m_dbMgr->connectDatabase( fname, IDataConnection::CREATE, &con ).ignore();
51 status = saveDescription( fname, cntName, "File containing statistics results.", "", clid );
52 if ( status.isSuccess() ) {
53 log() << MSG::INFO << "Opened NEW Database file:" << fname << " as " << oname << endmsg;
54 }
55 } else if ( update ) {
56 m_dbMgr->connectDatabase( fname, IDataConnection::UPDATE, &con ).ignore();
57 status = saveDescription( fname, cntName, "File containing statistics results.", "", clid );
58 if ( status.isSuccess() ) {
59 log() << MSG::INFO << "Connect to existing Database file:" << fname << " as " << oname << " for UPDATE"
60 << endmsg;
61 }
62 } else if ( read ) {
63 status = m_dbMgr->connectDatabase( fname, IDataConnection::READ, &con );
64 if ( status.isSuccess() ) {
65 log() << MSG::INFO << "Connect to existing Database file:" << fname << " as " << oname << " for READ" << endmsg;
66 }
67 } else if ( recrea ) {
68 m_dbMgr->connectDatabase( fname, IDataConnection::RECREATE, &con ).ignore();
69 status = saveDescription( fname, cntName, "File containing statistics results.", "", clid );
70 if ( status.isSuccess() ) {
71 log() << MSG::INFO << "Recreate Database file:" << fname << " as " << oname << endmsg;
72 }
73 } else {
74 log() << MSG::ERROR << "Don't know what to do:" << fname << endmsg;
75 status = StatusCode::FAILURE;
76 }
77 // Now create object
78 if ( status.isSuccess() ) {
79 NTuple::File* pFile = new NTuple::File( objType(), fname, oname );
80 pFile->setOpen( false );
81 refpObj = pFile;
82 }
83 }
84 return status;
85 }
Gaudi::RootStatCnv::log
MsgStream & log() const
Helper to use mesage logger.
Definition: RootStatCnv.h:40
DECLARE_COMPONENT_WITH_ID
#define DECLARE_COMPONENT_WITH_ID(type, id)
Definition: PluginService.h:35
StatusCode::SUCCESS
Definition: StatusCode.h:29
NTuple::File::setOpen
void setOpen(bool flag)
Set "open" flag.
Definition: NTuple.h:1041
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
Converter::objType
const CLID & objType() const override
Retrieve the class type of objects the converter produces.
Definition: Converter.cpp:14
Gaudi::RootDatabaseCnv::containerName
const std::string containerName(IRegistry *) const override
Retrieve the name of the container a given object is placed into.
Definition: RootDatabaseCnv.h:49
NTuple.h
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:50
RootDatabaseCnv.h
Gaudi::RootConverter::m_dbMgr
RootCnvSvc * m_dbMgr
Conversion service needed for proper operation to forward requests.
Definition: RootConverter.h:37
IOpaqueAddress::registry
virtual IRegistry * registry() const =0
Update branch name.
Gaudi::RootCnvSvc
Description:
Definition: RootCnvSvc.h:53
std
STL namespace.
hivetimeline.read
def read(f, regex='.*', skipevents=0)
Definition: hivetimeline.py:22
IRegistry::name
virtual const name_type & name() const =0
Name of the directory (or key)
Gaudi::RootCnvSvc::connectDatabase
StatusCode connectDatabase(const std::string &dataset, int mode, RootDataConnection **con)
Connect the output file to the service with open mode.
Definition: RootCnvSvc.cpp:211
Gaudi::IDataConnection::RECREATE
Definition: IIODataManager.h:41
IOpaqueAddress::par
virtual const std::string * par() const =0
Retrieve String parameters.
Gaudi::IDataConnection::READ
Definition: IIODataManager.h:41
IOpaqueAddress::ipar
virtual const unsigned long * ipar() const =0
Access to generic link parameters.
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Gaudi::RootDatabaseCnv
Statistics file converter class definition.
Definition: RootDatabaseCnv.h:29
Gaudi::RootStatCnv::saveDescription
StatusCode saveDescription(const std::string &path, const std::string &ident, const std::string &desc, const std::string &opt, const CLID &clid)
Save statistics object description.
Definition: RootStatCnv.cpp:116
IRegistry.h
IRegistry
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
ROOT_StorageType
const long ROOT_StorageType
Definition: ClassID.h:52
RootDataConnection.h
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
Gaudi::IDataConnection::UPDATE
Definition: IIODataManager.h:41
IOpaqueAddress.h
Gaudi::RootDirectoryCnv
Description: NTuple directory converter class definition Definition of the converter to manage the di...
Definition: RootDirectoryCnv.h:31
Gaudi::IDataConnection::CREATE
Definition: IIODataManager.h:41
Gaudi::RootDatabaseCnv::createObj
StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&refpObj) override
Converter overrides: Create transient object from persistent data.
Definition: RootDatabaseCnv.cpp:31
MSG::ERROR
Definition: IMessageSvc.h:16
Gaudi::RootDatabaseCnv::RootDatabaseCnv
RootDatabaseCnv(long typ, const CLID &, ISvcLocator *svc, RootCnvSvc *mgr)
Initializing Constructor.
Definition: RootDatabaseCnv.cpp:25
StatusCode::FAILURE
Definition: StatusCode.h:29
IOpaqueAddress
Opaque address interface definition.
Definition: IOpaqueAddress.h:23
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:84
MSG::INFO
Definition: IMessageSvc.h:16
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
Gaudi::RootDataConnection
Concrete implementation of the IDataConnection interface to access ROOT files.
Definition: RootDataConnection.h:94
Gaudi
Helper functions to set/get the application return code.
Definition: __init__.py:1
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
GaudiPython.Pythonizations.update
update
Definition: Pythonizations.py:123
ConverterID
Definition: Converter.h:142
NTuple::File
Small class representing an N tuple file in the transient store.
Definition: NTuple.h:1002