The Gaudi Framework  v29r0 (ff2e7097)
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
11 
13 #include "GaudiKernel/IRegistry.h"
14 #include "GaudiKernel/NTuple.h"
15 
16 #if 0
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
32 {
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 ) {
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 ) {
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 ) {
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 }
MsgStream & log() const
Helper to use mesage logger.
Definition: RootStatCnv.h:40
#define DECLARE_COMPONENT_WITH_ID(type, id)
Definition: PluginService.h:35
void setOpen(bool flag)
Set "open" flag.
Definition: NTuple.h:1041
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
const CLID & objType() const override
Retrieve the class type of objects the converter produces.
Definition: Converter.cpp:14
const std::string containerName(IRegistry *) const override
Retrieve the name of the container a given object is placed into.
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
RootCnvSvc * m_dbMgr
Conversion service needed for proper operation to forward requests.
Definition: RootConverter.h:37
virtual IRegistry * registry() const =0
Update branch name.
Description:
Definition: RootCnvSvc.h:53
STL namespace.
def read(f, regex='.*', skipevents=0)
Definition: hivetimeline.py:22
virtual const name_type & name() const =0
Name of the directory (or key)
StatusCode connectDatabase(const std::string &dataset, int mode, RootDataConnection **con)
Connect the output file to the service with open mode.
Definition: RootCnvSvc.cpp:211
virtual const std::string * par() const =0
Retrieve String parameters.
virtual const unsigned long * ipar() const =0
Access to generic link parameters.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
Statistics file converter class definition.
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.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
const long ROOT_StorageType
Definition: ClassID.h:52
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
Description: NTuple directory converter class definition Definition of the converter to manage the di...
StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&refpObj) override
Converter overrides: Create transient object from persistent data.
RootDatabaseCnv(long typ, const CLID &, ISvcLocator *svc, RootCnvSvc *mgr)
Initializing Constructor.
Opaque address interface definition.
void ignore() const
Definition: StatusCode.h:109
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:29
Concrete implementation of the IDataConnection interface to access ROOT files.
Helper functions to set/get the application return code.
Definition: __init__.py:1
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Small class representing an N tuple file in the transient store.
Definition: NTuple.h:1002