24 template <
typename C,
typename F>
26 return std::for_each( std::begin( c ), std::end( c ), std::forward<F>( f ) );
35 printError(
"Failed to initialize service base class.",
false );
46 }
catch (
const std::exception& ) {
printError(
"Cannot add file catalog:" + current,
false ); }
62 static const string s(
"MultiCatalog" );
68 if ( !c || ( writable && c->readOnly() ) )
continue;
69 if ( fid.empty() || ( !fid.empty() && c->existsFID( fid ) ) )
return c;
72 printError(
"No writable file catalog found which contains FID:" + fid, throw_if_not );
74 debug() <<
"No writable file catalog found which contains FID:" << fid <<
endmsg;
81 [&](
const IFileCatalog* f ) { return connect == f->connectInfo(); } );
82 return ( i !=
m_catalogs.end() && ( !must_be_writable || !( *i )->readOnly() ) ) ? *i :
nullptr;
87 [&](
const IFileCatalog* f ) { return connect == f->connectInfo(); } );
95 throw runtime_error(
"Catalog> " +
msg );
101 if ( !con.empty() ) {
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 );
108 if ( strncasecmp(
"xml", typ.c_str(), 3 ) == 0 ) {
109 cat = IFileCatalog::Factory::create( xml_typ, url,
msgSvc().get() ).
release();
111 using Gaudi::PluginService::Details::Registry;
112 Registry& registry = Registry::instance();
113 if ( registry.getInfo( typ ).factory.type() ==
typeid( Service::Factory::FactoryType ) ) {
115 }
else if ( registry.getInfo( typ ).factory.type() ==
typeid( IFileCatalog::Factory::FactoryType ) ) {
116 cat = IFileCatalog::Factory::create( typ, url,
msgSvc().get() ).
release();
126 printError(
"Failed to create catalog connection:" + con,
true );
131 printError(
"Got invalid (empty) catalog connection string.",
true );
140 printError(
"Got invalid catalog to be added to multi catalog.",
true );
144 if ( con.empty() || con ==
"*" ) {
160 printError(
"Unknown file catalog -- cannot be removed.",
true );
194 result = i->getMetaDataItem( fid, attr );
195 if ( !result.empty() )
break;
202 if ( !c ) c =
getCatalog(
"",
true,
true,
true );
203 c->registerPFN( fid, pfn, ftype );
208 if ( !c ) c =
getCatalog(
"",
true,
true,
true );
209 c->registerLFN( fid, lfn );
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
#define DECLARE_COMPONENT(type)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
virtual void rollback()=0
Save catalog to file.
virtual bool readOnly() const =0
Check if the catalog is read-only.
virtual bool dirty() const =0
Check if the catalog should be updated.
virtual void commit()=0
Save catalog to file.
virtual void init()=0
Parse the DOM tree of the XML catalog.
virtual const std::string & connectInfo() const =0
Access to connect string.
This class constitutes the core of the XML based FileCatalog API for using POOL within Gaudi.
void removeCatalog(CSTR connect) override
Remove catalog identified by name from the existing ones.
void registerPFN(CSTR fid, CSTR pfn, CSTR ftype) const override
Create a FileID and DOM Node of the PFN with all the attributes.
bool dirty() const override
Check if the catalog should be updated.
Catalogs::iterator i_findCatalog(CSTR connect, bool must_be_writable)
Find catalog by connect string.
bool m_started
Flag to indicate if catalog is started.
std::string createFID() const override
Catalog interface.
void propHandler()
simple property handle to allow interactive modification of list of the file catalogs
Catalogs m_catalogs
Container with references to known catalogs.
CSTR connectInfo() const override
Access to connect string.
StatusCode finalize() override
Finalize service object.
void setWriteCatalog(IFileCatalog *cat) override
Define the writable catalog identified by reference.
bool readOnly() const override
Check if the catalog is read-only.
IFileCatalog * getCatalog(CSTR fid, bool throw_if_not, bool writable=true, bool prt=true) const
Find catalog containing a given file identifier.
IFileCatalog * findCatalog(CSTR connect, bool must_be_writable) const override
Catalog management.
void rollback() override
Save DOM catalog to file.
Gaudi::Property< CatalogNames > m_catalogNames
void addCatalog(CSTR connect) override
Add new catalog identified by name to the existing ones.
void commit() override
Save DOM catalog to file.
void registerLFN(CSTR fid, CSTR lfn) const override
Create a FileID and DOM Node of the LFN with all the attributes.
StatusCode initialize() override
IService implementation.
CatalogNames m_oldNames
BACKUP:: Container with catalog names.
void init() override
Parse the DOM tree of the XML catalog.
std::string getMetaDataItem(CSTR fid, CSTR name) const override
Access metadata item.
void printError(CSTR msg, bool throw_exc=true) const
Definition of the basic interface.
virtual unsigned long addRef() const =0
Increment the reference count of Interface instance.
virtual unsigned long release() const =0
Release Interface instance.
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
StatusCode finalize() override
StatusCode initialize() override
Small smart pointer class with automatic reference counting for IInterface.
This class is used for returning status codes from appropriate routines.
constexpr static const auto SUCCESS
constexpr static const auto FAILURE
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
void for_each(ContainerOfSynced &c, Fun &&f)
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
std::string createGuidAsString()
Helper function creating file identifier using the UUID mechanism.