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< BASE, Interfaces >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces...>
 Typedef to the base of this class. More...
 
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 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...
 
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< BASE, Interfaces >
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::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
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::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces...>
 ~extend_interfaces () override=default
 Virtual destructor. More...
 
 ~extend_interfaces () override=default
 Virtual destructor. More...
 

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
 

Private Member Functions

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

Private Attributes

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

Detailed Description

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

This class manages multiple file catalogs.

Definition at line 20 of file MultiFileCatalog.h.

Member Typedef Documentation

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

Definition at line 29 of file MultiFileCatalog.h.

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

Definition at line 28 of file MultiFileCatalog.h.

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

Definition at line 27 of file MultiFileCatalog.h.

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

Definition at line 24 of file MultiFileCatalog.h.

Constructor & Destructor Documentation

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

Create a catalog file, initialization of XercesC.

Definition at line 24 of file MultiFileCatalog.cpp.

25  : base_class(nam, svc)
26 {
27  declareProperty("Catalogs", m_catalogNames, "The list of Catalogs")
28  -> declareUpdateHandler ( &Gaudi::MultiFileCatalog::propHandler, this ) ;
29 }
void propHandler(Property &)
simple property handle to allow interactive modification of list of the file catalogs ...
extends base_class
Typedef to this class.
Definition: extends.h:14
CatalogNames m_catalogNames
Property : Container with catalog names.
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 39 of file MultiFileCatalog.h.

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

Definition at line 47 of file MultiFileCatalog.h.

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

Definition at line 31 of file MultiFileCatalog.h.

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

Add new catalog identified by name to the existing ones.

Catalog is already present ... silently ignore request

Definition at line 119 of file MultiFileCatalog.cpp.

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

Add new catalog identified by reference to the existing ones.

Definition at line 155 of file MultiFileCatalog.cpp.

155  {
156  if ( cat ) {
157  cat->addRef();
158  m_catalogs.push_back(cat);
159  return;
160  }
161  printError("Got invalid catalog to be added to multi catalog.",true);
162 }
void printError(CSTR msg, bool throw_exc=true) const
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 144 of file MultiFileCatalog.h.

144 { 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 146 of file MultiFileCatalog.h.

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

Save DOM catalog to file.

Definition at line 246 of file MultiFileCatalog.cpp.

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

Access to connect string.

Definition at line 64 of file MultiFileCatalog.cpp.

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

Catalog interface.

Create file identifier using UUID mechanism.

Create file identifier using UUID mechanism

Definition at line 60 of file MultiFileCatalog.cpp.

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

Delete FileID from the catalog.

Definition at line 108 of file MultiFileCatalog.h.

109  { 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 238 of file MultiFileCatalog.cpp.

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

Drop all metadata of one FID.

Definition at line 126 of file MultiFileCatalog.h.

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

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

96  { 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 89 of file MultiFileCatalog.h.

90  { return !lookupLFN(lfn).empty(); }
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 83 of file MultiFileCatalog.h.

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

Finalize service object.

Definition at line 51 of file MultiFileCatalog.cpp.

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

Catalog management.

Find catalog by connect string

Definition at line 89 of file MultiFileCatalog.cpp.

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

Find catalog containing a given file identifier.

Definition at line 69 of file MultiFileCatalog.cpp.

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

Dump all file Identifiers.

Definition at line 105 of file MultiFileCatalog.h.

106  { _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
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 101 of file MultiFileCatalog.h.

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

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

Definition at line 118 of file MultiFileCatalog.h.

119  { _collect(fid,attr,std::mem_fn(&IFileCatalog::getMetaData)); }
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
string MultiFileCatalog::getMetaDataItem ( CSTR  fid,
CSTR  name 
) const
override

Access metadata item.

Definition at line 212 of file MultiFileCatalog.cpp.

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

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

Definition at line 98 of file MultiFileCatalog.h.

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

Find catalog by connect string.

Definition at line 99 of file MultiFileCatalog.cpp.

99  {
100  auto i = std::find_if(m_catalogs.begin(), m_catalogs.end(),
101  [&](const IFileCatalog* f){
102  return connect == f->connectInfo();
103  } );
104  if ( i!=m_catalogs.end() && must_be_writable && (*i)->readOnly() ) {
105  i = m_catalogs.end();
106  }
107  return i;
108 }
Catalogs m_catalogs
Container with references to known catalogs.
File catalog interface.
Definition: IFileCatalog.h:24
list i
Definition: ana.py:128
void MultiFileCatalog::init ( )
override

Parse the DOM tree of the XML catalog.

Definition at line 243 of file MultiFileCatalog.cpp.

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

IService implementation.

Finalize service object

Definition at line 31 of file MultiFileCatalog.cpp.

31  {
32  if ( !Service::initialize().isSuccess() ) {
33  printError("Failed to initialize service base class.",false);
34  return StatusCode::SUCCESS;
35  }
36  std::string current;
37  try {
38  for(const auto& i : m_catalogNames ) {
39  current = i;
40  addCatalog(i);
41  }
42  init();
43  return StatusCode::SUCCESS;
44  }
45  catch(const std::exception& /* e */) {
46  printError("Cannot add file catalog:"+current,false);
47  }
48  return StatusCode::FAILURE;
49 }
StatusCode initialize() override
Definition: Service.cpp:63
void printError(CSTR msg, bool throw_exc=true) const
CatalogNames m_catalogNames
Property : 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.
list i
Definition: ana.py:128
std::string Gaudi::MultiFileCatalog::lookupFID ( CSTR  lfn) const
private
std::string Gaudi::MultiFileCatalog::lookupLFN ( CSTR  lfn) const
inlineoverride

Lookup file identifier by logical file name.

Definition at line 92 of file MultiFileCatalog.h.

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

Lookup file identifier by physical file name.

Definition at line 86 of file MultiFileCatalog.h.

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

Definition at line 110 of file MultiFileCatalog.cpp.

110  {
111  MsgStream log(msgSvc(),name());
112  if ( rethrow ) {
113  log << MSG::FATAL << msg << endmsg;
114  throw runtime_error("Catalog> "+msg);
115  }
116  log << MSG::ERROR << msg << endmsg;
117 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
void MultiFileCatalog::propHandler ( Property )
private

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

Definition at line 252 of file MultiFileCatalog.cpp.

253 {
254  // not yet initialized
255  if ( !m_started ) { m_oldNames = m_catalogNames; return; } // RETURN
256  // no real change - no action
257  if ( m_catalogNames == m_oldNames ) { return; }
259  // remove ALL catalogs
260  removeCatalog("") ;
261  // add new catalogs
262  for ( const auto& inew : m_catalogNames ) addCatalog ( inew ) ;
263  // start
264  init() ;
265  //
266  MsgStream log ( msgSvc() , name() ) ;
267  log << MSG::DEBUG
268  << "New catalogs to be used: "
269  << Gaudi::Utils::toString ( m_catalogNames ) << endmsg ;
270 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
bool m_started
Flag to indicate if catalog is started.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:371
CatalogNames m_catalogNames
Property : Container with catalog names.
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.
bool MultiFileCatalog::readOnly ( ) const
override

Check if the catalog is read-only.

Definition at line 233 of file MultiFileCatalog.cpp.

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

Create a FileID and DOM Node.

Definition at line 115 of file MultiFileCatalog.h.

116  { 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 227 of file MultiFileCatalog.cpp.

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

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

Definition at line 221 of file MultiFileCatalog.cpp.

221  {
222  IFileCatalog* c = getCatalog(fid,false,true,false);
223  if ( !c ) c = getCatalog("",true,true,true);
224  c->registerPFN(fid, pfn, ftype);
225 }
tuple c
Definition: gaudirun.py:391
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.
IFileCatalog * getCatalog(CSTR fid, bool throw_if_not, bool writable=true, bool prt=true) const
Find catalog containing a given file identifier.
File catalog interface.
Definition: IFileCatalog.h:24
void MultiFileCatalog::removeCatalog ( CSTR  connect)
override

Remove catalog identified by name from the existing ones.

Definition at line 164 of file MultiFileCatalog.cpp.

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

Remove catalog identified by reference from the existing ones.

Definition at line 173 of file MultiFileCatalog.cpp.

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

Save DOM catalog to file.

Definition at line 249 of file MultiFileCatalog.cpp.

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

Insert/update metadata item.

Definition at line 123 of file MultiFileCatalog.h.

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

Define the writable catalog identified by reference.

Definition at line 186 of file MultiFileCatalog.cpp.

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

Define the writable catalog identified by name.

Definition at line 202 of file MultiFileCatalog.cpp.

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

Access to the (first) writable file catalog.

Definition at line 148 of file MultiFileCatalog.h.

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

Member Data Documentation

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

Property : Container with catalog names.

Definition at line 171 of file MultiFileCatalog.h.

Catalogs Gaudi::MultiFileCatalog::m_catalogs
private

Container with references to known catalogs.

Definition at line 169 of file MultiFileCatalog.h.

CatalogNames Gaudi::MultiFileCatalog::m_oldNames
private

BACKUP:: Container with catalog names.

Definition at line 175 of file MultiFileCatalog.h.

bool Gaudi::MultiFileCatalog::m_started = false
private

Flag to indicate if catalog is started.

Definition at line 173 of file MultiFileCatalog.h.


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