The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
RootDatabaseCnv.cpp
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
3* *
4* This software is distributed under the terms of the Apache version 2 licence, *
5* copied verbatim in the file "LICENSE". *
6* *
7* In applying this licence, CERN does not waive the privileges and immunities *
8* granted to it by virtue of its status as an Intergovernmental Organization *
9* or submit itself to any jurisdiction. *
10\***********************************************************************************/
11//------------------------------------------------------------------------------
12//
13// Implementation of class : RootDatabaseCnv
14//
15// Author : Markus Frank
16//
17//------------------------------------------------------------------------------
18// Framework include files
21
24#include <GaudiKernel/NTuple.h>
25
26#if 0
28 ConverterID(ROOT_StorageType,CLID_StatisticsFile) )
29#endif
30
31using namespace Gaudi;
32using namespace std;
33
34// Standard Constructor
36 : RootDirectoryCnv( typ, cl, svc, mgr ) {}
37
38// Create database object
41 if ( pAddr ) {
42 RootDataConnection* con = nullptr;
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 auto 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:" << fname << " as " << oname << endmsg;
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:" << fname << " as " << oname << " for UPDATE"
67 << endmsg;
68 }
69 } else if ( read ) {
70 status = m_dbMgr->connectDatabase( fname, IDataConnection::READ, &con );
71 if ( status.isSuccess() ) {
72 log() << MSG::INFO << "Connect to existing Database file:" << fname << " as " << oname << " for READ" << endmsg;
73 }
74 } else if ( recrea ) {
75 m_dbMgr->connectDatabase( fname, IDataConnection::RECREATE, &con ).ignore();
76 status = saveDescription( fname, cntName, "File containing statistics results.", "", clid );
77 if ( status.isSuccess() ) {
78 log() << MSG::INFO << "Recreate Database file:" << fname << " as " << oname << endmsg;
79 }
80 } else {
81 log() << MSG::ERROR << "Don't know what to do:" << fname << endmsg;
82 status = StatusCode::FAILURE;
83 }
84 // Now create object
85 if ( status.isSuccess() ) {
86 NTuple::File* pFile = new NTuple::File( objType(), fname, oname );
87 pFile->setOpen( false );
88 refpObj = pFile;
89 }
90 }
91 return status;
92}
unsigned int CLID
Class ID definition.
Definition ClassID.h:16
const long ROOT_StorageType
Definition ClassID.h:60
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
#define DECLARE_COMPONENT_WITH_ID(type, id)
const CLID & objType() const override
Retrieve the class type of objects the converter produces.
Definition Converter.cpp:22
A DataObject is the base class of any identifiable object on any data store.
Definition DataObject.h:37
Description:
Definition RootCnvSvc.h:61
RootCnvSvc * m_dbMgr
Conversion service needed for proper operation to forward requests.
Concrete implementation of the IDataConnection interface to access ROOT files.
Statistics file converter class definition.
const std::string containerName(IRegistry *) const override
Retrieve the name of the container a given object is placed into.
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.
RootDirectoryCnv(long typ, const CLID &clid, ISvcLocator *svc, RootCnvSvc *mgr)
Initializing Constructor.
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.
MsgStream & log() const
Helper to use mesage logger.
Definition RootStatCnv.h:47
Opaque address interface definition.
virtual const unsigned long * ipar() const =0
Access to generic link parameters.
virtual const std::string * par() const =0
Retrieve String parameters.
virtual IRegistry * registry() const =0
Update branch name.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition IRegistry.h:29
virtual const name_type & name() const =0
Name of the directory (or key)
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition ISvcLocator.h:42
Small class representing an N tuple file in the transient store.
Definition NTuple.h:915
void setOpen(bool flag)
Set "open" flag.
Definition NTuple.h:949
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
bool isSuccess() const
Definition StatusCode.h:314
constexpr static const auto SUCCESS
Definition StatusCode.h:99
constexpr static const auto FAILURE
Definition StatusCode.h:100
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition __init__.py:1
@ ERROR
Definition IMessageSvc.h:22
@ INFO
Definition IMessageSvc.h:22
STL namespace.