All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RootDatabaseCnv.cpp
Go to the documentation of this file.
1 // $Id: RootDatabaseCnv.cpp,v 1.6 2010-09-27 15:43:53 frankb Exp $
2 //------------------------------------------------------------------------------
3 //
4 // Implementation of class : RootDatabaseCnv
5 //
6 // Author : Markus Frank
7 //
8 //------------------------------------------------------------------------------
9 // Framework include files
12 
14 #include "GaudiKernel/IRegistry.h"
15 #include "GaudiKernel/NTuple.h"
16 
17 #if 0
19  ConverterID(ROOT_StorageType,CLID_StatisticsFile) )
20 #endif
21 
22 using namespace Gaudi;
23 using namespace std;
24 
25 // Standard Constructor
27 : RootDirectoryCnv(typ, cl, svc, mgr)
28 {
29 }
30 
31 // Standard destructor
33 }
34 
35 // Create database object
39  if ( pAddr ) {
40  RootDataConnection* con = 0;
41  IRegistry* pReg = pAddr->registry();
42  const unsigned long* ipars = pAddr->ipar();
43  const string* spars = pAddr->par();
44  char mode = char(ipars[1]);
45  string fname = spars[0];
46  string oname = pReg->name();
47  bool recrea = mode == 'R';
48  bool create = mode == 'N';
49  bool update = mode == 'U';
50  bool read = mode == 'O';
51  const CLID& clid = objType();
52  status = StatusCode::SUCCESS;
53  string cntName = containerName(pReg);
54  if ( create ) {
56  status = saveDescription(fname, cntName, "File containing statistics results.","", clid);
57  if ( status.isSuccess() ) {
58  log() << MSG::INFO << "Opened NEW Database file:"
59  << fname << " as " << oname << endmsg;
60  }
61  }
62  else if ( update ) {
64  status = saveDescription(fname, cntName, "File containing statistics results.","", clid);
65  if ( status.isSuccess() ) {
66  log() << MSG::INFO << "Connect to existing Database file:"
67  << fname << " as " << oname << " for UPDATE" << endmsg;
68  }
69  }
70  else if ( read ) {
71  status = m_dbMgr->connectDatabase(fname,IDataConnection::READ,&con);
72  if ( status.isSuccess() ) {
73  log() << MSG::INFO << "Connect to existing Database file:"
74  << fname << " as " << oname << " for READ" << endmsg;
75  }
76  }
77  else if ( recrea ) {
79  status = saveDescription(fname, cntName, "File containing statistics results.","", clid);
80  if ( status.isSuccess() ) {
81  log() << MSG::INFO << "Recreate Database file:" << fname << " as " << oname << endmsg;
82  }
83  }
84  else {
85  log() << MSG::ERROR << "Don't know what to do:" << fname << endmsg;
86  status = StatusCode::FAILURE;
87  }
88  // Now create object
89  if ( status.isSuccess() ) {
90  NTuple::File* pFile = new NTuple::File(objType(), fname, oname);
91  pFile->setOpen(false);
92  refpObj = pFile;
93  }
94  }
95  return status;
96 }
97 
MsgStream & log() const
Helper to use mesage logger.
Definition: RootStatCnv.h:39
#define DECLARE_COMPONENT_WITH_ID(type, id)
Definition: PluginService.h:39
virtual const std::string * par() const =0
Retrieve String parameters.
void setOpen(bool flag)
Set "open" flag.
Definition: NTuple.h:1138
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:26
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
Description:
Definition: RootCnvSvc.h:54
virtual const name_type & name() const =0
Name of the directory (or key)
virtual ~RootDatabaseCnv()
Standard destructor.
StatusCode connectDatabase(const std::string &dataset, int mode, RootDataConnection **con)
Connect the output file to the service with open mode.
Definition: RootCnvSvc.cpp:224
virtual const std::string containerName(IRegistry *) const
Retrieve the name of the container a given object is placed into.
virtual const CLID & objType() const
Retrieve the class type of objects the converter produces.
Definition: Converter.cpp:16
virtual IRegistry * registry() const =0
Update branch name.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
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.
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&refpObj)
Converter overrides: Create transient object from persistent data.
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:53
unsigned int CLID
Class ID definition.
Definition: ClassID.h:9
Description: NTuple directory converter class definition Definition of the converter to manage the di...
def update
Definition: install.py:213
RootDatabaseCnv(long typ, const CLID &, ISvcLocator *svc, RootCnvSvc *mgr)
Initializing Constructor.
Opaque address interface definition.
void ignore() const
Definition: StatusCode.h:107
This is a number of static methods for bootstrapping the Gaudi framework.
Definition: Bootstrap.h:14
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:31
Concrete implementation of the IDataConnection interface to access ROOT files.
virtual const unsigned long * ipar() const =0
Access to generic link parameters.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
Small class representing an N tuple file in the transient store.
Definition: NTuple.h:1085