| The Gaudi Framework v27r1

- 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
32 RootDatabaseCnv::createObj(IOpaqueAddress* pAddr, DataObject*& refpObj) {
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:"
54 << fname << " as " << oname << endmsg;
55 }
56 }
57 else if ( update ) {
58 m_dbMgr->connectDatabase(fname,IDataConnection::UPDATE,&con).ignore();
59 status = saveDescription(fname, cntName, "File containing statistics results.","", clid);
60 if ( status.isSuccess() ) {
61 log() << MSG::INFO << "Connect to existing Database file:"
62 << fname << " as " << oname << " for UPDATE" << endmsg;
63 }
64 }
65 else if ( read ) {
66 status = m_dbMgr->connectDatabase(fname,IDataConnection::READ,&con);
67 if ( status.isSuccess() ) {
68 log() << MSG::INFO << "Connect to existing Database file:"
69 << fname << " as " << oname << " for READ" << endmsg;
70 }
71 }
72 else if ( recrea ) {
73 m_dbMgr->connectDatabase(fname,IDataConnection::RECREATE,&con).ignore();
74 status = saveDescription(fname, cntName, "File containing statistics results.","", clid);
75 if ( status.isSuccess() ) {
76 log() << MSG::INFO << "Recreate Database file:" << fname << " as " << oname << endmsg;
77 }
78 }
79 else {
80 log() << MSG::ERROR << "Don't know what to do:" << fname << endmsg;
81 status = StatusCode::FAILURE;
82 }
83 // Now create object
84 if ( status.isSuccess() ) {
85 NTuple::File* pFile = new NTuple::File(objType(), fname, oname);
86 pFile->setOpen(false);
87 refpObj = pFile;
88 }
89 }
90 return status;
91 }
92
Gaudi::RootStatCnv::log
MsgStream & log() const
Helper to use mesage logger.
Definition: RootStatCnv.h:38
DECLARE_COMPONENT_WITH_ID
#define DECLARE_COMPONENT_WITH_ID(type, id)
Definition: PluginService.h:39
IOpaqueAddress::par
virtual const std::string * par() const =0
Retrieve String parameters.
NTuple::File::setOpen
void setOpen(bool flag)
Set "open" flag.
Definition: NTuple.h:1140
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
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:48
NTuple.h
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
RootDatabaseCnv.h
Gaudi::RootConverter::m_dbMgr
RootCnvSvc * m_dbMgr
Conversion service needed for proper operation to forward requests.
Definition: RootConverter.h:36
Gaudi::RootCnvSvc
Description:
Definition: RootCnvSvc.h:52
std
STL namespace.
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:223
Gaudi::IDataConnection::RECREATE
Definition: IIODataManager.h:38
Gaudi::IDataConnection::READ
Definition: IIODataManager.h:38
IOpaqueAddress::registry
virtual IRegistry * registry() const =0
Update branch name.
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::SUCCESS
Definition: StatusCode.h:30
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:28
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:112
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:38
IOpaqueAddress.h
Gaudi::RootDirectoryCnv
Description: NTuple directory converter class definition Definition of the converter to manage the di...
Definition: RootDirectoryCnv.h:30
install.update
def update
Definition: install.py:213
Gaudi::IDataConnection::CREATE
Definition: IIODataManager.h:38
Gaudi::RootDatabaseCnv::createObj
StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&refpObj) override
Converter overrides: Create transient object from persistent data.
Definition: RootDatabaseCnv.cpp:32
MSG::ERROR
Definition: IMessageSvc.h:21
Gaudi::RootDatabaseCnv::RootDatabaseCnv
RootDatabaseCnv(long typ, const CLID &, ISvcLocator *svc, RootCnvSvc *mgr)
Initializing Constructor.
Definition: RootDatabaseCnv.cpp:25
IOpaqueAddress
Opaque address interface definition.
Definition: IOpaqueAddress.h:23
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:108
MSG::INFO
Definition: IMessageSvc.h:19
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:92
IOpaqueAddress::ipar
virtual const unsigned long * ipar() const =0
Access to generic link parameters.
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:244
Converter::objType
const CLID & objType() const override
Retrieve the class type of objects the converter produces.
Definition: Converter.cpp:14
ConverterID
Definition: Converter.h:150
NTuple::File
Small class representing an N tuple file in the transient store.
Definition: NTuple.h:1088