Gaudi Framework, version v25r2

Home   Generated: Wed Jun 4 2014
 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
20 #endif
21 
22 using namespace Gaudi;
23 using namespace std;
24 
25 // Standard Constructor
26 RootDatabaseCnv::RootDatabaseCnv(long typ, const CLID& cl, ISvcLocator* svc, RootCnvSvc* mgr)
27 : RootDirectoryCnv(typ, cl, svc, mgr)
28 {
29 }
30 
31 // Standard destructor
32 RootDatabaseCnv::~RootDatabaseCnv() {
33 }
34 
35 // Create database object
37 RootDatabaseCnv::createObj(IOpaqueAddress* pAddr, DataObject*& refpObj) {
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 ) {
55  m_dbMgr->connectDatabase(fname,IDataConnection::CREATE,&con).ignore();
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 ) {
63  m_dbMgr->connectDatabase(fname,IDataConnection::UPDATE,&con).ignore();
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 ) {
78  m_dbMgr->connectDatabase(fname,IDataConnection::RECREATE,&con).ignore();
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 

Generated at Wed Jun 4 2014 14:48:58 for Gaudi Framework, version v25r2 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004