The Gaudi Framework  v29r0 (ff2e7097)
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 PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 Typedef used to refer to this class from derived classes, as in. More...
 
- 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...
 
 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 >
StatusCode declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
 Declare used 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 PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 PropertyHolder ()=default
 
 ~PropertyHolder () override=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none") const
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation. More...
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p) override
 set the property form another property More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 set the property from name and the value More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (const std::string &name) const override
 get the property by name More...
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 convert the property to the string More...
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties More...
 
bool hasProperty (const std::string &name) const override
 Return true if we have a property with the given name. More...
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, GaudiHandleBase &ref, const std::string &doc="none")
 Specializations for various GaudiHandles. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, GaudiHandleArrayBase &ref, const std::string &doc="none")
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, DataObjectHandleBase &ref, const std::string &doc="none")
 
- 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 PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
Gaudi::Details::PropertyBaseproperty (const std::string &name) const
 
- 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 (Details::PropertyBase &)
 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...
 
Gaudi::Property< CatalogNamesm_catalogNames
 
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
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::Property< int > m_outputLevel {this, "OutputLevel", MSG::NIL, "output level"}
 
Gaudi::Property< bool > m_auditInit {this, "AuditServices", false, "[[deprecated]] unused"}
 
Gaudi::Property< bool > m_auditorInitialize {this, "AuditInitialize", false, "trigger auditor on initialize()"}
 
Gaudi::Property< bool > m_auditorStart {this, "AuditStart", false, "trigger auditor on start()"}
 
Gaudi::Property< bool > m_auditorStop {this, "AuditStop", false, "trigger auditor on stop()"}
 
Gaudi::Property< bool > m_auditorFinalize {this, "AuditFinalize", false, "trigger auditor on finalize()"}
 
Gaudi::Property< bool > m_auditorReinitialize {this, "AuditReinitialize", false, "trigger auditor on reinitialize()"}
 
Gaudi::Property< bool > m_auditorRestart {this, "AuditRestart", false, "trigger auditor on restart()"}
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service. 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 21 of file MultiFileCatalog.h.

Member Typedef Documentation

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

Definition at line 30 of file MultiFileCatalog.h.

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

Definition at line 29 of file MultiFileCatalog.h.

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

Definition at line 28 of file MultiFileCatalog.h.

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

Definition at line 25 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 25 of file MultiFileCatalog.cpp.

25  : base_class( nam, svc )
26 {
27  m_catalogNames.declareUpdateHandler( &Gaudi::MultiFileCatalog::propHandler, this );
28 }
extends base_class
Typedef to this class.
Definition: extends.h:15
Gaudi::Property< CatalogNames > m_catalogNames
void propHandler(Details::PropertyBase &)
simple property handle to allow interactive modification of list of the file catalogs ...
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 43 of file MultiFileCatalog.h.

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

Definition at line 53 of file MultiFileCatalog.h.

54  {
55  A1 tmp;
56  for ( const auto& i : m_catalogs ) {
57  f( i, arg2, tmp ); // tmp = f(i,arg2)
58  arg1.insert( arg1.end(), tmp.begin(), tmp.end() );
59  tmp.clear();
60  }
61  }
Catalogs m_catalogs
Container with references to known catalogs.
template<class A1 , class F >
std::string Gaudi::MultiFileCatalog::_find ( A1 &  arg1,
pmf 
) const
inlineprotected

Definition at line 33 of file MultiFileCatalog.h.

34  {
35  std::string result;
36  for ( const auto& i : m_catalogs ) {
37  result = ( i->*pmf )( arg1 );
38  if ( !result.empty() ) break;
39  }
40  return result;
41  }
T empty(T...args)
STL class.
Catalogs m_catalogs
Container with references to known catalogs.
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 108 of file MultiFileCatalog.cpp.

109 {
110  if ( !con.empty() ) {
111  if ( !findCatalog( con, false ) ) {
112  static const string xml_typ = "Gaudi::XMLFileCatalog";
113  auto id0 = con.find( "_" );
114  string typ = con.substr( 0, id0 );
115  string url = con.substr( id0 + 1 );
116  IInterface* cat = nullptr;
117  if ( strncasecmp( "xml", typ.c_str(), 3 ) == 0 ) {
118  cat = IFileCatalog::Factory::create( xml_typ, url, msgSvc().get() );
119  } else {
121  Registry& registry = Registry::instance();
122  if ( registry.getInfo( typ ).type == typeid( Service::Factory::FuncType ).name() ) {
123  cat = Service::Factory::create( typ, url, serviceLocator().get() );
124  } else if ( registry.getInfo( typ ).type == typeid( IFileCatalog::Factory::FuncType ).name() ) {
125  cat = IFileCatalog::Factory::create( typ, url, msgSvc().get() );
126  }
127  }
128  if ( cat ) {
129  auto fileCat = SmartIF<IFileCatalog>( cat );
130  if ( fileCat ) {
131  addCatalog( fileCat.get() ); // addCatalog will take care of the refCount of fileCat...
132  return;
133  }
134  }
135  printError( "Failed to create catalog connection:" + con, true );
136  }
138  return;
139  }
140  printError( "Got invalid (empty) catalog connection string.", true );
141 }
Small smart pointer class with automatic reference counting for IInterface.
Definition: IConverter.h:15
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
void printError(CSTR msg, bool throw_exc=true) const
Definition of the basic interface.
Definition: IInterface.h:277
IFileCatalog * findCatalog(CSTR connect, bool must_be_writable) const override
Catalog management.
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.
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:292
void MultiFileCatalog::addCatalog ( IFileCatalog cat)
override

Add new catalog identified by reference to the existing ones.

Definition at line 143 of file MultiFileCatalog.cpp.

144 {
145  if ( cat ) {
146  cat->addRef();
147  m_catalogs.push_back( cat );
148  return;
149  }
150  printError( "Got invalid catalog to be added to multi catalog.", true );
151 }
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 150 of file MultiFileCatalog.h.

150 { 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 152 of file MultiFileCatalog.h.

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

Save DOM catalog to file.

Definition at line 247 of file MultiFileCatalog.cpp.

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

Access to connect string.

Definition at line 62 of file MultiFileCatalog.cpp.

63 {
64  static const string s( "MultiCatalog" );
65  return s;
66 }
string s
Definition: gaudirun.py:253
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 { return createGuidAsString(); }
std::string createGuidAsString()
Helper function creating file identifier using the UUID mechanism.
void Gaudi::MultiFileCatalog::deleteFID ( CSTR  fid) const
inlineoverride

Delete FileID from the catalog.

Definition at line 114 of file MultiFileCatalog.h.

114 { 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 235 of file MultiFileCatalog.cpp.

236 {
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:25
T begin(T...args)
T any_of(T...args)
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 134 of file MultiFileCatalog.h.

134 { 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 136 of file MultiFileCatalog.h.

136 { 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 99 of file MultiFileCatalog.h.

99 { 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 95 of file MultiFileCatalog.h.

95 { 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 91 of file MultiFileCatalog.h.

91 { 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 50 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:174
Catalogs m_catalogs
Container with references to known catalogs.
T clear(T...args)
File catalog interface.
Definition: IFileCatalog.h:25
virtual unsigned long release()=0
Release Interface instance.
T for_each(T...args)
void commit() override
Save DOM catalog to file.
IFileCatalog * MultiFileCatalog::findCatalog ( CSTR  connect,
bool  must_be_writable 
) const
override

Catalog management.

Find catalog by connect string

Definition at line 82 of file MultiFileCatalog.cpp.

83 {
85  [&]( const IFileCatalog* f ) { return connect == f->connectInfo(); } );
86  return ( i != m_catalogs.end() && ( !must_be_writable || !( *i )->readOnly() ) ) ? *i : nullptr;
87 }
T end(T...args)
Catalogs m_catalogs
Container with references to known catalogs.
File catalog interface.
Definition: IFileCatalog.h:25
T find_if(T...args)
T begin(T...args)
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 68 of file MultiFileCatalog.cpp.

69 {
70  for ( const auto& c : m_catalogs ) {
71  if ( !c || ( writable && c->readOnly() ) ) continue;
72  if ( fid.empty() || ( !fid.empty() && c->existsFID( fid ) ) ) return c;
73  }
74  if ( prt ) {
75  printError( "No writable file catalog found which contains FID:" + fid, throw_if_not );
76  } else {
77  debug() << "No writable file catalog found which contains FID:" << fid << endmsg;
78  }
79  return nullptr;
80 }
T empty(T...args)
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:209
void Gaudi::MultiFileCatalog::getFID ( Strings &  fids) const
inlineoverride

Dump all file Identifiers.

Definition at line 112 of file MultiFileCatalog.h.

112 { _collect( fids, std::mem_fn( &IFileCatalog::getFID ) ); }
void _collect(A1 &arg1, F f) const
virtual void getFID(Strings &fids) const =0
Dump all file Identifiers.
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 106 of file MultiFileCatalog.h.

107  {
108  _collect( fid, files, std::mem_fn( &IFileCatalog::getLFN ) );
109  }
virtual void getLFN(const std::string &fid, Files &files) const =0
Dump all LFNames of the catalog associate to the FileID.
void _collect(A1 &arg1, F f) const
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 122 of file MultiFileCatalog.h.

123  {
125  }
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 205 of file MultiFileCatalog.cpp.

206 {
207  std::string result;
208  for ( const auto& i : m_catalogs ) {
209  result = i->getMetaDataItem( fid, attr );
210  if ( !result.empty() ) break;
211  }
212  return result;
213 }
T empty(T...args)
STL class.
Catalogs m_catalogs
Container with references to known catalogs.
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 101 of file MultiFileCatalog.h.

102  {
103  _collect( fid, files, std::mem_fn( &IFileCatalog::getPFN ) );
104  }
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 89 of file MultiFileCatalog.cpp.

90 {
92  [&]( const IFileCatalog* f ) { return connect == f->connectInfo(); } );
93  if ( i != m_catalogs.end() && must_be_writable && ( *i )->readOnly() ) {
94  i = m_catalogs.end();
95  }
96  return i;
97 }
T end(T...args)
virtual bool readOnly() const =0
Check if the catalog is read-only.
Catalogs m_catalogs
Container with references to known catalogs.
File catalog interface.
Definition: IFileCatalog.h:25
T find_if(T...args)
T begin(T...args)
void MultiFileCatalog::init ( )
override

Parse the DOM tree of the XML catalog.

Definition at line 241 of file MultiFileCatalog.cpp.

242 {
243  for_each( m_catalogs, []( IFileCatalog* i ) { i->init(); } );
244  m_started = true;
245 }
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:25
virtual void init()=0
Parse the DOM tree of the XML catalog.
T for_each(T...args)
StatusCode MultiFileCatalog::initialize ( )
override

IService implementation.

Finalize service object

Definition at line 30 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  } catch ( const std::exception& /* e */ ) {
45  printError( "Cannot add file catalog:" + current, false );
46  }
47  return StatusCode::FAILURE;
48 }
StatusCode initialize() override
Definition: Service.cpp:64
void printError(CSTR msg, bool throw_exc=true) const
STL class.
Gaudi::Property< CatalogNames > m_catalogNames
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.
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 97 of file MultiFileCatalog.h.

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

Lookup file identifier by physical file name.

Definition at line 93 of file MultiFileCatalog.h.

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

Definition at line 99 of file MultiFileCatalog.cpp.

100 {
101  if ( rethrow ) {
102  fatal() << msg << endmsg;
103  throw runtime_error( "Catalog> " + msg );
104  }
105  error() << msg << endmsg;
106 }
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:209
void MultiFileCatalog::propHandler ( Details::PropertyBase )
private

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

Definition at line 257 of file MultiFileCatalog.cpp.

258 {
259  // not yet initialized
260  if ( !m_started ) {
262  return;
263  } // RETURN
264  // no real change - no action
265  if ( m_catalogNames == m_oldNames ) {
266  return;
267  }
269  // remove ALL catalogs
270  removeCatalog( "" );
271  // add new catalogs
272  for ( const auto& inew : m_catalogNames ) addCatalog( inew );
273  // start
274  init();
275  //
276  debug() << "New catalogs to be used: " << Gaudi::Utils::toString( m_catalogNames ) << endmsg;
277 }
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:346
Gaudi::Property< CatalogNames > m_catalogNames
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:209
bool MultiFileCatalog::readOnly ( ) const
override

Check if the catalog is read-only.

Definition at line 229 of file MultiFileCatalog.cpp.

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

Create a FileID and DOM Node.

Definition at line 120 of file MultiFileCatalog.h.

120 { 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 222 of file MultiFileCatalog.cpp.

223 {
224  IFileCatalog* c = getCatalog( fid, false, true, false );
225  if ( !c ) c = getCatalog( "", true, true, true );
226  c->registerLFN( fid, lfn );
227 }
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:25
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.
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 215 of file MultiFileCatalog.cpp.

216 {
217  IFileCatalog* c = getCatalog( fid, false, true, false );
218  if ( !c ) c = getCatalog( "", true, true, true );
219  c->registerPFN( fid, pfn, ftype );
220 }
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:25
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.
void MultiFileCatalog::removeCatalog ( CSTR  connect)
override

Remove catalog identified by name from the existing ones.

Definition at line 153 of file MultiFileCatalog.cpp.

154 {
155  if ( con.empty() || con == "*" ) {
156  for_each( m_catalogs, []( IFileCatalog* i ) { i->release(); } );
157  m_catalogs.clear();
158  return;
159  }
160  removeCatalog( findCatalog( con, false ) );
161 }
Catalogs m_catalogs
Container with references to known catalogs.
T clear(T...args)
File catalog interface.
Definition: IFileCatalog.h:25
IFileCatalog * findCatalog(CSTR connect, bool must_be_writable) const override
Catalog management.
virtual unsigned long release()=0
Release Interface instance.
T for_each(T...args)
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 163 of file MultiFileCatalog.cpp.

164 {
165  if ( cat ) {
166  auto i = find( m_catalogs.begin(), m_catalogs.end(), cat );
167  if ( i != m_catalogs.end() ) {
168  ( *i )->release();
169  m_catalogs.erase( i );
170  return;
171  }
172  printError( "Unknown file catalog -- cannot be removed.", true );
173  }
174  printError( "Invalid file catalog.", true );
175 }
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)
void MultiFileCatalog::rollback ( )
override

Save DOM catalog to file.

Definition at line 252 of file MultiFileCatalog.cpp.

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

Insert/update metadata item.

Definition at line 129 of file MultiFileCatalog.h.

130  {
131  writeCatalog( fid )->setMetaData( fid, attr, val );
132  }
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 177 of file MultiFileCatalog.cpp.

178 {
179  if ( cat ) {
180  if ( !cat->readOnly() ) {
181  auto i = find( m_catalogs.begin(), m_catalogs.end(), cat );
182  if ( i != m_catalogs.end() ) {
183  m_catalogs.erase( i );
184  m_catalogs.insert( m_catalogs.begin(), cat );
185  return;
186  }
187  printError( "The catalog " + cat->connectInfo() + " is not known.", true );
188  }
189  printError( "The catalog " + cat->connectInfo() + " is not writable.", true );
190  }
191  printError( "Invalid file catalog.", true );
192 }
void printError(CSTR msg, bool throw_exc=true) const
virtual const std::string & connectInfo() const =0
Access to connect string.
T end(T...args)
virtual bool readOnly() const =0
Check if the catalog is read-only.
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)
void MultiFileCatalog::setWriteCatalog ( CSTR  connect)
override

Define the writable catalog identified by name.

Definition at line 194 of file MultiFileCatalog.cpp.

195 {
196  auto i = i_findCatalog( connect, true );
197  if ( i == m_catalogs.end() ) {
198  addCatalog( connect );
199  setWriteCatalog( findCatalog( connect, true ) );
200  return;
201  }
202  setWriteCatalog( *i );
203 }
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.
IFileCatalog * findCatalog(CSTR connect, bool must_be_writable) const override
Catalog management.
void addCatalog(CSTR connect) override
Add new catalog identified by name to the existing ones.
IFileCatalog* Gaudi::MultiFileCatalog::writeCatalog ( CSTR  fid = "") const
inlineoverride

Access to the (first) writable file catalog.

Definition at line 154 of file MultiFileCatalog.h.

154 { 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

Gaudi::Property<CatalogNames> Gaudi::MultiFileCatalog::m_catalogNames
private
Initial value:
{
this, "Catalogs", {{"xmlcatalog_file:test_catalog.xml"}}, "catalog names"}

Definition at line 176 of file MultiFileCatalog.h.

Catalogs Gaudi::MultiFileCatalog::m_catalogs
private

Container with references to known catalogs.

Definition at line 174 of file MultiFileCatalog.h.

CatalogNames Gaudi::MultiFileCatalog::m_oldNames
private

BACKUP:: Container with catalog names.

Definition at line 182 of file MultiFileCatalog.h.

bool Gaudi::MultiFileCatalog::m_started = false
private

Flag to indicate if catalog is started.

Definition at line 180 of file MultiFileCatalog.h.


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