The Gaudi Framework  master (f31105fd)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Gaudi::MultiFileCatalog Class Reference

#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 = 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
using Factory = Gaudi::PluginService::Factory< IService *(const std::string &, ISvcLocator *)>
 
- 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

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 renamePFN (CSTR pfn, CSTR newpfn) const override
 rename a PFN More...
 
void deletePFN (CSTR pfn) const override
 remove a PFN 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...
 
- 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...
 
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 >
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. More...
 
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. More...
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 PropertyHolder ()=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, 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 std::string &name, const Gaudi::Details::PropertyBase &p) override
 set the property from another property with a different name More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property. More...
 
virtual StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p)=0
 Set the property from a property with a different name. More...
 
virtual StatusCode setProperty (const std::string &s)=0
 Set the property by string. More...
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals. More...
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string. More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode setPropertyRepr (const std::string &n, const std::string &r) override
 set the property from name and value string representation More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (std::string_view name) const override
 get the property by name More...
 
StatusCode getProperty (std::string_view 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 (std::string_view name) const override
 Return true if we have a property with the given name. More...
 
Gaudi::Details::PropertyBaseproperty (std::string_view name) const
 \fixme property and bindPropertiesTo should be protected More...
 
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) More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream 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
std::vector< IAlgTool * > & tools ()
 
 ~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 > >
MSG::Level setUpMessaging () const
 Set up local caches. More...
 
MSG::Level resetMessaging ()
 Reinitialize internal states. More...
 
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 ()
 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" }
 flag indicating whether ToolHandle tools have been added to m_tools More...
 
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()" }
 
Gaudi::Property< bool > m_autoRetrieveTools
 
Gaudi::Property< bool > m_checkToolDeps
 
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 30 of file MultiFileCatalog.h.

Member Typedef Documentation

◆ CatalogNames

Definition at line 38 of file MultiFileCatalog.h.

◆ Catalogs

Definition at line 37 of file MultiFileCatalog.h.

◆ CSTR

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

Definition at line 36 of file MultiFileCatalog.h.

◆ Factory

Member Function Documentation

◆ _collect() [1/2]

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

Definition at line 50 of file MultiFileCatalog.h.

50  {
51  A1 tmp;
52  for ( const auto& i : m_catalogs ) {
53  f( i, tmp ); // tmp = f(i)
54  arg1.insert( arg1.end(), tmp.begin(), tmp.end() );
55  tmp.clear();
56  }
57  }

◆ _collect() [2/2]

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

Definition at line 59 of file MultiFileCatalog.h.

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

◆ _find()

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

Definition at line 41 of file MultiFileCatalog.h.

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

◆ 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 }

◆ 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 }

◆ catalogs() [1/2]

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

Access catalog container (CONST)

Definition at line 155 of file MultiFileCatalog.h.

155 { return m_catalogs; }

◆ catalogs() [2/2]

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

Access catalog container.

Definition at line 153 of file MultiFileCatalog.h.

153 { 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 }

◆ 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(); }

◆ deleteFID()

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

Delete FileID from the catalog.

Definition at line 115 of file MultiFileCatalog.h.

115 { writeCatalog( fid )->deleteFID( fid ); }

◆ deletePFN()

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

remove a PFN

Definition at line 125 of file MultiFileCatalog.h.

125 { writeCatalog()->deletePFN( pfn ); }

◆ dirty()

bool MultiFileCatalog::dirty ( ) const
override

Check if the catalog should be updated.

Definition at line 217 of file MultiFileCatalog.cpp.

217  {
219  []( const IFileCatalog* i ) { return i->dirty(); } );
220 }

◆ dropMetaData() [1/2]

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

Drop all metadata of one FID.

Definition at line 137 of file MultiFileCatalog.h.

137 { writeCatalog( fid )->dropMetaData( fid ); }

◆ dropMetaData() [2/2]

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

Drop specified metadata item.

Definition at line 139 of file MultiFileCatalog.h.

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

◆ existsFID()

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

Return the status of a FileID.

Definition at line 102 of file MultiFileCatalog.h.

102 { return 0 != getCatalog( fid, false, false, false ); }

◆ existsLFN()

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

Return the status of a logical file name.

Definition at line 98 of file MultiFileCatalog.h.

98 { return !lookupLFN( lfn ).empty(); }

◆ existsPFN()

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

Return the status of physical file name.

Definition at line 94 of file MultiFileCatalog.h.

94 { return !lookupPFN( pfn ).empty(); }

◆ 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 }

◆ 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  {
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 }

◆ getFID()

void Gaudi::MultiFileCatalog::getFID ( Strings &  fids) const
inlineoverride

Dump all file Identifiers.

Definition at line 113 of file MultiFileCatalog.h.

113 { _collect( fids, std::mem_fn( &IFileCatalog::getFID ) ); }

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

108  {
109  _collect( fid, files, std::mem_fn( &IFileCatalog::getLFN ) );
110  }

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

127  {
129  }

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

104  {
105  _collect( fid, files, std::mem_fn( &IFileCatalog::getPFN ) );
106  }

◆ 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  {
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 }

◆ 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 );
36  return StatusCode::SUCCESS;
37  }
38  std::string current;
39  try {
40  for ( const auto& i : m_catalogNames ) {
41  current = i;
42  addCatalog( i );
43  }
44  init();
45  return StatusCode::SUCCESS;
46  } catch ( const std::exception& /* e */ ) { printError( "Cannot add file catalog:" + current, false ); }
47  return StatusCode::FAILURE;
48 }

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

100 { return _find( lfn, &IFileCatalog::lookupLFN ); }

◆ lookupPFN()

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

Lookup file identifier by physical file name.

Definition at line 96 of file MultiFileCatalog.h.

96 { return _find( pfn, &IFileCatalog::lookupPFN ); }

◆ 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 }

◆ 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 }

◆ readOnly()

bool MultiFileCatalog::readOnly ( ) const
override

Check if the catalog is read-only.

Definition at line 212 of file MultiFileCatalog.cpp.

212  {
214  []( const IFileCatalog* i ) { return i->readOnly(); } );
215 }

◆ registerFID()

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

Create a FileID and DOM Node.

Definition at line 121 of file MultiFileCatalog.h.

121 { writeCatalog()->registerFID( fid ); }

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

123 { writeCatalog()->renamePFN( pfn, newpfn ); }

◆ 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 }

◆ setMetaData()

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

Insert/update metadata item.

Definition at line 133 of file MultiFileCatalog.h.

133  {
134  writeCatalog( fid )->setMetaData( fid, attr, val );
135  }

◆ 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 }

◆ 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 }

◆ writeCatalog()

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

Access to the (first) writable file catalog.

Definition at line 157 of file MultiFileCatalog.h.

157 { 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" }

Definition at line 179 of file MultiFileCatalog.h.

◆ m_catalogs

Catalogs Gaudi::MultiFileCatalog::m_catalogs
private

Container with references to known catalogs.

Definition at line 177 of file MultiFileCatalog.h.

◆ m_oldNames

CatalogNames Gaudi::MultiFileCatalog::m_oldNames
private

BACKUP:: Container with catalog names.

Definition at line 185 of file MultiFileCatalog.h.

◆ m_started

bool Gaudi::MultiFileCatalog::m_started = false
private

Flag to indicate if catalog is started.

Definition at line 183 of file MultiFileCatalog.h.


The documentation for this class was generated from the following files:
Gaudi::IFileCatalog::rollback
virtual void rollback()=0
Save catalog to file.
Gaudi::MultiFileCatalog::commit
void commit() override
Save DOM catalog to file.
Definition: MultiFileCatalog.cpp:227
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:118
Gaudi::IFileCatalog::connectInfo
virtual const std::string & connectInfo() const =0
Access to connect string.
std::string
STL class.
std::exception
STL class.
Gaudi::IFileCatalog::readOnly
virtual bool readOnly() const =0
Check if the catalog is read-only.
cpluginsvc.registry
def registry()
Definition: cpluginsvc.py:83
Gaudi::IFileCatalog::lookupPFN
virtual std::string lookupPFN(const std::string &lfn) const =0
Lookup file identifier by physical file name.
Gaudi::IFileCatalog
Definition: IFileCatalog.h:36
Gaudi::IFileCatalog::commit
virtual void commit()=0
Save catalog to file.
gaudirun.s
string s
Definition: gaudirun.py:346
Gaudi::MultiFileCatalog::i_findCatalog
Catalogs::iterator i_findCatalog(CSTR connect, bool must_be_writable)
Find catalog by connect string.
Definition: MultiFileCatalog.cpp:85
std::find_if
T find_if(T... args)
Gaudi::IFileCatalog::renamePFN
virtual void renamePFN(const std::string &pfn, const std::string &new_pfn) const =0
rename a PFN
Gaudi::MultiFileCatalog::removeCatalog
void removeCatalog(CSTR connect) override
Remove catalog identified by name from the existing ones.
Definition: MultiFileCatalog.cpp:143
Gaudi::IFileCatalog::dirty
virtual bool dirty() const =0
Check if the catalog should be updated.
GaudiPartProp.decorators.get
get
decorate the vector of properties
Definition: decorators.py:283
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:19
std::mem_fn
T mem_fn(T... args)
Gaudi::MultiFileCatalog::m_catalogNames
Gaudi::Property< CatalogNames > m_catalogNames
Definition: MultiFileCatalog.h:179
gaudirun.c
c
Definition: gaudirun.py:525
std::any_of
T any_of(T... args)
Gaudi::MultiFileCatalog::findCatalog
IFileCatalog * findCatalog(CSTR connect, bool must_be_writable) const override
Catalog management
Definition: MultiFileCatalog.cpp:79
Gaudi::MultiFileCatalog::_find
std::string _find(A1 &arg1, F pmf) const
Definition: MultiFileCatalog.h:41
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:222
std::vector::clear
T clear(T... args)
AvalancheSchedulerErrorTest.msgSvc
msgSvc
Definition: AvalancheSchedulerErrorTest.py:80
Gaudi::MultiFileCatalog::m_catalogs
Catalogs m_catalogs
Container with references to known catalogs.
Definition: MultiFileCatalog.h:177
std::vector::push_back
T push_back(T... args)
Gaudi::IFileCatalog::lookupLFN
virtual std::string lookupLFN(const std::string &lfn) const =0
Lookup file identifier by physical file name.
Gaudi::MultiFileCatalog::printError
void printError(CSTR msg, bool throw_exc=true) const
Definition: MultiFileCatalog.cpp:92
Gaudi::IFileCatalog::registerFID
virtual void registerFID(const std::string &fid) const =0
Create a Node for a FileID and DOM Node.
Gaudi::cxx::for_each
void for_each(ContainerOfSynced &c, Fun &&f)
Definition: SynchronizedValue.h:104
Gaudi::IFileCatalog::dropMetaData
virtual void dropMetaData(const std::string &fid) const =0
Drop all metadata of one FID.
std::string::c_str
T c_str(T... args)
Gaudi::MultiFileCatalog::setWriteCatalog
void setWriteCatalog(IFileCatalog *cat) override
Define the writable catalog identified by reference.
Definition: MultiFileCatalog.cpp:165
Gaudi::MultiFileCatalog::lookupPFN
std::string lookupPFN(CSTR pfn) const override
Lookup file identifier by physical file name.
Definition: MultiFileCatalog.h:96
std::vector::erase
T erase(T... args)
std::runtime_error
STL class.
SmartIF
Definition: IConverter.h:25
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
Gaudi::MultiFileCatalog::init
void init() override
Parse the DOM tree of the XML catalog.
Definition: MultiFileCatalog.cpp:222
Gaudi::IFileCatalog::getLFN
virtual void getLFN(const std::string &fid, Files &files) const =0
Dump all LFNames of the catalog associate to the FileID.
Gaudi::Utils::toString
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:357
Gaudi::MultiFileCatalog::_collect
void _collect(A1 &arg1, F f) const
Definition: MultiFileCatalog.h:50
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
Gaudi::IFileCatalog::setMetaData
virtual void setMetaData(const std::string &fid, const std::string &name, const std::string &value) const =0
Insert/update metadata item.
std::begin
T begin(T... args)
Gaudi::IFileCatalog::getMetaData
virtual void getMetaData(const std::string &fid, Attributes &attr) const =0
Dump all MetaData of the catalog for a given file ID.
std::vector::insert
T insert(T... args)
Gaudi::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.
IInterface
Definition: IInterface.h:239
Gaudi::IFileCatalog::init
virtual void init()=0
Parse the DOM tree of the XML catalog.
Gaudi::createGuidAsString
std::string createGuidAsString()
Helper function creating file identifier using the UUID mechanism.
std::string::empty
T empty(T... args)
Gaudi::MultiFileCatalog::lookupLFN
std::string lookupLFN(CSTR lfn) const override
Lookup file identifier by logical file name.
Definition: MultiFileCatalog.h:100
Gaudi::MultiFileCatalog::writeCatalog
IFileCatalog * writeCatalog(CSTR fid="") const override
Access to the (first) writable file catalog.
Definition: MultiFileCatalog.h:157
std::end
T end(T... args)
Gaudi::IFileCatalog::getFID
virtual void getFID(Strings &fids) const =0
Dump all file Identifiers.
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
IInterface::release
virtual unsigned long release()=0
Release Interface instance.
Gaudi::IFileCatalog::deleteFID
virtual void deleteFID(const std::string &FileID) const =0
Delete FileID Node from the catalog.
Gaudi::MultiFileCatalog::getCatalog
IFileCatalog * getCatalog(CSTR fid, bool throw_if_not, bool writable=true, bool prt=true) const
Find catalog containing a given file identifier.
Definition: MultiFileCatalog.cpp:66
Gaudi::MultiFileCatalog::m_started
bool m_started
Flag to indicate if catalog is started.
Definition: MultiFileCatalog.h:183
Gaudi::IFileCatalog::deletePFN
virtual void deletePFN(const std::string &pfn) const =0
remove a PFN
IInterface::addRef
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
Gaudi::MultiFileCatalog::addCatalog
void addCatalog(CSTR connect) override
Add new catalog identified by name to the existing ones.
Definition: MultiFileCatalog.cpp:100
Gaudi::MultiFileCatalog::propHandler
void propHandler()
simple property handle to allow interactive modification of list of the file catalogs
Definition: MultiFileCatalog.cpp:235
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator
Definition: Service.cpp:335
Gaudi::MultiFileCatalog::m_oldNames
CatalogNames m_oldNames
BACKUP:: Container with catalog names.
Definition: MultiFileCatalog.h:185