TagCollectionSvc Class Reference

Gaudi tag collection service definition. More...

#include <src/NTupleSvc/TagCollectionSvc.h>

Inheritance diagram for TagCollectionSvc:
Collaboration diagram for TagCollectionSvc:

Public Member Functions

 TagCollectionSvc (const std::string &name, ISvcLocator *svc)
 Standard Constructor. More...
 
 ~TagCollectionSvc () override=default
 Standard Destructor. More...
 
- Public Member Functions inherited from NTupleSvc
virtual StatusCode initialize ()
 DataSvc overrides: Initialize the service. More...
 
virtual StatusCode reinitialize ()
 DataSvc overrides: reinitialize service. More...
 
virtual StatusCode finalize ()
 DataSvc overrides: stop the service. More...
 
virtual IConversionSvcgetDataLoader (IRegistry *pReg)
 DataSvc overrides: Retrieve data loader. More...
 
virtual NTuple::DirectorycreateDirectory (DataObject *pParent, const std::string &title)
 Create Ntuple directory and register it with the data store. More...
 
virtual NTuple::DirectorycreateDirectory (DataObject *pParent, long id)
 Create Ntuple directory and register it with the data store. More...
 
virtual NTuple::DirectorycreateDirectory (const std::string &dirPath, long id)
 Create Ntuple directory and register it with the data store. More...
 
virtual NTuple::DirectorycreateDirectory (const std::string &dirPath, const std::string &title)
 Create Ntuple directory and register it with the data store. More...
 
virtual NTuple::DirectorycreateDirectory (const std::string &fullPath)
 Create Ntuple directory and register it with the data store. More...
 
virtual StatusCode create (const CLID &typ, const std::string &title, NTuple::Tuple *&refpTuple)
 Create requested N tuple (Hide constructor) More...
 
virtual NTuple::Tuplebook (const std::string &fullPath, const CLID &type, const std::string &title)
 Book Ntuple and register it with the data store. More...
 
virtual NTuple::Tuplebook (const std::string &dirPath, const std::string &relPath, const CLID &type, const std::string &title)
 Book Ntuple and register it with the data store. More...
 
virtual NTuple::Tuplebook (const std::string &dirPath, long id, const CLID &type, const std::string &title)
 Book Ntuple and register it with the data store. More...
 
virtual NTuple::Tuplebook (DataObject *pParent, const std::string &relPath, const CLID &type, const std::string &title)
 Book Ntuple and register it with the data store. More...
 
virtual NTuple::Tuplebook (DataObject *pParent, long id, const CLID &type, const std::string &title)
 Book Ntuple and register it with the data store. More...
 
virtual NTuple::Tupleaccess (const std::string &fullPath, const std::string &filename)
 Access N tuple on disk. More...
 
virtual StatusCode save (const std::string &fullPath)
 Save N tuple to disk. Must be called in order to close the ntuple file properly. More...
 
virtual StatusCode save (NTuple::Tuple *tuple)
 Save N tuple to disk. Must be called in order to close the ntuple file properly. More...
 
virtual StatusCode save (DataObject *pParent, const std::string &relPath)
 Save N tuple to disk. Must be called in order to close the ntuple file properly. More...
 
virtual StatusCode writeRecord (NTuple::Tuple *tuple)
 Write single record to N tuple. More...
 
virtual StatusCode writeRecord (const std::string &fullPath)
 Write single record to N tuple. More...
 
virtual StatusCode writeRecord (DataObject *pParent, const std::string &relPath)
 Write single record to N tuple. More...
 
virtual StatusCode readRecord (NTuple::Tuple *tuple)
 Read single record from N tuple. More...
 
virtual StatusCode readRecord (const std::string &fullPath)
 Read single record from N tuple. More...
 
virtual StatusCode readRecord (DataObject *pParent, const std::string &relPath)
 Read single record from N tuple. More...
 
virtual bool isConnected (const std::string &identifier) const
 Check if a datasource is connected. More...
 
virtual StatusCode connect (const std::string &ident)
 Add file to list I/O list. More...
 
virtual StatusCode disconnect (const std::string &nam)
 Close open connection. More...
 
virtual StatusCode disconnectAll ()
 Close all open connections. More...
 
 NTupleSvc (const std::string &name, ISvcLocator *svc)
 Standard Constructor. More...
 
virtual ~NTupleSvc ()
 Standard Destructor. More...
 
- Public Member Functions inherited from extends< BASE, Interfaces >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces...>
 ~extend_interfaces () override=default
 Virtual destructor. More...
 
 ~extend_interfaces () override=default
 Virtual destructor. More...
 

Protected Member Functions

StatusCode connect (const std::string &ident, std::string &logname) override
 Add file to list I/O list. More...
 
virtual StatusCode createService (const std::string &nam, const std::string &typ, const std::vector< Prop > &props, IConversionSvc *&pSvc)
 Create conversion service. More...
 
- Protected Member Functions inherited from NTupleSvc
StatusCode createService (const std::string &nam, const std::string &typ, const std::vector< Prop > &props, IConversionSvc *&pSvc)
 Create conversion service. More...
 
void releaseConnection (Connection &c)
 Finalize single service. More...
 
StatusCode attachTuple (const std::string &filename, const std::string &logname, const char typ, const long t)
 Attach output/input file. More...
 
StatusCode updateDirectories ()
 Update directory data. More...
 

Additional Inherited Members

- Public Types inherited from extends< BASE, Interfaces >
typedef extends base_class
 Typedef to this class. More...
 
typedef extend_interfaces< Interfaces...> extend_interfaces_base
 Typedef to the base of this class. More...
 
typedef extends base_class
 Typedef to this class. More...
 
typedef extend_interfaces< Interfaces...> extend_interfaces_base
 Typedef to the base of this class. More...
 
- Public Types inherited from extend_interfaces< Interfaces...>
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids...>::type
 take union of the ext_iids of all Interfaces... More...
 
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids...>::type
 take union of the ext_iids of all Interfaces... More...
 
- Protected Types inherited from NTupleSvc
typedef std::vector< std::string > DBaseEntries
 
typedef std::map< std::string, ConnectionConnections
 
typedef std::pair< std::string, std::string > Prop
 
- Protected Attributes inherited from NTupleSvc
DBaseEntries m_output
 Output streams. More...
 
DBaseEntries m_input
 Input streams. More...
 
Connections m_connections
 Container of connection points. More...
 

Detailed Description

Gaudi tag collection service definition.

Description: See the base class definition files for more detailed documentation of the implementing class. The basic functionality of the implementation is enhanced to allow for more general N-tuples, which can be used also as event tag collections.

M.Frank 1.0

Definition at line 26 of file TagCollectionSvc.h.

Constructor & Destructor Documentation

TagCollectionSvc::TagCollectionSvc ( const std::string &  name,
ISvcLocator svc 
)

Standard Constructor.

Definition at line 46 of file TagCollectionSvc.cpp.

47  : NTupleSvc(name, svc)
48 {
49 }
NTupleSvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
Definition: NTupleSvc.cpp:61
TagCollectionSvc::~TagCollectionSvc ( )
overridedefault

Standard Destructor.

Member Function Documentation

StatusCode TagCollectionSvc::connect ( const std::string &  ident,
std::string &  logname 
)
overrideprotectedvirtual

Add file to list I/O list.

Reimplemented from NTupleSvc.

Definition at line 53 of file TagCollectionSvc.cpp.

53  {
54  MsgStream log ( msgSvc(), name() );
55  DataObject* pO = nullptr;
56  StatusCode status = findObject(m_rootName, pO);
57  if ( status.isSuccess() ) {
58  status = INVALID_ROOT;
59  if ( pO->registry() ) {
60  char typ=0;
61  std::vector<Prop> props;
62  long loc = ident.find(" ");
63  std::string filename, svc = "DbCnvSvc";
64  logname = ident.substr(0,loc);
65  using Parser = Gaudi::Utils::AttribStringParser;
66  // we assume that there is always a " "
67  // (but if it is not there, we probably will not match the pattern)
68  for (auto attrib: Parser(ident.substr(loc + 1))) {
69  switch( ::toupper(attrib.tag[0]) ) {
70  case 'A':
71  props.emplace_back( "Server", attrib.value);
72  break;
73  case 'F': /* FILE='<file name>' */
74  case 'D': /* DATAFILE='<file name>' */
75  filename = std::move(attrib.value);
76  break;
77  case 'O': /* OPT='<NEW<CREATE,WRITE>, UPDATE, READ>' */
78  switch( ::toupper(attrib.value[0]) ) {
79  case 'C':
80  case 'N':
81  case 'W': typ = 'N'; break;
82  case 'U': typ = 'U'; break;
83  case 'O':
84  case 'R':
85  switch( ::toupper(attrib.value[2]) ) {
86  case 'C': /* RECREATE */ typ = 'R'; break;
87  case 'A': /* READ */
88  default: typ = 'O'; break;
89  }
90  break;
91  default: typ = 0; break;
92  }
93  break;
94  case 'S': // SVC='<service type>'
95  switch( ::toupper(attrib.tag[1]) ) {
96  case 'V': svc = std::move(attrib.value); break;
97  case 'H':
98  switch(::toupper(attrib.value[0])) {
99  case 'Y':
100  props.emplace_back( "ShareFiles", attrib.value);
101  break ;
102  }
103  break;
104  }
105  break;
106  case 'T': // TYP='<HBOOK,ROOT,OBJY,...>'
107  switch(::toupper(attrib.value[0])) {
108  case 'H':
109  svc = "HbookCnv::ConvSvc";
110  break;
111  case 'P':
112  props.emplace_back( "DbType", attrib.value);
113  svc = "PoolDbCnvSvc";
114  break;
115  default:
116  props.emplace_back( "DbType", attrib.value);
117  svc = "DbCnvSvc";
118  break;
119  }
120  break;
121  default:
122  props.emplace_back( attrib.tag, attrib.value);
123  break;
124  }
125  }
126  if ( 0 != typ ) {
127  IConversionSvc* pSvc = nullptr;
128  status = createService(name()+'.'+logname, svc, props, pSvc);
129  if ( status.isSuccess() ) {
130  status = attachTuple(filename,logname,typ,pSvc->repSvcType());
131  if ( status.isSuccess() ) {
132  m_connections.emplace(m_rootName+'/'+logname,Connection(pSvc));
133  return StatusCode::SUCCESS;
134  }
135  }
136  }
137  }
138  }
139  log << MSG::ERROR << "Cannot add " << ident << " invalid filename!" << endmsg;
140  return StatusCode::FAILURE;
141 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:74
virtual long repSvcType() const =0
Retrieve the class type of the data store the converter uses.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
StatusCode attachTuple(const std::string &filename, const std::string &logname, const char typ, const long t)
Attach output/input file.
Definition: NTupleSvc.cpp:470
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
void toupper(std::string &s)
virtual StatusCode createService(const std::string &nam, const std::string &typ, const std::vector< Prop > &props, IConversionSvc *&pSvc)
Create conversion service.
Connections m_connections
Container of connection points.
Definition: NTupleSvc.h:126
StatusCode TagCollectionSvc::createService ( const std::string &  nam,
const std::string &  typ,
const std::vector< Prop > &  props,
IConversionSvc *&  pSvc 
)
protectedvirtual

Create conversion service.

Parameters
namName of the service to be created
svcService type if sepecified in the options
props

Definition at line 144 of file TagCollectionSvc.cpp.

147  {
148  pSvc = nullptr;
150  auto mgr = serviceLocator()->as<ISvcManager>();
151 
152  // TagCollectionSvc has to directly create a ConversionSvc to manage it directly.
153  StatusCode status = NO_INTERFACE;
154  if ( mgr ) {
155  SmartIF<IService> isvc = mgr->createService(TypeNameString(nam, typ));
156  if (isvc) {
157  auto icsvc = isvc.as<IConversionSvc>();
158  if ( icsvc ) {
159  auto iprop = isvc.as<IProperty>();
160  if ( iprop ) {
161  for ( const auto& p : props ) {
162  iprop->setProperty(p.first, p.second).ignore();
163  }
164  // NTupleSvc has to directly create a ConversionSvc to manage it directly.
165  status = isvc->sysInitialize();
166  if ( status.isSuccess() ) {
167  status = icsvc->setDataProvider(this);
168  if ( status.isSuccess() ) {
169  pSvc = icsvc.get();
170  pSvc->addRef();
171  }
172  }
173  }
174  }
175  }
176  }
177  return status;
178 }
The ISvcManager is the interface implemented by the Service Factory in the Application Manager to sup...
Definition: ISvcManager.h:28
virtual StatusCode sysInitialize()=0
Initialize Service.
SmartIF< IFace > as() const
return a new SmartIF instance to another interface
Definition: SmartIF.h:110
Helper class to parse a string of format "type/name".
Definition: TypeNameString.h:9
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
virtual StatusCode setProperty(const Property &p)=0
Set the property by property.
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
void ignore() const
Definition: StatusCode.h:108
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:21

The documentation for this class was generated from the following files: