Gaudi Framework, version v23r6

Home   Generated: Wed Jan 30 2013
 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
18 #include "GaudiKernel/CnvFactory.h"
19 PLUGINSVC_FACTORY_WITH_ID( RootDatabaseCnv,
21  IConverter*(long, CLID, ISvcLocator*) );
22 #endif
23 
24 using namespace Gaudi;
25 using namespace std;
26 
27 // Standard Constructor
28 RootDatabaseCnv::RootDatabaseCnv(long typ, const CLID& cl, ISvcLocator* svc, RootCnvSvc* mgr)
29 : RootDirectoryCnv(typ, cl, svc, mgr)
30 {
31 }
32 
33 // Standard destructor
34 RootDatabaseCnv::~RootDatabaseCnv() {
35 }
36 
37 // Create database object
39 RootDatabaseCnv::createObj(IOpaqueAddress* pAddr, DataObject*& refpObj) {
41  if ( pAddr ) {
42  RootDataConnection* con = 0;
43  IRegistry* pReg = pAddr->registry();
44  const unsigned long* ipars = pAddr->ipar();
45  const string* spars = pAddr->par();
46  char mode = char(ipars[1]);
47  string fname = spars[0];
48  string oname = pReg->name();
49  bool recrea = mode == 'R';
50  bool create = mode == 'N';
51  bool update = mode == 'U';
52  bool read = mode == 'O';
53  const CLID& clid = objType();
54  status = StatusCode::SUCCESS;
55  string cntName = containerName(pReg);
56  if ( create ) {
57  m_dbMgr->connectDatabase(fname,IDataConnection::CREATE,&con).ignore();
58  status = saveDescription(fname, cntName, "File containing statistics results.","", clid);
59  if ( status.isSuccess() ) {
60  log() << MSG::INFO << "Opened NEW Database file:"
61  << fname << " as " << oname << endmsg;
62  }
63  }
64  else if ( update ) {
65  m_dbMgr->connectDatabase(fname,IDataConnection::UPDATE,&con).ignore();
66  status = saveDescription(fname, cntName, "File containing statistics results.","", clid);
67  if ( status.isSuccess() ) {
68  log() << MSG::INFO << "Connect to existing Database file:"
69  << fname << " as " << oname << " for UPDATE" << endmsg;
70  }
71  }
72  else if ( read ) {
73  status = m_dbMgr->connectDatabase(fname,IDataConnection::READ,&con);
74  if ( status.isSuccess() ) {
75  log() << MSG::INFO << "Connect to existing Database file:"
76  << fname << " as " << oname << " for READ" << endmsg;
77  }
78  }
79  else if ( recrea ) {
80  m_dbMgr->connectDatabase(fname,IDataConnection::RECREATE,&con).ignore();
81  status = saveDescription(fname, cntName, "File containing statistics results.","", clid);
82  if ( status.isSuccess() ) {
83  log() << MSG::INFO << "Recreate Database file:" << fname << " as " << oname << endmsg;
84  }
85  }
86  else {
87  log() << MSG::ERROR << "Don't know what to do:" << fname << endmsg;
88  status = StatusCode::FAILURE;
89  }
90  // Now create object
91  if ( status.isSuccess() ) {
92  NTuple::File* pFile = new NTuple::File(objType(), fname, oname);
93  pFile->setOpen(false);
94  refpObj = pFile;
95  }
96  }
97  return status;
98 }
99 

Generated at Wed Jan 30 2013 17:13:42 for Gaudi Framework, version v23r6 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004