The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
Gaudi::MultiFileCatalog Class Reference

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

#include </builds/gaudi/Gaudi/GaudiUtils/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
 Typedef to this class.
 
using extend_interfaces_base
 Typedef to the base of this class.
 
- Public Types inherited from Service
using Factory = Gaudi::PluginService::Factory<IService*( const std::string&, ISvcLocator* )>
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using PropertyHolderImpl
 Typedef used to refer to this class from derived classes, as in.
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids
 take union of the ext_iids of all Interfaces...
 

Public Member Functions

StatusCode initialize () override
 IService implementation.
 
StatusCode finalize () override
 Finalize service object.
 
std::string createFID () const override
 Catalog interface.
 
CSTR connectInfo () const override
 Access to connect string.
 
void init () override
 Parse the DOM tree of the XML catalog.
 
void commit () override
 Save DOM catalog to file.
 
void rollback () override
 Save DOM catalog to file.
 
bool readOnly () const override
 Check if the catalog is read-only.
 
bool dirty () const override
 Check if the catalog should be updated.
 
bool existsPFN (CSTR pfn) const override
 Return the status of physical file name.
 
std::string lookupPFN (CSTR pfn) const override
 Lookup file identifier by physical file name.
 
bool existsLFN (CSTR lfn) const override
 Return the status of a logical file name.
 
std::string lookupLFN (CSTR lfn) const override
 Lookup file identifier by logical file name.
 
bool existsFID (CSTR fid) const override
 Return the status of a FileID.
 
void getPFN (CSTR fid, Files &files) const override
 Dump all physical file names of the catalog and their attributes associate to the FileID.
 
void getLFN (CSTR fid, Files &files) const override
 Dump all logical file names of the catalog associate to the FileID.
 
void getFID (Strings &fids) const override
 Dump all file Identifiers.
 
void deleteFID (CSTR fid) const override
 Delete FileID from the catalog.
 
void registerPFN (CSTR fid, CSTR pfn, CSTR ftype) const override
 Create a FileID and DOM Node of the PFN with all the attributes.
 
void registerLFN (CSTR fid, CSTR lfn) const override
 Create a FileID and DOM Node of the LFN with all the attributes.
 
void registerFID (CSTR fid) const override
 Create a FileID and DOM Node.
 
void renamePFN (CSTR pfn, CSTR newpfn) const override
 rename a PFN
 
void deletePFN (CSTR pfn) const override
 remove a PFN
 
void getMetaData (CSTR fid, Attributes &attr) const override
 Dump all MetaData of the catalog for a given file ID.
 
std::string getMetaDataItem (CSTR fid, CSTR name) const override
 Access metadata item.
 
void setMetaData (CSTR fid, CSTR attr, CSTR val) const override
 Insert/update metadata item.
 
void dropMetaData (CSTR fid) const override
 Drop all metadata of one FID.
 
void dropMetaData (CSTR fid, CSTR attr) const override
 Drop specified metadata item.
 
IFileCatalogfindCatalog (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.
 
void addCatalog (IFileCatalog *cat) override
 Add new catalog identified by reference to the existing ones.
 
void removeCatalog (CSTR connect) override
 Remove catalog identified by name from the existing ones.
 
void removeCatalog (const IFileCatalog *cat) override
 Remove catalog identified by reference from the existing ones.
 
Catalogscatalogs () override
 Access catalog container.
 
const Catalogscatalogs () const override
 Access catalog container (CONST)
 
IFileCatalogwriteCatalog (CSTR fid="") const override
 Access to the (first) writable file catalog.
 
void setWriteCatalog (IFileCatalog *cat) override
 Define the writable catalog identified by reference.
 
void setWriteCatalog (CSTR connect) override
 Define the writable catalog identified by name.
 
- Public Member Functions inherited from extends< Service, IFileCatalog, IFileCatalogMgr >
void const * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast.
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface.
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames.
 
- Public Member Functions inherited from Service
const std::string & name () const override
 Retrieve name of the service.
 
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.
 
StatusCode sysStart () override
 Initialize Service.
 
StatusCode sysStop () override
 Initialize Service.
 
StatusCode sysFinalize () override
 Finalize Service.
 
StatusCode sysReinitialize () override
 Re-initialize the Service.
 
StatusCode sysRestart () override
 Re-initialize the Service.
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor.
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator.
 
template<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, bool createIf=true) const
 
template<class T>
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none")
 
template<class T>
StatusCode declareTool (ToolHandle< T > &handle, bool createIf=true)
 
template<class T>
StatusCode declareTool (ToolHandle< T > &handle, const std::string &toolTypeAndName, bool createIf=true)
 Declare used tool.
 
template<class T>
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandleArray< T > &hndlArr, const std::string &doc="none")
 
template<class T>
void addToolsArray (ToolHandleArray< T > &hndlArr)
 
const std::vector< IAlgTool * > & tools () const
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked.
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property.
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals.
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string.
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property.
 
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.
 
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.
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property.
 
StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p) override
 set the property from another property with a different name
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property.
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals.
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string.
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
StatusCode setPropertyRepr (const std::string &n, const std::string &r) override
 set the property from name and value string representation
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property
 
const Gaudi::Details::PropertyBasegetProperty (std::string_view name) const override
 get the property by name
 
StatusCode getProperty (std::string_view n, std::string &v) const override
 convert the property to the string
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties
 
bool hasProperty (std::string_view name) const override
 Return true if we have a property with the given name.
 
Gaudi::Details::PropertyBaseproperty (std::string_view name) const
 \fixme property and bindPropertiesTo should be protected
 
void bindPropertiesTo (Gaudi::Interfaces::IOptionsSvc &optsSvc)
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
- Public Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level msgLevel () const
 get the cached level (originally extracted from the embedded MsgStream)
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor.
 
const SmartIF< IMessageSvc > & msgSvc () const
 The standard message service.
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream.
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts.
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS)
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL)
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING)
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO)
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG)
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE)
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO)
 

Protected Types

typedef const std::string & CSTR
 
typedef std::vector< IFileCatalog * > Catalogs
 
typedef std::vector< std::string > CatalogNames
 

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
std::vector< IAlgTool * > & tools ()
 
 ~Service () override
 
int outputLevel () const
 get the Service's output level
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level setUpMessaging () const
 Set up local caches.
 
MSG::Level resetMessaging ()
 Reinitialize internal states.
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream.
 

Private Member Functions

IFileCataloggetCatalog (CSTR fid, bool throw_if_not, bool writable=true, bool prt=true) const
 Find catalog containing a given file identifier.
 
Catalogs::iterator i_findCatalog (CSTR connect, bool must_be_writable)
 Find catalog by connect string.
 
void propHandler ()
 simple property handle to allow interactive modification of list of the file catalogs
 
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.
 
Gaudi::Property< CatalogNamesm_catalogNames
 
bool m_started = false
 Flag to indicate if catalog is started.
 
CatalogNames m_oldNames
 BACKUP:: Container with catalog names.
 

Additional Inherited Members

- Protected Attributes inherited from Service
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state.
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state.
 
Gaudi::Property< int > m_outputLevel { this, "OutputLevel", MSG::NIL, "output level" }
 flag indicating whether ToolHandle tools have been added to m_tools
 
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()" }
 
Gaudi::Property< bool > m_autoRetrieveTools
 
Gaudi::Property< bool > m_checkToolDeps
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service.
 

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 29 of file MultiFileCatalog.h.

Member Typedef Documentation

◆ CatalogNames

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

Definition at line 37 of file MultiFileCatalog.h.

◆ Catalogs

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

Definition at line 36 of file MultiFileCatalog.h.

◆ CSTR

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

Definition at line 35 of file MultiFileCatalog.h.

◆ Factory

Member Function Documentation

◆ _collect() [1/2]

template<class A1, class F>
void Gaudi::MultiFileCatalog::_collect ( A1 & arg1,
F 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, tmp ); // tmp = f(i)
53 arg1.insert( arg1.end(), tmp.begin(), tmp.end() );
54 tmp.clear();
55 }
56 }
Catalogs m_catalogs
Container with references to known catalogs.

◆ _collect() [2/2]

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

Definition at line 58 of file MultiFileCatalog.h.

58 {
59 A1 tmp;
60 for ( const auto& i : m_catalogs ) {
61 f( i, arg2, tmp ); // tmp = f(i,arg2)
62 arg1.insert( arg1.end(), tmp.begin(), tmp.end() );
63 tmp.clear();
64 }
65 }

◆ _find()

template<class A1, class F>
std::string Gaudi::MultiFileCatalog::_find ( A1 & arg1,
F pmf ) const
inlineprotected

Definition at line 40 of file MultiFileCatalog.h.

40 {
41 std::string result;
42 for ( const auto& i : m_catalogs ) {
43 result = ( i->*pmf )( arg1 );
44 if ( !result.empty() ) break;
45 }
46 return result;
47 }

◆ addCatalog() [1/2]

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 100 of file MultiFileCatalog.cpp.

100 {
101 if ( !con.empty() ) {
102 if ( !findCatalog( con, false ) ) {
103 static const string xml_typ = "Gaudi::XMLFileCatalog";
104 auto id0 = con.find( "_" );
105 string typ = con.substr( 0, id0 );
106 string url = con.substr( id0 + 1 );
107 IInterface* cat = nullptr;
108 if ( strncasecmp( "xml", typ.c_str(), 3 ) == 0 ) {
109 cat = IFileCatalog::Factory::create( xml_typ, url, msgSvc().get() ).release();
110 } else {
111 using Gaudi::PluginService::Details::Registry;
112 Registry& registry = Registry::instance();
113 if ( registry.getInfo( typ ).factory.type() == typeid( Service::Factory::FactoryType ) ) {
114 cat = Service::Factory::create( typ, url, serviceLocator().get() ).release();
115 } else if ( registry.getInfo( typ ).factory.type() == typeid( IFileCatalog::Factory::FactoryType ) ) {
116 cat = IFileCatalog::Factory::create( typ, url, msgSvc().get() ).release();
117 }
118 }
119 if ( cat ) {
120 auto fileCat = SmartIF<IFileCatalog>( cat );
121 if ( fileCat ) {
122 addCatalog( fileCat.get() ); // addCatalog will take care of the refCount of fileCat...
123 return;
124 }
125 }
126 printError( "Failed to create catalog connection:" + con, true );
127 }
129 return;
130 }
131 printError( "Got invalid (empty) catalog connection string.", true );
132}
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
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.
void printError(CSTR msg, bool throw_exc=true) const
virtual unsigned long release() const =0
Release Interface instance.
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition Service.cpp:336
get
decorate the vector of properties
Definition decorators.py:94

◆ addCatalog() [2/2]

void MultiFileCatalog::addCatalog ( IFileCatalog * cat)
override

Add new catalog identified by reference to the existing ones.

Definition at line 134 of file MultiFileCatalog.cpp.

134 {
135 if ( cat ) {
136 cat->addRef();
137 m_catalogs.push_back( cat );
138 return;
139 }
140 printError( "Got invalid catalog to be added to multi catalog.", true );
141}
virtual unsigned long addRef() const =0
Increment the reference count of Interface instance.

◆ catalogs() [1/2]

const Catalogs & Gaudi::MultiFileCatalog::catalogs ( ) const
inlineoverride

Access catalog container (CONST)

Definition at line 154 of file MultiFileCatalog.h.

154{ return m_catalogs; }

◆ catalogs() [2/2]

Catalogs & Gaudi::MultiFileCatalog::catalogs ( )
inlineoverride

Access catalog container.

Definition at line 152 of file MultiFileCatalog.h.

152{ return m_catalogs; }

◆ commit()

void MultiFileCatalog::commit ( )
override

Save DOM catalog to file.

Definition at line 227 of file MultiFileCatalog.cpp.

227 {
228 for_each( m_catalogs, []( IFileCatalog* i ) { i->commit(); } );
229}
virtual void commit()=0
Save catalog to file.
void for_each(ContainerOfSynced &c, Fun &&f)

◆ connectInfo()

MultiFileCatalog::CSTR MultiFileCatalog::connectInfo ( ) const
override

Access to connect string.

Definition at line 61 of file MultiFileCatalog.cpp.

61 {
62 static const string s( "MultiCatalog" );
63 return s;
64}

◆ createFID()

std::string MultiFileCatalog::createFID ( ) const
override

Catalog interface.

Create file identifier using UUID mechanism.

Create file identifier using UUID mechanism

Definition at line 59 of file MultiFileCatalog.cpp.

59{ return createGuidAsString(); }
std::string createGuidAsString()
Helper function creating file identifier using the UUID mechanism.

◆ deleteFID()

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.

◆ deletePFN()

void Gaudi::MultiFileCatalog::deletePFN ( CSTR pfn) const
inlineoverride

remove a PFN

Definition at line 124 of file MultiFileCatalog.h.

124{ writeCatalog()->deletePFN( pfn ); }
virtual void deletePFN(const std::string &pfn) const =0
remove a PFN

◆ dirty()

bool MultiFileCatalog::dirty ( ) const
override

Check if the catalog should be updated.

Definition at line 217 of file MultiFileCatalog.cpp.

217 {
218 return std::any_of( std::begin( m_catalogs ), std::end( m_catalogs ),
219 []( const IFileCatalog* i ) { return i->dirty(); } );
220}
virtual bool dirty() const =0
Check if the catalog should be updated.

◆ dropMetaData() [1/2]

void Gaudi::MultiFileCatalog::dropMetaData ( CSTR fid) const
inlineoverride

Drop all metadata of one FID.

Definition at line 136 of file MultiFileCatalog.h.

136{ writeCatalog( fid )->dropMetaData( fid ); }
virtual void dropMetaData(const std::string &fid) const =0
Drop all metadata of one FID.

◆ dropMetaData() [2/2]

void Gaudi::MultiFileCatalog::dropMetaData ( CSTR fid,
CSTR attr ) const
inlineoverride

Drop specified metadata item.

Definition at line 138 of file MultiFileCatalog.h.

138{ writeCatalog( fid )->dropMetaData( fid, attr ); }

◆ existsFID()

bool Gaudi::MultiFileCatalog::existsFID ( CSTR fid) const
inlineoverride

Return the status of a FileID.

Definition at line 101 of file MultiFileCatalog.h.

101{ 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.

◆ existsLFN()

bool Gaudi::MultiFileCatalog::existsLFN ( CSTR lfn) const
inlineoverride

Return the status of a logical file name.

Definition at line 97 of file MultiFileCatalog.h.

97{ return !lookupLFN( lfn ).empty(); }
std::string lookupLFN(CSTR lfn) const override
Lookup file identifier by logical file name.

◆ existsPFN()

bool Gaudi::MultiFileCatalog::existsPFN ( CSTR pfn) const
inlineoverride

Return the status of physical file name.

Definition at line 93 of file MultiFileCatalog.h.

93{ return !lookupPFN( pfn ).empty(); }
std::string lookupPFN(CSTR pfn) const override
Lookup file identifier by physical file name.

◆ finalize()

StatusCode MultiFileCatalog::finalize ( )
override

Finalize service object.

Definition at line 50 of file MultiFileCatalog.cpp.

50 {
51 commit();
52 for_each( m_catalogs, []( IFileCatalog* i ) { i->release(); } );
53 m_catalogs.clear();
54 m_started = false;
55 return Service::finalize();
56}
bool m_started
Flag to indicate if catalog is started.
void commit() override
Save DOM catalog to file.
StatusCode finalize() override
Definition Service.cpp:223

◆ findCatalog()

IFileCatalog * MultiFileCatalog::findCatalog ( CSTR connect,
bool must_be_writable ) const
override

Catalog management.

Find catalog by connect string

Definition at line 79 of file MultiFileCatalog.cpp.

79 {
80 auto i = std::find_if( m_catalogs.begin(), m_catalogs.end(),
81 [&]( const IFileCatalog* f ) { return connect == f->connectInfo(); } );
82 return ( i != m_catalogs.end() && ( !must_be_writable || !( *i )->readOnly() ) ) ? *i : nullptr;
83}

◆ getCatalog()

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 66 of file MultiFileCatalog.cpp.

66 {
67 for ( const auto& c : m_catalogs ) {
68 if ( !c || ( writable && c->readOnly() ) ) continue;
69 if ( fid.empty() || ( !fid.empty() && c->existsFID( fid ) ) ) return c;
70 }
71 if ( prt ) {
72 printError( "No writable file catalog found which contains FID:" + fid, throw_if_not );
73 } else {
74 debug() << "No writable file catalog found which contains FID:" << fid << endmsg;
75 }
76 return nullptr;
77}
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)

◆ getFID()

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 ) ); }
virtual void getFID(Strings &fids) const =0
Dump all file Identifiers.
void _collect(A1 &arg1, F f) const

◆ getLFN()

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 107 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.

◆ getMetaData()

void Gaudi::MultiFileCatalog::getMetaData ( CSTR fid,
Attributes & attr ) const
inlineoverride

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

Definition at line 126 of file MultiFileCatalog.h.

126 {
127 _collect( fid, attr, std::mem_fn( &IFileCatalog::getMetaData ) );
128 }
virtual void getMetaData(const std::string &fid, Attributes &attr) const =0
Dump all MetaData of the catalog for a given file ID.

◆ getMetaDataItem()

string MultiFileCatalog::getMetaDataItem ( CSTR fid,
CSTR name ) const
override

Access metadata item.

Definition at line 191 of file MultiFileCatalog.cpp.

191 {
192 std::string result;
193 for ( const auto& i : m_catalogs ) {
194 result = i->getMetaDataItem( fid, attr );
195 if ( !result.empty() ) break;
196 }
197 return result;
198}

◆ getPFN()

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 103 of file MultiFileCatalog.h.

103 {
104 _collect( fid, files, std::mem_fn( &IFileCatalog::getPFN ) );
105 }
virtual void getPFN(const std::string &fid, Files &files) const =0
Dump all PFNames of the catalog and their attributes associate to the FileID.

◆ i_findCatalog()

MultiFileCatalog::Catalogs::iterator MultiFileCatalog::i_findCatalog ( CSTR connect,
bool must_be_writable )
private

Find catalog by connect string.

Definition at line 85 of file MultiFileCatalog.cpp.

85 {
86 auto i = std::find_if( m_catalogs.begin(), m_catalogs.end(),
87 [&]( const IFileCatalog* f ) { return connect == f->connectInfo(); } );
88 if ( i != m_catalogs.end() && must_be_writable && ( *i )->readOnly() ) { i = m_catalogs.end(); }
89 return i;
90}

◆ init()

void MultiFileCatalog::init ( )
override

Parse the DOM tree of the XML catalog.

Definition at line 222 of file MultiFileCatalog.cpp.

222 {
223 for_each( m_catalogs, []( IFileCatalog* i ) { i->init(); } );
224 m_started = true;
225}
virtual void init()=0
Parse the DOM tree of the XML catalog.

◆ initialize()

StatusCode MultiFileCatalog::initialize ( )
override

IService implementation.

Finalize service object

Definition at line 33 of file MultiFileCatalog.cpp.

33 {
34 if ( !Service::initialize().isSuccess() ) {
35 printError( "Failed to initialize service base class.", false );
37 }
38 std::string current;
39 try {
40 for ( const auto& i : m_catalogNames ) {
41 current = i;
42 addCatalog( i );
43 }
44 init();
46 } catch ( const std::exception& /* e */ ) { printError( "Cannot add file catalog:" + current, false ); }
48}
Gaudi::Property< CatalogNames > m_catalogNames
void init() override
Parse the DOM tree of the XML catalog.
StatusCode initialize() override
Definition Service.cpp:118
constexpr static const auto SUCCESS
Definition StatusCode.h:99
constexpr static const auto FAILURE
Definition StatusCode.h:100

◆ lookupFID()

std::string Gaudi::MultiFileCatalog::lookupFID ( CSTR lfn) const
private

◆ lookupLFN()

std::string Gaudi::MultiFileCatalog::lookupLFN ( CSTR lfn) const
inlineoverride

Lookup file identifier by logical file name.

Definition at line 99 of file MultiFileCatalog.h.

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

◆ lookupPFN()

std::string Gaudi::MultiFileCatalog::lookupPFN ( CSTR pfn) const
inlineoverride

Lookup file identifier by physical file name.

Definition at line 95 of file MultiFileCatalog.h.

95{ return _find( pfn, &IFileCatalog::lookupPFN ); }
virtual std::string lookupPFN(const std::string &lfn) const =0
Lookup file identifier by physical file name.

◆ printError()

void MultiFileCatalog::printError ( CSTR msg,
bool throw_exc = true ) const
private

Definition at line 92 of file MultiFileCatalog.cpp.

92 {
93 if ( rethrow ) {
94 fatal() << msg << endmsg;
95 throw runtime_error( "Catalog> " + msg );
96 }
97 error() << msg << endmsg;
98}
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)

◆ propHandler()

void MultiFileCatalog::propHandler ( )
private

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

Definition at line 235 of file MultiFileCatalog.cpp.

235 {
236 // not yet initialized
237 if ( !m_started ) {
239 return;
240 } // RETURN
241 // no real change - no action
242 if ( m_catalogNames == m_oldNames ) { return; }
244 // remove ALL catalogs
245 removeCatalog( "" );
246 // add new catalogs
247 for ( const auto& inew : m_catalogNames ) addCatalog( inew );
248 // start
249 init();
250 //
251 debug() << "New catalogs to be used: " << Gaudi::Utils::toString( m_catalogNames ) << endmsg;
252}
void removeCatalog(CSTR connect) override
Remove catalog identified by name from the existing ones.
CatalogNames m_oldNames
BACKUP:: Container with catalog names.
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition ToStream.h:326

◆ readOnly()

bool MultiFileCatalog::readOnly ( ) const
override

Check if the catalog is read-only.

Definition at line 212 of file MultiFileCatalog.cpp.

212 {
213 return std::all_of( std::begin( m_catalogs ), std::end( m_catalogs ),
214 []( const IFileCatalog* i ) { return i->readOnly(); } );
215}
virtual bool readOnly() const =0
Check if the catalog is read-only.

◆ registerFID()

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.

◆ registerLFN()

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 206 of file MultiFileCatalog.cpp.

206 {
207 IFileCatalog* c = getCatalog( fid, false, true, false );
208 if ( !c ) c = getCatalog( "", true, true, true );
209 c->registerLFN( fid, lfn );
210}

◆ registerPFN()

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 200 of file MultiFileCatalog.cpp.

200 {
201 IFileCatalog* c = getCatalog( fid, false, true, false );
202 if ( !c ) c = getCatalog( "", true, true, true );
203 c->registerPFN( fid, pfn, ftype );
204}

◆ removeCatalog() [1/2]

void MultiFileCatalog::removeCatalog ( const IFileCatalog * cat)
override

Remove catalog identified by reference from the existing ones.

Definition at line 152 of file MultiFileCatalog.cpp.

152 {
153 if ( cat ) {
154 auto i = find( m_catalogs.begin(), m_catalogs.end(), cat );
155 if ( i != m_catalogs.end() ) {
156 ( *i )->release();
157 m_catalogs.erase( i );
158 return;
159 }
160 printError( "Unknown file catalog -- cannot be removed.", true );
161 }
162 printError( "Invalid file catalog.", true );
163}

◆ removeCatalog() [2/2]

void MultiFileCatalog::removeCatalog ( CSTR connect)
override

Remove catalog identified by name from the existing ones.

Definition at line 143 of file MultiFileCatalog.cpp.

143 {
144 if ( con.empty() || con == "*" ) {
145 for_each( m_catalogs, []( IFileCatalog* i ) { i->release(); } );
146 m_catalogs.clear();
147 return;
148 }
149 removeCatalog( findCatalog( con, false ) );
150}

◆ renamePFN()

void Gaudi::MultiFileCatalog::renamePFN ( CSTR pfn,
CSTR newpfn ) const
inlineoverride

rename a PFN

Definition at line 122 of file MultiFileCatalog.h.

122{ writeCatalog()->renamePFN( pfn, newpfn ); }
virtual void renamePFN(const std::string &pfn, const std::string &new_pfn) const =0
rename a PFN

◆ rollback()

void MultiFileCatalog::rollback ( )
override

Save DOM catalog to file.

Definition at line 231 of file MultiFileCatalog.cpp.

231 {
232 for_each( m_catalogs, []( IFileCatalog* i ) { i->rollback(); } );
233}
virtual void rollback()=0
Save catalog to file.

◆ setMetaData()

void Gaudi::MultiFileCatalog::setMetaData ( CSTR fid,
CSTR attr,
CSTR val ) const
inlineoverride

Insert/update metadata item.

Definition at line 132 of file MultiFileCatalog.h.

132 {
133 writeCatalog( fid )->setMetaData( fid, attr, val );
134 }
virtual void setMetaData(const std::string &fid, const std::string &name, const std::string &value) const =0
Insert/update metadata item.

◆ setWriteCatalog() [1/2]

void MultiFileCatalog::setWriteCatalog ( CSTR connect)
override

Define the writable catalog identified by name.

Definition at line 181 of file MultiFileCatalog.cpp.

181 {
182 auto i = i_findCatalog( connect, true );
183 if ( i == m_catalogs.end() ) {
184 addCatalog( connect );
185 setWriteCatalog( findCatalog( connect, true ) );
186 return;
187 }
188 setWriteCatalog( *i );
189}
Catalogs::iterator i_findCatalog(CSTR connect, bool must_be_writable)
Find catalog by connect string.
void setWriteCatalog(IFileCatalog *cat) override
Define the writable catalog identified by reference.

◆ setWriteCatalog() [2/2]

void MultiFileCatalog::setWriteCatalog ( IFileCatalog * cat)
override

Define the writable catalog identified by reference.

Definition at line 165 of file MultiFileCatalog.cpp.

165 {
166 if ( cat ) {
167 if ( !cat->readOnly() ) {
168 auto i = find( m_catalogs.begin(), m_catalogs.end(), cat );
169 if ( i != m_catalogs.end() ) {
170 m_catalogs.erase( i );
171 m_catalogs.insert( m_catalogs.begin(), cat );
172 return;
173 }
174 printError( "The catalog " + cat->connectInfo() + " is not known.", true );
175 }
176 printError( "The catalog " + cat->connectInfo() + " is not writable.", true );
177 }
178 printError( "Invalid file catalog.", true );
179}
virtual const std::string & connectInfo() const =0
Access to connect string.

◆ writeCatalog()

IFileCatalog * Gaudi::MultiFileCatalog::writeCatalog ( CSTR fid = "") const
inlineoverride

Access to the (first) writable file catalog.

Definition at line 156 of file MultiFileCatalog.h.

156{ return getCatalog( fid, true, true, false ); }

Member Data Documentation

◆ m_catalogNames

Gaudi::Property<CatalogNames> Gaudi::MultiFileCatalog::m_catalogNames
private
Initial value:
{
this, "Catalogs", { { "xmlcatalog_file:test_catalog.xml" } }, &MultiFileCatalog::propHandler, "catalog names" }
void propHandler()
simple property handle to allow interactive modification of list of the file catalogs

Definition at line 178 of file MultiFileCatalog.h.

178 {
179 this, "Catalogs", { { "xmlcatalog_file:test_catalog.xml" } }, &MultiFileCatalog::propHandler, "catalog names" };

◆ m_catalogs

Catalogs Gaudi::MultiFileCatalog::m_catalogs
private

Container with references to known catalogs.

Definition at line 176 of file MultiFileCatalog.h.

◆ m_oldNames

CatalogNames Gaudi::MultiFileCatalog::m_oldNames
private

BACKUP:: Container with catalog names.

Definition at line 184 of file MultiFileCatalog.h.

◆ m_started

bool Gaudi::MultiFileCatalog::m_started = false
private

Flag to indicate if catalog is started.

Definition at line 182 of file MultiFileCatalog.h.


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