Gaudi::MultiFileCatalog Class Reference

This class constitutes the core of the XML based FileCatalog API for using POOL within Gaudi. More...

#include <src/component/MultiFileCatalog.h>

Inheritance diagram for Gaudi::MultiFileCatalog:
Collaboration diagram for Gaudi::MultiFileCatalog:

Public Types

typedef Service::Factory Factory
 
- Public Types inherited from extends< Service, IFileCatalog, IFileCatalogMgr >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces...>
 Typedef to the base of this class. More...
 
- Public Types inherited from Service
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > Factory
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class = CommonMessaging
 
- 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...
 

Public Member Functions

 MultiFileCatalog (const std::string &nam, ISvcLocator *svc)
 Create a catalog file, initialization of XercesC. More...
 
 ~MultiFileCatalog () override=default
 Destructor,. More...
 
StatusCode initialize () override
 IService implementation. More...
 
StatusCode finalize () override
 Finalize service object. More...
 
std::string createFID () const override
 Catalog interface. More...
 
CSTR connectInfo () const override
 Access to connect string. More...
 
void init () override
 Parse the DOM tree of the XML catalog. More...
 
void commit () override
 Save DOM catalog to file. More...
 
void rollback () override
 Save DOM catalog to file. More...
 
bool readOnly () const override
 Check if the catalog is read-only. More...
 
bool dirty () const override
 Check if the catalog should be updated. More...
 
bool existsPFN (CSTR pfn) const override
 Return the status of physical file name. More...
 
std::string lookupPFN (CSTR pfn) const override
 Lookup file identifier by physical file name. More...
 
bool existsLFN (CSTR lfn) const override
 Return the status of a logical file name. More...
 
std::string lookupLFN (CSTR lfn) const override
 Lookup file identifier by logical file name. More...
 
bool existsFID (CSTR fid) const override
 Return the status of a FileID. More...
 
void getPFN (CSTR fid, Files &files) const override
 Dump all physical file names of the catalog and their attributes associate to the FileID. More...
 
void getLFN (CSTR fid, Files &files) const override
 Dump all logical file names of the catalog associate to the FileID. More...
 
void getFID (Strings &fids) const override
 Dump all file Identifiers. More...
 
void deleteFID (CSTR fid) const override
 Delete FileID from the catalog. More...
 
void registerPFN (CSTR fid, CSTR pfn, CSTR ftype) const override
 Create a FileID and DOM Node of the PFN with all the attributes. More...
 
void registerLFN (CSTR fid, CSTR lfn) const override
 Create a FileID and DOM Node of the LFN with all the attributes. More...
 
void registerFID (CSTR fid) const override
 Create a FileID and DOM Node. More...
 
void getMetaData (CSTR fid, Attributes &attr) const override
 Dump all MetaData of the catalog for a given file ID. More...
 
std::string getMetaDataItem (CSTR fid, CSTR name) const override
 Access metadata item. More...
 
void setMetaData (CSTR fid, CSTR attr, CSTR val) const override
 Insert/update metadata item. More...
 
void dropMetaData (CSTR fid) const override
 Drop all metadata of one FID. More...
 
void dropMetaData (CSTR fid, CSTR attr) const override
 Drop specified metadata item. More...
 
IFileCatalogfindCatalog (CSTR connect, bool must_be_writable) const override
 Catalog management. More...
 
void addCatalog (CSTR connect) override
 Add new catalog identified by name to the existing ones. More...
 
void addCatalog (IFileCatalog *cat) override
 Add new catalog identified by reference to the existing ones. More...
 
void removeCatalog (CSTR connect) override
 Remove catalog identified by name from the existing ones. More...
 
void removeCatalog (const IFileCatalog *cat) override
 Remove catalog identified by reference from the existing ones. More...
 
Catalogscatalogs () override
 Access catalog container. More...
 
const Catalogscatalogs () const override
 Access catalog container (CONST) More...
 
IFileCatalogwriteCatalog (CSTR fid="") const override
 Access to the (first) writable file catalog. More...
 
void setWriteCatalog (IFileCatalog *cat) override
 Define the writable catalog identified by reference. More...
 
void setWriteCatalog (CSTR connect) override
 Define the writable catalog identified by name. More...
 
- Public Member Functions inherited from extends< Service, IFileCatalog, IFileCatalogMgr >
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::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
- Public Member Functions inherited from Service
const std::stringname () const override
 Retrieve name of the service. More...
 
StatusCode configure () override
 
StatusCode initialize () override
 
StatusCode start () override
 
StatusCode stop () override
 
StatusCode finalize () override
 
StatusCode terminate () override
 
Gaudi::StateMachine::State FSMState () const override
 
Gaudi::StateMachine::State targetFSMState () const override
 
StatusCode reinitialize () override
 
StatusCode restart () override
 
StatusCode sysInitialize () override
 Initialize Service. More...
 
StatusCode sysStart () override
 Initialize Service. More...
 
StatusCode sysStop () override
 Initialize Service. More...
 
StatusCode sysFinalize () override
 Finalize Service. More...
 
StatusCode sysReinitialize () override
 Re-initialize the Service. More...
 
StatusCode sysRestart () override
 Re-initialize the Service. More...
 
StatusCode setProperty (const Property &p) override
 
StatusCode setProperty (const std::string &s) override
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 
StatusCode getProperty (Property *p) const override
 
const PropertygetProperty (const std::string &name) const override
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 
const std::vector< Property * > & getProperties () const override
 
bool hasProperty (const std::string &name) const override
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator. More...
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job. More...
 
template<class T >
StatusCode service (const std::string &name, const T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist. More...
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties. More...
 
template<class T >
StatusCode declarePrivateTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 Declare used Private tool. More...
 
template<class T >
StatusCode declarePublicTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 Declare used Public tool. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const __attribute__((deprecated))
 Backward compatibility function for getting the output level. More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces...>
 ~extend_interfaces () override=default
 Virtual destructor. More...
 

Protected Types

typedef const std::stringCSTR
 
typedef std::vector< IFileCatalog * > Catalogs
 
typedef std::vector< std::stringCatalogNames
 

Protected Member Functions

template<class A1 , class F >
std::string _find (A1 &arg1, F pmf) const
 
template<class A1 , class F >
void _collect (A1 &arg1, F f) const
 
template<class A2 , class A1 , class F >
void _collect (const A2 &arg2, A1 &arg1, F f) const
 
- Protected Member Functions inherited from Service
 ~Service () override
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 

Private Member Functions

IFileCataloggetCatalog (CSTR fid, bool throw_if_not, bool writable=true, bool prt=true) const
 Find catalog containing a given file identifier. More...
 
Catalogs::iterator i_findCatalog (CSTR connect, bool must_be_writable)
 Find catalog by connect string. More...
 
void propHandler (Property &)
 simple property handle to allow interactive modification of list of the file catalogs More...
 
void printError (CSTR msg, bool throw_exc=true) const
 
std::string lookupFID (CSTR lfn) const
 

Private Attributes

Catalogs m_catalogs
 Container with references to known catalogs. More...
 
CatalogNames m_catalogNames = { { "xmlcatalog_file:test_catalog.xml" } }
 Property : Container with catalog names. More...
 
bool m_started = false
 Flag to indicate if catalog is started. More...
 
CatalogNames m_oldNames
 BACKUP:: Container with catalog names. More...
 

Additional Inherited Members

- Protected Attributes inherited from Service
IntegerProperty m_outputLevel = MSG::NIL
 Service output level. More...
 
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state. More...
 

Detailed Description

This class constitutes the core of the XML based FileCatalog API for using POOL within Gaudi.

This class manages multiple file catalogs.

Definition at line 20 of file MultiFileCatalog.h.

Member Typedef Documentation

typedef std::vector<std::string> Gaudi::MultiFileCatalog::CatalogNames
protected

Definition at line 31 of file MultiFileCatalog.h.

typedef std::vector<IFileCatalog*> Gaudi::MultiFileCatalog::Catalogs
protected

Definition at line 30 of file MultiFileCatalog.h.

typedef const std::string& Gaudi::MultiFileCatalog::CSTR
protected

Definition at line 29 of file MultiFileCatalog.h.

typedef Service::Factory Gaudi::MultiFileCatalog::Factory

Definition at line 26 of file MultiFileCatalog.h.

Constructor & Destructor Documentation

MultiFileCatalog::MultiFileCatalog ( const std::string nam,
ISvcLocator svc 
)

Create a catalog file, initialization of XercesC.

Definition at line 24 of file MultiFileCatalog.cpp.

25  : base_class(nam, svc)
26 {
27  declareProperty("Catalogs", m_catalogNames, "The list of Catalogs")
28  -> declareUpdateHandler ( &Gaudi::MultiFileCatalog::propHandler, this ) ;
29 }
void propHandler(Property &)
simple property handle to allow interactive modification of list of the file catalogs ...
extends base_class
Typedef to this class.
Definition: extends.h:14
CatalogNames m_catalogNames
Property : Container with catalog names.
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Service.h:215
Gaudi::MultiFileCatalog::~MultiFileCatalog ( )
overridedefault

Destructor,.

Member Function Documentation

template<class A1 , class F >
void Gaudi::MultiFileCatalog::_collect ( A1 &  arg1,
f 
) const
inlineprotected

Definition at line 41 of file MultiFileCatalog.h.

41  {
42  A1 tmp;
43  for(const auto & i : m_catalogs ) {
44  f(i,tmp); // tmp = f(i)
45  arg1.insert(arg1.end(),tmp.begin(),tmp.end());
46  tmp.clear();
47  }
48  }
Catalogs m_catalogs
Container with references to known catalogs.
list i
Definition: ana.py:128
template<class A2 , class A1 , class F >
void Gaudi::MultiFileCatalog::_collect ( const A2 &  arg2,
A1 &  arg1,
f 
) const
inlineprotected

Definition at line 49 of file MultiFileCatalog.h.

49  {
50  A1 tmp;
51  for(const auto& i : m_catalogs ) {
52  f(i,arg2,tmp); // tmp = f(i,arg2)
53  arg1.insert(arg1.end(),tmp.begin(),tmp.end());
54  tmp.clear();
55  }
56  }
Catalogs m_catalogs
Container with references to known catalogs.
list i
Definition: ana.py:128
template<class A1 , class F >
std::string Gaudi::MultiFileCatalog::_find ( A1 &  arg1,
pmf 
) const
inlineprotected

Definition at line 33 of file MultiFileCatalog.h.

33  {
34  std::string result;
35  for(const auto& i : m_catalogs ) {
36  result= (i->*pmf)(arg1);
37  if ( !result.empty() ) break;
38  }
39  return result;
40  }
T empty(T...args)
STL class.
Catalogs m_catalogs
Container with references to known catalogs.
list i
Definition: ana.py:128
void MultiFileCatalog::addCatalog ( CSTR  connect)
override

Add new catalog identified by name to the existing ones.

Catalog is already present ... silently ignore request

Definition at line 117 of file MultiFileCatalog.cpp.

117  {
118  if ( !con.empty() ) {
119  if ( !findCatalog(con,false) ) {
120  static const string xml_typ = "Gaudi::XMLFileCatalog";
121  auto id0 = con.find("_");
122  string typ = con.substr(0,id0);
123  string url = con.substr(id0+1);
124  IInterface* cat = nullptr;
125  if ( strncasecmp("xml",typ.c_str(),3) == 0 ) {
126  cat = IFileCatalog::Factory::create(xml_typ,url,msgSvc().get());
127  } else {
129  Registry& registry = Registry::instance();
130  if (registry.getInfo(typ).type ==
131  typeid(Service::Factory::FuncType).name()) {
132  cat = Service::Factory::create(typ,url,serviceLocator().get());
133  } else if (registry.getInfo(typ).type ==
134  typeid(IFileCatalog::Factory::FuncType).name()) {
135  cat = IFileCatalog::Factory::create(typ,url,msgSvc().get());
136  }
137  }
138  if ( cat ) {
139  auto fileCat = SmartIF<IFileCatalog>( cat ) ;
140  if ( fileCat ) {
141  addCatalog(fileCat.get()); //addCatalog will take care of the refCount of fileCat...
142  return;
143  }
144  }
145  printError("Failed to create catalog connection:"+con,true);
146  }
148  return;
149  }
150  printError("Got invalid (empty) catalog connection string.",true);
151 }
Small smart pointer class with automatic reference counting for IInterface.
Definition: IConverter.h:14
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:324
IFileCatalog * findCatalog(CSTR connect, bool must_be_writable) const override
Catalog management.
void printError(CSTR msg, bool throw_exc=true) const
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
Definition of the basic interface.
Definition: IInterface.h:234
T c_str(T...args)
void addCatalog(CSTR connect) override
Add new catalog identified by name to the existing ones.
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
In-memory database of the loaded factories.
void MultiFileCatalog::addCatalog ( IFileCatalog cat)
override

Add new catalog identified by reference to the existing ones.

Definition at line 153 of file MultiFileCatalog.cpp.

153  {
154  if ( cat ) {
155  cat->addRef();
156  m_catalogs.push_back(cat);
157  return;
158  }
159  printError("Got invalid catalog to be added to multi catalog.",true);
160 }
void printError(CSTR msg, bool throw_exc=true) const
T push_back(T...args)
Catalogs m_catalogs
Container with references to known catalogs.
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
Catalogs& Gaudi::MultiFileCatalog::catalogs ( )
inlineoverride

Access catalog container.

Definition at line 146 of file MultiFileCatalog.h.

146 { return m_catalogs; }
Catalogs m_catalogs
Container with references to known catalogs.
const Catalogs& Gaudi::MultiFileCatalog::catalogs ( ) const
inlineoverride

Access catalog container (CONST)

Definition at line 148 of file MultiFileCatalog.h.

148 { return m_catalogs; }
Catalogs m_catalogs
Container with references to known catalogs.
void MultiFileCatalog::commit ( )
override

Save DOM catalog to file.

Definition at line 244 of file MultiFileCatalog.cpp.

245 { for_each(m_catalogs,[](IFileCatalog* i) { i->commit(); } ); }
virtual void commit()=0
Save catalog to file.
Catalogs m_catalogs
Container with references to known catalogs.
File catalog interface.
Definition: IFileCatalog.h:24
T for_each(T...args)
list i
Definition: ana.py:128
MultiFileCatalog::CSTR MultiFileCatalog::connectInfo ( ) const
override

Access to connect string.

Definition at line 64 of file MultiFileCatalog.cpp.

64  {
65  static const string s("MultiCatalog");
66  return s;
67 }
string s
Definition: gaudirun.py:245
std::string MultiFileCatalog::createFID ( ) const
override

Catalog interface.

Create file identifier using UUID mechanism.

Create file identifier using UUID mechanism

Definition at line 60 of file MultiFileCatalog.cpp.

60  {
61  return createGuidAsString();
62 }
std::string createGuidAsString()
Create file identifier using UUID mechanism.
void Gaudi::MultiFileCatalog::deleteFID ( CSTR  fid) const
inlineoverride

Delete FileID from the catalog.

Definition at line 110 of file MultiFileCatalog.h.

111  { writeCatalog(fid)->deleteFID(fid); }
virtual void deleteFID(const std::string &FileID) const =0
Delete FileID Node from the catalog.
IFileCatalog * writeCatalog(CSTR fid="") const override
Access to the (first) writable file catalog.
bool MultiFileCatalog::dirty ( ) const
override

Check if the catalog should be updated.

Definition at line 236 of file MultiFileCatalog.cpp.

238  [](const IFileCatalog* i) { return i->dirty();} ) ;
239 }
T end(T...args)
Catalogs m_catalogs
Container with references to known catalogs.
File catalog interface.
Definition: IFileCatalog.h:24
T begin(T...args)
T any_of(T...args)
list i
Definition: ana.py:128
virtual bool dirty() const =0
Check if the catalog should be updated.
void Gaudi::MultiFileCatalog::dropMetaData ( CSTR  fid) const
inlineoverride

Drop all metadata of one FID.

Definition at line 128 of file MultiFileCatalog.h.

129  { writeCatalog(fid)->dropMetaData(fid); }
virtual void dropMetaData(const std::string &fid) const =0
Drop all metadata of one FID.
IFileCatalog * writeCatalog(CSTR fid="") const override
Access to the (first) writable file catalog.
void Gaudi::MultiFileCatalog::dropMetaData ( CSTR  fid,
CSTR  attr 
) const
inlineoverride

Drop specified metadata item.

Definition at line 131 of file MultiFileCatalog.h.

132  { writeCatalog(fid)->dropMetaData(fid,attr); }
virtual void dropMetaData(const std::string &fid) const =0
Drop all metadata of one FID.
IFileCatalog * writeCatalog(CSTR fid="") const override
Access to the (first) writable file catalog.
bool Gaudi::MultiFileCatalog::existsFID ( CSTR  fid) const
inlineoverride

Return the status of a FileID.

Definition at line 97 of file MultiFileCatalog.h.

98  { return 0 != getCatalog(fid,false,false,false); }
IFileCatalog * getCatalog(CSTR fid, bool throw_if_not, bool writable=true, bool prt=true) const
Find catalog containing a given file identifier.
bool Gaudi::MultiFileCatalog::existsLFN ( CSTR  lfn) const
inlineoverride

Return the status of a logical file name.

Definition at line 91 of file MultiFileCatalog.h.

92  { return !lookupLFN(lfn).empty(); }
T empty(T...args)
std::string lookupLFN(CSTR lfn) const override
Lookup file identifier by logical file name.
bool Gaudi::MultiFileCatalog::existsPFN ( CSTR  pfn) const
inlineoverride

Return the status of physical file name.

Definition at line 85 of file MultiFileCatalog.h.

86  { return !lookupPFN(pfn).empty(); }
T empty(T...args)
std::string lookupPFN(CSTR pfn) const override
Lookup file identifier by physical file name.
StatusCode MultiFileCatalog::finalize ( )
override

Finalize service object.

Definition at line 51 of file MultiFileCatalog.cpp.

51  {
52  commit();
53  for_each(m_catalogs, [](IFileCatalog* i) { i->release(); } );
54  m_catalogs.clear();
55  m_started = false;
56  return Service::finalize();
57 }
bool m_started
Flag to indicate if catalog is started.
StatusCode finalize() override
Definition: Service.cpp:193
Catalogs m_catalogs
Container with references to known catalogs.
T clear(T...args)
File catalog interface.
Definition: IFileCatalog.h:24
virtual unsigned long release()=0
Release Interface instance.
T for_each(T...args)
void commit() override
Save DOM catalog to file.
list i
Definition: ana.py:128
IFileCatalog * MultiFileCatalog::findCatalog ( CSTR  connect,
bool  must_be_writable 
) const
override

Catalog management.

Find catalog by connect string

Definition at line 88 of file MultiFileCatalog.cpp.

88  {
90  [&](const IFileCatalog* f){
91  return connect == f->connectInfo();
92  } );
93  return ( i!=m_catalogs.end() &&
94  ( !must_be_writable || !(*i)->readOnly() ) ) ? *i : nullptr;
95 }
T end(T...args)
Catalogs m_catalogs
Container with references to known catalogs.
File catalog interface.
Definition: IFileCatalog.h:24
T find_if(T...args)
T begin(T...args)
list i
Definition: ana.py:128
IFileCatalog * MultiFileCatalog::getCatalog ( CSTR  fid,
bool  throw_if_not,
bool  writable = true,
bool  prt = true 
) const
private

Find catalog containing a given file identifier.

Definition at line 69 of file MultiFileCatalog.cpp.

73 {
74  for( const auto& c : m_catalogs ) {
75  if ( !c || ( writable && c->readOnly() )) continue;
76  if ( fid.empty() || ( !fid.empty() && c->existsFID(fid) ) )
77  return c;
78  }
79  if ( prt ) {
80  printError("No writable file catalog found which contains FID:"+fid,throw_if_not);
81  }
82  else {
83  debug() << "No writable file catalog found which contains FID:" << fid << endmsg;
84  }
85  return nullptr;
86 }
T empty(T...args)
tuple c
Definition: gaudirun.py:391
void printError(CSTR msg, bool throw_exc=true) const
Catalogs m_catalogs
Container with references to known catalogs.
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
void Gaudi::MultiFileCatalog::getFID ( Strings &  fids) const
inlineoverride

Dump all file Identifiers.

Definition at line 107 of file MultiFileCatalog.h.

virtual void getFID(Strings &fids) const =0
Dump all file Identifiers.
void _collect(A1 &arg1, F f) const
T mem_fn(T...args)
void Gaudi::MultiFileCatalog::getLFN ( CSTR  fid,
Files &  files 
) const
inlineoverride

Dump all logical file names of the catalog associate to the FileID.

Definition at line 103 of file MultiFileCatalog.h.

104  { _collect(fid,files,std::mem_fn(&IFileCatalog::getLFN)); }
void _collect(A1 &arg1, F f) const
virtual void getLFN(const std::string &fid, Files &files) const =0
Dump all LFNames of the catalog associate to the FileID.
T mem_fn(T...args)
void Gaudi::MultiFileCatalog::getMetaData ( CSTR  fid,
Attributes &  attr 
) const
inlineoverride

Dump all MetaData of the catalog for a given file ID.

Definition at line 120 of file MultiFileCatalog.h.

virtual void getMetaData(const std::string &fid, Attributes &attr) const =0
Dump all MetaData of the catalog for a given file ID.
void _collect(A1 &arg1, F f) const
T mem_fn(T...args)
string MultiFileCatalog::getMetaDataItem ( CSTR  fid,
CSTR  name 
) const
override

Access metadata item.

Definition at line 210 of file MultiFileCatalog.cpp.

210  {
211  std::string result;
212  for(const auto& i : m_catalogs ) {
213  result = i->getMetaDataItem(fid,attr);
214  if ( !result.empty() ) break;
215  }
216  return result;
217 }
T empty(T...args)
STL class.
Catalogs m_catalogs
Container with references to known catalogs.
list i
Definition: ana.py:128
void Gaudi::MultiFileCatalog::getPFN ( CSTR  fid,
Files &  files 
) const
inlineoverride

Dump all physical file names of the catalog and their attributes associate to the FileID.

Definition at line 100 of file MultiFileCatalog.h.

101  { _collect(fid,files,std::mem_fn(&IFileCatalog::getPFN)); }
virtual void getPFN(const std::string &fid, Files &files) const =0
Dump all PFNames of the catalog and their attributes associate to the FileID.
void _collect(A1 &arg1, F f) const
T mem_fn(T...args)
MultiFileCatalog::Catalogs::iterator MultiFileCatalog::i_findCatalog ( CSTR  connect,
bool  must_be_writable 
)
private

Find catalog by connect string.

Definition at line 98 of file MultiFileCatalog.cpp.

98  {
100  [&](const IFileCatalog* f){
101  return connect == f->connectInfo();
102  } );
103  if ( i!=m_catalogs.end() && must_be_writable && (*i)->readOnly() ) {
104  i = m_catalogs.end();
105  }
106  return i;
107 }
T end(T...args)
Catalogs m_catalogs
Container with references to known catalogs.
File catalog interface.
Definition: IFileCatalog.h:24
T find_if(T...args)
T begin(T...args)
virtual bool readOnly() const =0
Check if the catalog is read-only.
list i
Definition: ana.py:128
void MultiFileCatalog::init ( )
override

Parse the DOM tree of the XML catalog.

Definition at line 241 of file MultiFileCatalog.cpp.

242 { for_each(m_catalogs,[](IFileCatalog* i) { i->init(); }); m_started=true; }
bool m_started
Flag to indicate if catalog is started.
Catalogs m_catalogs
Container with references to known catalogs.
File catalog interface.
Definition: IFileCatalog.h:24
virtual void init()=0
Parse the DOM tree of the XML catalog.
T for_each(T...args)
list i
Definition: ana.py:128
StatusCode MultiFileCatalog::initialize ( )
override

IService implementation.

Finalize service object

Definition at line 31 of file MultiFileCatalog.cpp.

31  {
32  if ( !Service::initialize().isSuccess() ) {
33  printError("Failed to initialize service base class.",false);
34  return StatusCode::SUCCESS;
35  }
36  std::string current;
37  try {
38  for(const auto& i : m_catalogNames ) {
39  current = i;
40  addCatalog(i);
41  }
42  init();
43  return StatusCode::SUCCESS;
44  }
45  catch(const std::exception& /* e */) {
46  printError("Cannot add file catalog:"+current,false);
47  }
48  return StatusCode::FAILURE;
49 }
StatusCode initialize() override
Definition: Service.cpp:68
void printError(CSTR msg, bool throw_exc=true) const
STL class.
CatalogNames m_catalogNames
Property : Container with catalog names.
STL class.
void init() override
Parse the DOM tree of the XML catalog.
void addCatalog(CSTR connect) override
Add new catalog identified by name to the existing ones.
list i
Definition: ana.py:128
std::string Gaudi::MultiFileCatalog::lookupFID ( CSTR  lfn) const
private
std::string Gaudi::MultiFileCatalog::lookupLFN ( CSTR  lfn) const
inlineoverride

Lookup file identifier by logical file name.

Definition at line 94 of file MultiFileCatalog.h.

95  { return _find(lfn,&IFileCatalog::lookupLFN); }
virtual std::string lookupLFN(const std::string &lfn) const =0
Lookup file identifier by physical file name.
std::string _find(A1 &arg1, F pmf) const
std::string Gaudi::MultiFileCatalog::lookupPFN ( CSTR  pfn) const
inlineoverride

Lookup file identifier by physical file name.

Definition at line 88 of file MultiFileCatalog.h.

89  { return _find(pfn,&IFileCatalog::lookupPFN); }
virtual std::string lookupPFN(const std::string &lfn) const =0
Lookup file identifier by physical file name.
std::string _find(A1 &arg1, F pmf) const
void MultiFileCatalog::printError ( CSTR  msg,
bool  throw_exc = true 
) const
private

Definition at line 109 of file MultiFileCatalog.cpp.

109  {
110  if ( rethrow ) {
111  fatal() << msg << endmsg;
112  throw runtime_error("Catalog> "+msg);
113  }
114  error() << msg << endmsg;
115 }
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
void MultiFileCatalog::propHandler ( Property )
private

simple property handle to allow interactive modification of list of the file catalogs

Definition at line 250 of file MultiFileCatalog.cpp.

251 {
252  // not yet initialized
253  if ( !m_started ) { m_oldNames = m_catalogNames; return; } // RETURN
254  // no real change - no action
255  if ( m_catalogNames == m_oldNames ) { return; }
257  // remove ALL catalogs
258  removeCatalog("") ;
259  // add new catalogs
260  for ( const auto& inew : m_catalogNames ) addCatalog ( inew ) ;
261  // start
262  init() ;
263  //
264  debug()
265  << "New catalogs to be used: "
266  << Gaudi::Utils::toString ( m_catalogNames ) << endmsg ;
267 }
bool m_started
Flag to indicate if catalog is started.
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:371
CatalogNames m_catalogNames
Property : Container with catalog names.
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
CatalogNames m_oldNames
BACKUP:: Container with catalog names.
void init() override
Parse the DOM tree of the XML catalog.
void addCatalog(CSTR connect) override
Add new catalog identified by name to the existing ones.
void removeCatalog(CSTR connect) override
Remove catalog identified by name from the existing ones.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
bool MultiFileCatalog::readOnly ( ) const
override

Check if the catalog is read-only.

Definition at line 231 of file MultiFileCatalog.cpp.

233  [](const IFileCatalog* i) { return i->readOnly(); } );
234 }
T end(T...args)
Catalogs m_catalogs
Container with references to known catalogs.
File catalog interface.
Definition: IFileCatalog.h:24
T begin(T...args)
T all_of(T...args)
virtual bool readOnly() const =0
Check if the catalog is read-only.
list i
Definition: ana.py:128
void Gaudi::MultiFileCatalog::registerFID ( CSTR  fid) const
inlineoverride

Create a FileID and DOM Node.

Definition at line 117 of file MultiFileCatalog.h.

118  { writeCatalog()->registerFID(fid); }
virtual void registerFID(const std::string &fid) const =0
Create a Node for a FileID and DOM Node.
IFileCatalog * writeCatalog(CSTR fid="") const override
Access to the (first) writable file catalog.
void MultiFileCatalog::registerLFN ( CSTR  fid,
CSTR  lfn 
) const
override

Create a FileID and DOM Node of the LFN with all the attributes.

Definition at line 225 of file MultiFileCatalog.cpp.

225  {
226  IFileCatalog* c = getCatalog(fid,false,true,false);
227  if ( !c ) c = getCatalog("",true,true,true);
228  c->registerLFN(fid, lfn);
229 }
tuple c
Definition: gaudirun.py:391
IFileCatalog * getCatalog(CSTR fid, bool throw_if_not, bool writable=true, bool prt=true) const
Find catalog containing a given file identifier.
virtual void registerLFN(const std::string &fid, const std::string &lfn) const =0
Create a Node for a FileID and DOM Node of the LFN with all the attributes.
File catalog interface.
Definition: IFileCatalog.h:24
void MultiFileCatalog::registerPFN ( CSTR  fid,
CSTR  pfn,
CSTR  ftype 
) const
override

Create a FileID and DOM Node of the PFN with all the attributes.

Definition at line 219 of file MultiFileCatalog.cpp.

219  {
220  IFileCatalog* c = getCatalog(fid,false,true,false);
221  if ( !c ) c = getCatalog("",true,true,true);
222  c->registerPFN(fid, pfn, ftype);
223 }
virtual void registerPFN(const std::string &fid, const std::string &pfn, const std::string &ftype) const =0
Create a Node for a FileID and DOM Node of the PFN with all the attributes.
tuple c
Definition: gaudirun.py:391
IFileCatalog * getCatalog(CSTR fid, bool throw_if_not, bool writable=true, bool prt=true) const
Find catalog containing a given file identifier.
File catalog interface.
Definition: IFileCatalog.h:24
void MultiFileCatalog::removeCatalog ( CSTR  connect)
override

Remove catalog identified by name from the existing ones.

Definition at line 162 of file MultiFileCatalog.cpp.

162  {
163  if ( con.empty() || con == "*" ) {
164  for_each(m_catalogs, [](IFileCatalog* i) { i->release(); } );
165  m_catalogs.clear();
166  return;
167  }
168  removeCatalog(findCatalog(con,false));
169 }
IFileCatalog * findCatalog(CSTR connect, bool must_be_writable) const override
Catalog management.
Catalogs m_catalogs
Container with references to known catalogs.
T clear(T...args)
File catalog interface.
Definition: IFileCatalog.h:24
virtual unsigned long release()=0
Release Interface instance.
T for_each(T...args)
list i
Definition: ana.py:128
void removeCatalog(CSTR connect) override
Remove catalog identified by name from the existing ones.
void MultiFileCatalog::removeCatalog ( const IFileCatalog cat)
override

Remove catalog identified by reference from the existing ones.

Definition at line 171 of file MultiFileCatalog.cpp.

171  {
172  if ( cat ) {
173  auto i=find(m_catalogs.begin(),m_catalogs.end(),cat);
174  if ( i != m_catalogs.end() ) {
175  (*i)->release();
176  m_catalogs.erase(i);
177  return;
178  }
179  printError("Unknown file catalog -- cannot be removed.",true);
180  }
181  printError("Invalid file catalog.",true);
182 }
void printError(CSTR msg, bool throw_exc=true) const
T end(T...args)
Catalogs m_catalogs
Container with references to known catalogs.
T erase(T...args)
T find(T...args)
T begin(T...args)
list i
Definition: ana.py:128
void MultiFileCatalog::rollback ( )
override

Save DOM catalog to file.

Definition at line 247 of file MultiFileCatalog.cpp.

248 { for_each(m_catalogs, [](IFileCatalog* i) { i->rollback(); } ); }
Catalogs m_catalogs
Container with references to known catalogs.
File catalog interface.
Definition: IFileCatalog.h:24
virtual void rollback()=0
Save catalog to file.
T for_each(T...args)
list i
Definition: ana.py:128
void Gaudi::MultiFileCatalog::setMetaData ( CSTR  fid,
CSTR  attr,
CSTR  val 
) const
inlineoverride

Insert/update metadata item.

Definition at line 125 of file MultiFileCatalog.h.

126  { writeCatalog(fid)->setMetaData(fid,attr,val); }
virtual void setMetaData(const std::string &fid, const std::string &name, const std::string &value) const =0
Insert/update metadata item.
IFileCatalog * writeCatalog(CSTR fid="") const override
Access to the (first) writable file catalog.
void MultiFileCatalog::setWriteCatalog ( IFileCatalog cat)
override

Define the writable catalog identified by reference.

Definition at line 184 of file MultiFileCatalog.cpp.

184  {
185  if ( cat ) {
186  if ( !cat->readOnly() ) {
187  auto i=find(m_catalogs.begin(),m_catalogs.end(),cat);
188  if ( i != m_catalogs.end() ) {
189  m_catalogs.erase(i);
191  return;
192  }
193  printError("The catalog "+cat->connectInfo()+" is not known.",true);
194  }
195  printError("The catalog "+cat->connectInfo()+" is not writable.",true);
196  }
197  printError("Invalid file catalog.",true);
198 }
void printError(CSTR msg, bool throw_exc=true) const
T end(T...args)
virtual const std::string & connectInfo() const =0
Access to connect string.
Catalogs m_catalogs
Container with references to known catalogs.
T erase(T...args)
T insert(T...args)
T find(T...args)
T begin(T...args)
virtual bool readOnly() const =0
Check if the catalog is read-only.
list i
Definition: ana.py:128
void MultiFileCatalog::setWriteCatalog ( CSTR  connect)
override

Define the writable catalog identified by name.

Definition at line 200 of file MultiFileCatalog.cpp.

200  {
201  auto i = i_findCatalog(connect,true);
202  if ( i == m_catalogs.end() ) {
203  addCatalog(connect);
204  setWriteCatalog(findCatalog(connect,true));
205  return;
206  }
207  setWriteCatalog(*i);
208 }
IFileCatalog * findCatalog(CSTR connect, bool must_be_writable) const override
Catalog management.
void setWriteCatalog(IFileCatalog *cat) override
Define the writable catalog identified by reference.
T end(T...args)
Catalogs::iterator i_findCatalog(CSTR connect, bool must_be_writable)
Find catalog by connect string.
Catalogs m_catalogs
Container with references to known catalogs.
void addCatalog(CSTR connect) override
Add new catalog identified by name to the existing ones.
list i
Definition: ana.py:128
IFileCatalog* Gaudi::MultiFileCatalog::writeCatalog ( CSTR  fid = "") const
inlineoverride

Access to the (first) writable file catalog.

Definition at line 150 of file MultiFileCatalog.h.

151  { return getCatalog(fid,true,true,false); }
IFileCatalog * getCatalog(CSTR fid, bool throw_if_not, bool writable=true, bool prt=true) const
Find catalog containing a given file identifier.

Member Data Documentation

CatalogNames Gaudi::MultiFileCatalog::m_catalogNames = { { "xmlcatalog_file:test_catalog.xml" } }
private

Property : Container with catalog names.

Definition at line 173 of file MultiFileCatalog.h.

Catalogs Gaudi::MultiFileCatalog::m_catalogs
private

Container with references to known catalogs.

Definition at line 171 of file MultiFileCatalog.h.

CatalogNames Gaudi::MultiFileCatalog::m_oldNames
private

BACKUP:: Container with catalog names.

Definition at line 177 of file MultiFileCatalog.h.

bool Gaudi::MultiFileCatalog::m_started = false
private

Flag to indicate if catalog is started.

Definition at line 175 of file MultiFileCatalog.h.


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