| The Gaudi Framework v32r1 (f65d50dc)

XMLFileCatalog.cpp
Go to the documentation of this file.
1 #include "xercesc/dom/DOM.hpp"
2 #include "xercesc/framework/LocalFileFormatTarget.hpp"
3 #include "xercesc/framework/MemBufInputSource.hpp"
4 #include "xercesc/parsers/XercesDOMParser.hpp"
5 #include "xercesc/sax/EntityResolver.hpp"
6 #include "xercesc/sax/InputSource.hpp"
7 #include "xercesc/sax/SAXParseException.hpp"
8 #include "xercesc/util/PlatformUtils.hpp"
9 #include "xercesc/util/XMLString.hpp"
10 #include "xercesc/util/XMLURL.hpp"
11 #include "xercesc/util/XMLUni.hpp"
12 #include "xercesc/util/XercesDefs.hpp"
13
14 #include "GaudiKernel/MsgStream.h"
15 #include "GaudiKernel/Service.h"
16 #include <Gaudi/PluginService.h>
17
18 #include "XMLFileCatalog.h"
19 #include "createGuidAsString.h"
20
21 #include <fstream>
22 #include <iostream>
23 #include <stdexcept>
24 #include <sys/stat.h>
25 #include <sys/types.h>
26
27 using namespace xercesc;
28 using namespace Gaudi;
29 using namespace std;
30
31 #if _XERCES_VERSION <= 30000
32 // API change between XercesC 2 and 3
33 # define setIdAttribute( a, b ) setIdAttribute( a )
34 #endif
35
36 DECLARE_FACTORY( XMLFileCatalog, IFileCatalog::Factory )
37
38 namespace {
39
40 typedef const string& CSTR;
41 inline string _toString( const XMLCh* toTranscode ) {
42 char* buff = XMLString::transcode( toTranscode );
43 string tmp( buff == 0 ? "" : buff );
44 XMLString::release( &buff );
45 return tmp;
46 }
47 struct __Init {
48 __Init() {
49 try {
50 XMLPlatformUtils::Initialize();
51 } catch ( const XMLException& e ) {
52 cout << "Xerces-c error in initialization:" << _toString( e.getMessage() ) << endl;
53 }
54 }
55 ~__Init() { XMLPlatformUtils::Terminate(); }
56 };
57 __Init __In__;
58
59 struct XMLStr {
60 XMLCh* m_xml;
61 XMLStr( CSTR c ) { m_xml = XMLString::transcode( c.c_str() ); }
62 ~XMLStr() {
63 if ( m_xml ) XMLString::release( &m_xml );
64 }
65 operator const XMLCh*() const { return m_xml; }
66 };
67 struct XMLTag : public XMLStr {
68 string m_str;
69 XMLTag( CSTR s ) : XMLStr( s ), m_str( s ) {}
70 ~XMLTag() {}
71 operator CSTR() const { return m_str; }
72 };
73 // bool operator==(const XMLTag& b, CSTR c) { return c==b.m_str; }
74 bool operator==( CSTR c, const XMLTag& b ) { return c == b.m_str; }
75 struct XMLCollection {
76 DOMElement* m_node;
77 XMLCollection( DOMNode* n, bool use_children = true ) : m_node( (DOMElement*)n ) {
78 if ( use_children ) {
79 if ( m_node ) m_node = (DOMElement*)m_node->getFirstChild();
80 if ( m_node && m_node->getNodeType() != DOMNode::ELEMENT_NODE ) ++( *this );
81 }
82 }
83 operator bool() const { return m_node; }
84 operator DOMNode*() const { return m_node; }
85 operator DOMElement*() const { return m_node; }
86 DOMElement* operator->() const { return m_node; }
87 string attr( const XMLTag& tag ) const { return _toString( m_node->getAttribute( tag ) ); }
88 string attr( CSTR tag ) const { return attr( XMLTag( tag ) ); }
89 string tag() const { return _toString( m_node->getTagName() ); }
90 void operator++() {
91 while ( m_node ) {
92 m_node = (DOMElement*)m_node->getNextSibling();
93 if ( m_node && m_node->getNodeType() == DOMNode::ELEMENT_NODE ) { return; }
94 }
95 }
96 };
97 struct ErrHandler : public ErrorHandler {
99 IMessageSvc* m_msg;
101 ErrHandler( IMessageSvc* m ) : m_msg( m ) {}
103 void resetErrors() override {}
105 void warning( const SAXParseException& /* e */ ) override {}
107 void error( const SAXParseException& e ) override;
109 void fatalError( const SAXParseException& e ) override;
110 };
111 struct DTDRedirect : public EntityResolver {
112 InputSource* resolveEntity( const XMLCh* const /* pubId */, const XMLCh* const /* sysId */ ) override {
113 static const char* dtdID = "redirectinmem.dtd";
114 static const char* dtd = "\
115 <!ELEMENT POOLFILECATALOG (META*,File*)>\
116 <!ELEMENT META EMPTY>\
117 <!ELEMENT File (physical,logical,metadata*)>\
118 <!ATTLIST META name CDATA #REQUIRED>\
119 <!ATTLIST META type CDATA #REQUIRED>\
120 <!ELEMENT physical (pfn)+>\
121 <!ELEMENT logical (lfn)*>\
122 <!ELEMENT metadata EMPTY>\
123 <!ELEMENT lfn EMPTY>\
124 <!ELEMENT pfn EMPTY>\
125 <!ATTLIST File ID ID #REQUIRED>\
126 <!ATTLIST pfn name ID #REQUIRED>\
127 <!ATTLIST pfn filetype CDATA #IMPLIED>\
128 <!ATTLIST pfn se CDATA #IMPLIED>\
129 <!ATTLIST lfn name ID #REQUIRED>\
130 <!ATTLIST metadata att_name CDATA #REQUIRED>\
131 <!ATTLIST metadata att_value CDATA #REQUIRED>\
132 ";
133 static const size_t len = strlen( dtd );
134 return new MemBufInputSource( (const XMLByte*)dtd, len, dtdID, false );
135 }
136 };
137
138 void ErrHandler::error( const SAXParseException& e ) {
139 string m( _toString( e.getMessage() ) );
140 if ( m.find( "The values for attribute 'name' must be names or name tokens" ) != string::npos ||
141 m.find( "The values for attribute 'ID' must be names or name tokens" ) != string::npos ||
142 m.find( "for attribute 'name' must be Name or Nmtoken" ) != string::npos ||
143 m.find( "for attribute 'ID' must be Name or Nmtoken" ) != string::npos ||
144 m.find( "for attribute 'name' is invalid Name or NMTOKEN value" ) != string::npos ||
145 m.find( "for attribute 'ID' is invalid Name or NMTOKEN value" ) != string::npos )
146 return;
147 string sys( _toString( e.getSystemId() ) );
148 MsgStream log( m_msg, "XMLCatalog" );
149 log << MSG::ERROR << "Error at file \"" << sys << "\", line " << e.getLineNumber() << ", column "
150 << e.getColumnNumber() << endmsg << "Message: " << m << endmsg;
151 }
152 void ErrHandler::fatalError( const SAXParseException& e ) {
153 MsgStream log( m_msg, "XMLCatalog" );
154 string m( _toString( e.getMessage() ) );
155 string sys( _toString( e.getSystemId() ) );
156 log << MSG::ERROR << "Fatal Error at file \"" << sys << "\", line " << e.getLineNumber() << ", column "
157 << e.getColumnNumber() << endmsg << "Message: " << m << endmsg;
158 throw runtime_error( "Standard pool exception : Fatal Error on the DOM Parser" );
159 }
160
161 const XMLTag EmptyCatalog( "<!-- Edited By POOL -->\n"
162 "<!DOCTYPE POOLFILECATALOG SYSTEM \"InMemory\">\n"
163 "<POOLFILECATALOG>\n"
164 "</POOLFILECATALOG>\n" );
165 const XMLTag PFNCOLL( "physical" );
166 const XMLTag LFNCOLL( "logical" );
167 const XMLTag PFNNODE( "pfn" );
168 const XMLTag LFNNODE( "lfn" );
169 const XMLTag Attr_type( "type" );
170 const XMLTag Attr_ID( "ID" );
171 const XMLTag Attr_name( "name" );
172 const XMLTag Attr_ftype( "filetype" );
173 const XMLTag MetaNode( "metadata" );
174 const XMLTag Attr_metaName( "att_name" );
175 const XMLTag Attr_metaValue( "att_value" );
176 } // namespace
177
178 // ----------------------------------------------------------------------------
179 XMLFileCatalog::XMLFileCatalog( CSTR uri, IMessageSvc* m ) : m_file( uri ), m_msgSvc( m ) {}
180 // ----------------------------------------------------------------------------
182 std::string XMLFileCatalog::createFID() const { return createGuidAsString(); }
183 // ----------------------------------------------------------------------------
184 DOMDocument* XMLFileCatalog::getDoc( bool throw_if_no_exists ) const {
185 if ( !m_doc && throw_if_no_exists ) printError( "The XML catalog was not started.", true );
186 return m_doc;
187 }
188 // ----------------------------------------------------------------------------
189 void XMLFileCatalog::printError( CSTR msg, bool rethrow ) const {
190 MsgStream log( m_msgSvc, "XMLCatalog" );
191 log << MSG::FATAL << msg << endmsg;
192 if ( rethrow ) throw runtime_error( "XMLFileCatalog> " + msg );
193 }
194 // ----------------------------------------------------------------------------
195 void XMLFileCatalog::init() {
196 string xmlFile = getfile( false );
197 try {
198 m_parser = std::make_unique<XercesDOMParser>();
199 m_parser->setValidationScheme( XercesDOMParser::Val_Auto );
200 m_parser->setDoNamespaces( false );
201 DTDRedirect dtdinmem;
202 m_parser->setEntityResolver( &dtdinmem );
203 if ( !m_errHdlr ) m_errHdlr = std::make_unique<ErrHandler>( m_msgSvc );
204 m_parser->setErrorHandler( m_errHdlr.get() );
205 if ( !xmlFile.empty() ) {
206 m_parser->parse( xmlFile.c_str() );
207 } else {
208 const std::string& s = EmptyCatalog;
209 MemBufInputSource src( (const XMLByte*)s.c_str(), s.length(), "MemCatalog" );
210 m_parser->parse( src );
211 }
212 m_doc = m_parser->getDocument();
213 } catch ( const XMLException& e ) {
214 printError( "XML parse error[" + xmlFile + "]: " + _toString( e.getMessage() ) );
215 } catch ( const DOMException& e ) {
216 printError( "XML parse error[" + xmlFile + "]: " + _toString( e.getMessage() ) );
217 } catch ( ... ) { printError( "UNKNOWN XML parse error in file " + xmlFile ); }
218 }
219 // ----------------------------------------------------------------------------
220 string XMLFileCatalog::lookupFID( const std::string& fid ) const {
221 std::string result;
222 DOMNode* e = element( fid, false );
223 e = e ? e->getParentNode() : 0; // Mode up to <logical>
224 e = e ? e->getParentNode() : 0; // Mode up to <File>
225 if ( e ) {
226 if ( e->getAttributes() ) { // Need to check this. The node may be no DOMElement
227 char* nam = XMLString::transcode( ( (DOMElement*)e )->getAttribute( Attr_ID ) );
228 if ( nam ) result = nam;
229 XMLString::release( &nam );
230 }
231 }
232 return result;
233 }
234 // ----------------------------------------------------------------------------
235 void XMLFileCatalog::getFID( Strings& fids ) const {
236 fids.clear();
237 DOMNode* fde = getDoc( true )->getElementsByTagName( XMLStr( "*" ) )->item( 0 );
238 for ( XMLCollection c( child( fde, "File" ), false ); c; ++c ) fids.push_back( c.attr( Attr_ID ) );
239 }
240 // ----------------------------------------------------------------------------
241 void XMLFileCatalog::getPFN( CSTR fid, Files& files ) const {
242 files.clear();
243 for ( XMLCollection c( child( child( element( fid, false ), PFNCOLL ), PFNNODE ), false ); c; ++c )
244 files.emplace_back( c.attr( Attr_name ), c.attr( Attr_ftype ) );
245 }
246 // ----------------------------------------------------------------------------
247 void XMLFileCatalog::getLFN( CSTR fid, Files& files ) const {
248 files.clear();
249 for ( XMLCollection c( child( child( element( fid, false ), LFNCOLL ), LFNNODE ), false ); c; ++c )
250 files.emplace_back( c.attr( Attr_name ), fid );
251 }
252 // ----------------------------------------------------------------------------
253 void XMLFileCatalog::getMetaData( CSTR fid, Attributes& attr ) const {
254 attr.clear();
255 for ( XMLCollection c( child( element( fid ), MetaNode ), false ); c; ++c )
256 attr.emplace_back( c.attr( Attr_metaName ), c.attr( Attr_metaValue ) );
257 if ( attr.size() > 0 ) attr.emplace_back( "guid", fid );
258 }
259 // ----------------------------------------------------------------------------
260 DOMNode* XMLFileCatalog::child( DOMNode* par, CSTR tag, CSTR attr, CSTR val ) const {
261 for ( XMLCollection c( par ); c; ++c ) {
262 if ( c.tag() == tag ) {
263 if ( !attr.empty() && c.attr( attr ) != val ) continue;
264 return c;
265 }
266 }
267 return 0;
268 }
269 // ----------------------------------------------------------------------------
270 void XMLFileCatalog::setMetaData( CSTR fid, CSTR attr, CSTR val ) const {
271 if ( !readOnly() ) {
272 DOMNode* node = element( fid );
273 DOMElement* mnod = (DOMElement*)child( node, MetaNode, Attr_metaName, attr );
274 if ( !mnod ) {
275 mnod = getDoc( true )->createElement( MetaNode );
276 node->appendChild( mnod );
277 mnod->setAttribute( Attr_metaName, XMLStr( attr ) );
278 }
279 mnod->setAttribute( Attr_metaValue, XMLStr( val ) );
280 m_update = true;
281 return;
282 }
283 printError( "Cannot update readonly catalog!" );
284 }
285 // ----------------------------------------------------------------------------
286 string XMLFileCatalog::getMetaDataItem( CSTR fid, CSTR attr ) const {
287 XMLCollection c( child( getDoc( true )->getElementById( XMLStr( fid ) ), MetaNode, Attr_metaName, attr ) );
288 return c ? c.attr( attr ) : string( "" );
289 }
290 // ----------------------------------------------------------------------------
291 void XMLFileCatalog::dropMetaData( CSTR fid, CSTR attr ) const {
292 vector<DOMNode*> gbc;
293 DOMNode* fn = getDoc( true )->getElementById( XMLStr( fid ) );
294 for ( XMLCollection c{child( fn, MetaNode )}; c; ++c )
295 if ( attr[0] == '*' || !c.attr( attr ).empty() ) gbc.push_back( c );
296 for ( const auto& i : gbc ) fn->removeChild( i );
297 }
298 // ----------------------------------------------------------------------------
299 DOMNode* XMLFileCatalog::element( CSTR element_name, bool print_err ) const {
300 DOMNode* node = getDoc( true )->getElementById( XMLStr( element_name ) );
301 if ( !node && print_err ) printError( "Cannot find element:" + element_name );
302 return node;
303 }
304 // ----------------------------------------------------------------------------
305 void XMLFileCatalog::deleteFID( CSTR fid ) const {
306 DOMNode *pn = nullptr, *fn = element( fid );
307 if ( fn ) pn = fn->getParentNode();
308 if ( pn ) pn->removeChild( fn );
309 }
310 // ----------------------------------------------------------------------------
311 void XMLFileCatalog::registerFID( CSTR fid ) const {
312 if ( !fid.empty() ) {
313 std::pair<DOMElement*, DOMElement*> res = i_registerFID( fid );
314 if ( res.first == 0 || res.second == 0 ) { printError( "Failed to register FID:" + fid ); }
315 return;
316 }
317 throw runtime_error( "XMLFileCatalog> Cannot register LFN for invalid FID:" + fid );
318 }
319 // ----------------------------------------------------------------------------
320 void XMLFileCatalog::renamePFN( CSTR pfn, CSTR new_pfn ) const {
321 DOMNode* node = getDoc( true )->getElementById( XMLStr( pfn ) );
322 if ( node && node->getNodeType() == DOMNode::ELEMENT_NODE ) {
323 ( (DOMElement*)node )->setAttribute( Attr_name, XMLStr( new_pfn ) );
324 m_update = true;
325 }
326 }
327 // ----------------------------------------------------------------------------
328 void XMLFileCatalog::deletePFN( CSTR pfn ) const {
329 DOMNode* node = getDoc( true )->getElementById( XMLStr( pfn ) );
330 if ( node ) {
331 DOMNode* pcoll_node = node->getParentNode();
332 pcoll_node->removeChild( node );
333 m_update = true;
334 for ( XMLCollection pcoll( pcoll_node, true ); pcoll; ++pcoll ) {
335 return; // there are other PFN entries left, so we are done
336 }
337 // delete empty file entry
338 DOMNode* file_node = pcoll_node->getParentNode();
339 file_node->getParentNode()->removeChild( file_node );
340 }
341 }
342 // ----------------------------------------------------------------------------
343 std::pair<DOMElement*, DOMElement*> XMLFileCatalog::i_registerFID( CSTR fid ) const {
344 if ( readOnly() ) {
345 printError( "Cannot update readonly catalog!" );
346 return {nullptr, nullptr};
347 }
348
350 DOMElement * file = (DOMElement*)element( fid, false ), *phyelem = 0, *logelem = 0;
351 DOMDocument* doc = getDoc( true );
352 if ( !file ) {
353 DOMNode* fde = doc->getElementsByTagName( XMLStr( "*" ) )->item( 0 );
354 file = m_doc->createElement( XMLStr( "File" ) );
355 file->setAttribute( Attr_ID, XMLStr( fid ) );
356 file->setIdAttribute( Attr_ID, true );
357 fde->appendChild( file );
358 m_update = true;
359 }
360 for ( XMLCollection c1( file ); c1; ++c1 ) {
361 char* nam = XMLString::transcode( c1->getNodeName() );
362 if ( nam == PFNCOLL ) phyelem = c1;
363 if ( nam == LFNCOLL ) logelem = c1;
364 XMLString::release( &nam );
365 }
366 if ( !phyelem ) {
367 phyelem = doc->createElement( PFNCOLL );
368 file->appendChild( phyelem );
369 m_update = true;
370 }
371 if ( !logelem ) {
372 logelem = doc->createElement( LFNCOLL );
373 file->appendChild( logelem );
374 m_update = true;
375 }
376 return {logelem, phyelem};
377 }
378 // ----------------------------------------------------------------------------
379 void XMLFileCatalog::registerPFN( CSTR fid, CSTR pfn, CSTR ftype ) const {
380 if ( !fid.empty() ) {
381 std::pair<DOMElement*, DOMElement*> res = i_registerFID( fid );
382 DOMElement * phyelem = res.second, *fnelem = 0;
383 for ( XMLCollection c( phyelem ); c; ++c ) {
384 char* nam = XMLString::transcode( c->getNodeName() );
385 if ( nam == PFNNODE ) {
386 XMLString::release( &nam );
387 nam = XMLString::transcode( c->getAttribute( Attr_name ) );
388 if ( nam == pfn ) {
389 XMLString::release( &nam );
390 fnelem = c;
391 break;
392 }
393 }
394 XMLString::release( &nam );
395 }
396 if ( !fnelem ) {
397 fnelem = getDoc( true )->createElement( PFNNODE );
398 phyelem->appendChild( fnelem );
399 fnelem->setAttribute( Attr_ftype, XMLStr( ftype ) );
400 fnelem->setAttribute( Attr_name, XMLStr( pfn ) );
401 fnelem->setIdAttribute( Attr_name, true );
402 m_update = true;
403 }
404 return;
405 }
406 throw runtime_error( "XMLFileCatalog> Cannot register PFN for invalid FID:" + fid );
407 }
408 // ----------------------------------------------------------------------------
409 void XMLFileCatalog::registerLFN( CSTR fid, CSTR lfn ) const {
410 if ( !fid.empty() ) {
411 std::pair<DOMElement*, DOMElement*> res = i_registerFID( fid );
412 DOMElement * logelem = res.first, *fnelem = 0;
413 for ( XMLCollection c( logelem ); c; ++c ) {
414 char* nam = XMLString::transcode( c->getNodeName() );
415 if ( nam == LFNNODE ) {
416 XMLString::release( &nam );
417 nam = XMLString::transcode( c->getAttribute( Attr_name ) );
418 if ( nam == lfn ) {
419 XMLString::release( &nam );
420 fnelem = c;
421 break;
422 }
423 }
424 }
425 if ( !fnelem ) {
426 fnelem = getDoc( true )->createElement( LFNNODE );
427 logelem->appendChild( fnelem );
428 fnelem->setAttribute( Attr_name, XMLStr( lfn ) );
429 fnelem->setIdAttribute( Attr_name, true );
430 m_update = true;
431 }
432 return;
433 }
434 throw runtime_error( "XMLFileCatalog> Cannot register LFN for invalid FID:" + fid );
435 }
436 // ----------------------------------------------------------------------------
437 void XMLFileCatalog::commit() {
438 try {
439 if ( dirty() && !readOnly() ) {
440 string xmlfile = getfile( true );
441 XMLStr ii( "LS" );
442 DOMImplementation* imp = DOMImplementationRegistry::getDOMImplementation( ii );
443 auto tar = std::make_unique<LocalFileFormatTarget>( xmlfile.c_str() );
444 #if _XERCES_VERSION <= 30000
445 DOMWriter* wr = imp->createDOMWriter();
446 wr->setFeature( XMLUni::fgDOMWRTFormatPrettyPrint, true );
447 wr->writeNode( tar.get(), *m_doc );
448 wr->release();
449 #else
450 DOMLSOutput* output = imp->createLSOutput();
451 output->setByteStream( tar.get() );
452 DOMLSSerializer* wr = imp->createLSSerializer();
453 wr->getDomConfig()->setParameter( XMLStr( "format-pretty-print" ), true );
454 wr->write( m_doc, output );
455 output->release();
456 wr->release();
457 #endif
458 }
459 } catch ( exception& e ) { printError( string( "Cannot open output file:" ) + e.what() ); } catch ( ... ) {
460 printError( "Unknown IO rrror." );
461 }
462 }
463 // ----------------------------------------------------------------------------
464 string XMLFileCatalog::getfile( bool create ) {
465 string protocol, path;
466 XMLURL xerurl;
467 try {
468 xerurl = (const XMLCh*)XMLStr( m_file );
469 protocol = _toString( xerurl.getProtocolName() );
470 path = _toString( xerurl.getPath() );
471 } catch ( const XMLException& e ) { printError( _toString( e.getMessage() ) ); }
472 if ( protocol.empty() ) {
473 printError( "Missing protocol." );
474 } else if ( protocol == "http" || protocol == "ftp" ) {
475 m_rdOnly = true;
476 } else if ( protocol == "file" ) {
477 m_rdOnly = false;
478 struct stat buff;
479 int exist = ::stat( path.c_str(), &buff ) != -1;
480 if ( create && !exist ) {
481 MsgStream log( m_msgSvc, "XMLCatalog" );
482 log << MSG::INFO << "File '" << path << "' does not exist. New file created." << endmsg;
483 ofstream out{path};
484 if ( !m_rdOnly && out.is_open() ) {
485 out << (CSTR)EmptyCatalog << endl;
486 } else {
487 printError( "Problem creating file " + path );
488 }
489 out.close();
490 } else if ( exist ) {
491 return path;
492 } else if ( !create ) {
493 return "";
494 }
495 } else {
496 printError( protocol + ": protocol not supported." );
497 }
498 return path;
499 }
Gaudi::XMLFileCatalog::registerPFN
void registerPFN(CSTR fid, CSTR pfn, CSTR ftype) const override
Create a FileID and Node of the physical file name with all the attributes.
Definition: XMLFileCatalog.cpp:379
Gaudi::XMLFileCatalog::getMetaDataItem
std::string getMetaDataItem(CSTR fid, CSTR name) const override
Access metadata item.
Definition: XMLFileCatalog.cpp:286
Gaudi::XMLFileCatalog::m_file
std::string m_file
Definition: XMLFileCatalog.h:104
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
Gaudi::XMLFileCatalog::dirty
bool dirty() const override
Check if the catalog should be updated.
Definition: XMLFileCatalog.h:51
Gaudi::XMLFileCatalog::registerLFN
void registerLFN(CSTR fid, CSTR lfn) const override
Create a FileID and Node of the logical file name with all the attributes.
Definition: XMLFileCatalog.cpp:409
std::string::empty
T empty(T... args)
gaudirun.c
c
Definition: gaudirun.py:487
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:932
DECLARE_FACTORY
#define DECLARE_FACTORY(type, factory)
Definition: PluginServiceV1.h:41
Gaudi::XMLFileCatalog::registerFID
void registerFID(CSTR fid) const override
Create a FileID and Node.
Definition: XMLFileCatalog.cpp:311
MsgStream.h
gaudirun.output
output
Definition: gaudirun.py:484
std::endl
T endl(T... args)
Gaudi::XMLFileCatalog::getFID
void getFID(Strings &fids) const override
Dump all file Identifiers.
Definition: XMLFileCatalog.cpp:235
std
STL namespace.
Gaudi::XMLFileCatalog::getMetaData
void getMetaData(CSTR fid, Attributes &attr) const override
Dump all MetaData of the catalog for a given file ID.
Definition: XMLFileCatalog.cpp:253
Gaudi::XMLFileCatalog::getfile
std::string getfile(bool create)
Definition: XMLFileCatalog.cpp:464
Gaudi::XMLFileCatalog::setMetaData
void setMetaData(CSTR fid, CSTR name, CSTR value) const override
Insert/update metadata item.
Definition: XMLFileCatalog.cpp:270
Gaudi::XMLFileCatalog::renamePFN
void renamePFN(CSTR pfn, CSTR new_pfn) const override
rename a PFN
Definition: XMLFileCatalog.cpp:320
Gaudi::XMLFileCatalog::lookupFID
std::string lookupFID(CSTR lfn) const
Definition: XMLFileCatalog.cpp:220
Gaudi::XMLFileCatalog::m_parser
std::unique_ptr< xercesc::XercesDOMParser > m_parser
Definition: XMLFileCatalog.h:102
Gaudi::XMLFileCatalog::dropMetaData
void dropMetaData(CSTR fid) const override
Drop all metadata of one FID.
Definition: XMLFileCatalog.h:87
XMLFileCatalog.h
Gaudi::XMLFileCatalog::i_registerFID
std::pair< xercesc::DOMElement *, xercesc::DOMElement * > i_registerFID(CSTR fid) const
Definition: XMLFileCatalog.cpp:343
std::string
STL class.
Service.h
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:210
MSG::FATAL
Definition: IMessageSvc.h:15
std::vector::push_back
T push_back(T... args)
std::ofstream
STL class.
Gaudi::XMLFileCatalog::CSTR
const std::string & CSTR
Definition: XMLFileCatalog.h:29
compareOutputFiles.par
string par
Definition: compareOutputFiles.py:465
Gaudi::XMLFileCatalog::getLFN
void getLFN(CSTR fid, Files &files) const override
Dump all logical file names of the catalog associate to the FileID.
Definition: XMLFileCatalog.cpp:247
Gaudi::XMLFileCatalog::deletePFN
void deletePFN(CSTR pfn) const override
remove a PFN
Definition: XMLFileCatalog.cpp:328
std::exception::what
T what(T... args)
std::strlen
T strlen(T... args)
operator==
bool operator==(const GaudiUtils::Allocator< T1 > &, const GaudiUtils::Allocator< T2 > &)
Definition: Allocator.h:231
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:92
std::runtime_error
STL class.
Gaudi::XMLFileCatalog::m_errHdlr
std::unique_ptr< xercesc::ErrorHandler > m_errHdlr
Definition: XMLFileCatalog.h:103
IMessageSvc
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:37
Gaudi::XMLFileCatalog::m_doc
xercesc::DOMDocument * m_doc
Definition: XMLFileCatalog.h:101
Gaudi::XMLFileCatalog::getPFN
void getPFN(CSTR fid, Files &files) const override
Dump all physical file names of the catalog and their attributes associate to the FileID.
Definition: XMLFileCatalog.cpp:241
CSTR
const std::string CSTR
Definition: MultiStoreSvc.cpp:41
std::exception
STL class.
Gaudi::XMLFileCatalog::m_rdOnly
bool m_rdOnly
Definition: XMLFileCatalog.h:99
std::pair
Gaudi::IFileCatalog::Factory
Gaudi::PluginService::Factory< IInterface *(const std::string &, IMessageSvc *)> Factory
Definition: IFileCatalog.h:32
std::unique_ptr::get
T get(T... args)
PluginService.h
std::string::length
T length(T... args)
std::vector
STL class.
Gaudi::createGuidAsString
std::string createGuidAsString()
Helper function creating file identifier using the UUID mechanism.
Gaudi::XMLFileCatalog::readOnly
bool readOnly() const override
Check if the catalog is read-only.
Definition: XMLFileCatalog.h:49
Gaudi::XMLFileCatalog::deleteFID
void deleteFID(CSTR FileID) const override
Delete FileID Node from the catalog.
Definition: XMLFileCatalog.cpp:305
Gaudi::XMLFileCatalog::createFID
std::string createFID() const override
Catalog interface.
Definition: XMLFileCatalog.cpp:182
std::string::c_str
T c_str(T... args)
Gaudi::XMLFileCatalog::commit
void commit() override
Save DOM catalog to file.
Definition: XMLFileCatalog.cpp:437
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
gaudirun.s
string s
Definition: gaudirun.py:316
Gaudi::XMLFileCatalog::getDoc
xercesc::DOMDocument * getDoc(bool throw_if_no_exists=true) const
Definition: XMLFileCatalog.cpp:184
Gaudi::XMLFileCatalog::child
xercesc::DOMNode * child(xercesc::DOMNode *par, CSTR tag, CSTR attr="", CSTR val="") const
Definition: XMLFileCatalog.cpp:260
MSG::ERROR
Definition: IMessageSvc.h:15
Gaudi::XMLFileCatalog::init
void init() override
Parse the DOM tree of the XML catalog.
Definition: XMLFileCatalog.cpp:195
Gaudi::XMLFileCatalog::element
xercesc::DOMNode * element(CSTR fid, bool print_err=true) const
Definition: XMLFileCatalog.cpp:299
Gaudi::XMLFileCatalog::m_msgSvc
IMessageSvc * m_msgSvc
Definition: XMLFileCatalog.h:105
createGuidAsString.h
MSG::INFO
Definition: IMessageSvc.h:15
Gaudi::XMLFileCatalog
This class constitutes the core of the XML based FileCatalog API for POOL.
Definition: XMLFileCatalog.h:27
std::cout
Gaudi::XMLFileCatalog::m_update
bool m_update
Definition: XMLFileCatalog.h:100
Gaudi
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
Gaudi.Configuration.log
log
Definition: Configuration.py:13
Gaudi::XMLFileCatalog::printError
void printError(CSTR msg, bool throw_exc=true) const
Definition: XMLFileCatalog.cpp:189