| The Gaudi Framework v29r1 (5cd95fa2)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Protected Types | Private Member Functions | Private Attributes | List of all members
Gaudi::XMLFileCatalog Class Reference

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

`#include <src/component/XMLFileCatalog.h>`

Inheritance diagram for Gaudi::XMLFileCatalog:
[legend]
Collaboration diagram for Gaudi::XMLFileCatalog:
[legend]

## Public Member Functions
| XMLFileCatalog (CSTR url, IMessageSvc *m)
| Create a catalog file, initialization of XercesC. More...
| ~XMLFileCatalog () override=default
| Destructor,. 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 a physical file name. More...
std::string | lookupPFN (CSTR fid) 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 FileID) const override
| Delete FileID Node from the catalog. More...
void | registerPFN (CSTR fid, CSTR pfn, CSTR ftype) const override
| Create a FileID and Node of the physical file name with all the attributes. More...
void | registerLFN (CSTR fid, CSTR lfn) const override
| Create a FileID and Node of the logical file name with all the attributes. More...
void | registerFID (CSTR fid) const override
| Create a FileID and 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 name, CSTR value) 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...
Public Member Functions inherited from implements< IFileCatalog >
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...
| implements ()=default
| Default constructor. More...
| implements (const implements &)
| Copy constructor (zero the reference count) More...
implements & | operator= (const implements &)
| Assignment operator (do not touch the reference count). More...
| ~implements () override=default
| Virtual destructor. More...
unsigned long | addRef () override
| Reference Interface instance. More...
unsigned long | release () override
| Release Interface instance. More...
unsigned long | refCount () const override
| Current reference count. More...
Public Member Functions inherited from extend_interfaces< Interfaces... >
| ~extend_interfaces () override=default
| Virtual destructor. More...

## Protected Types
typedef const std::string & | CSTR

## Private Member Functions
xercesc::DOMDocument * | getDoc (bool throw_if_no_exists=true) const
std::string | getfile (bool create)
void | printError (CSTR msg, bool throw_exc=true) const
std::string | lookupFID (CSTR lfn) const
xercesc::DOMNode * | element (CSTR fid, bool print_err=true) const
xercesc::DOMNode * | child (xercesc::DOMNode *par, CSTR tag, CSTR attr="", CSTR val="") const
std::pair< xercesc::DOMElement *, xercesc::DOMElement * > | i_registerFID (CSTR fid) const

## Private Attributes
bool | m_rdOnly
bool | m_update
xercesc::DOMDocument * | m_doc
std::unique_ptr< xercesc::XercesDOMParser > | m_parser
std::unique_ptr< xercesc::ErrorHandler > | m_errHdlr
std::string | m_file
IMessageSvc * | m_msgSvc

## Additional Inherited Members
Public Types inherited from implements< IFileCatalog >
using | base_class = implements< Interfaces... >
| Typedef to this class. More...
using | extend_interfaces_base = extend_interfaces< Interfaces... >
| Typedef to the base of this class. More...
using | iids = typename extend_interfaces_base::ext_iids
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...
Protected Attributes inherited from implements< IFileCatalog >
std::atomic_ulong | m_refCount
| Reference counter. More...

## Detailed Description

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

It uses the DOM model and the external XercesC library for parsing.

Definition at line 26 of file XMLFileCatalog.h.

## Member Typedef Documentation

typedef const std::string& Gaudi::XMLFileCatalog::CSTR
| protected

Definition at line 29 of file XMLFileCatalog.h.

## Constructor & Destructor Documentation

XMLFileCatalog::XMLFileCatalog | ( | CSTR | url,
|  | IMessageSvc * | m
| ) |  |

Create a catalog file, initialization of XercesC.

Definition at line 192 of file XMLFileCatalog.cpp.

193 : m_rdOnly( false ), m_update( false ), m_doc( 0 ), m_file( uri ), m_msgSvc( m )
194 {
195 }
Gaudi::XMLFileCatalog::m_file
std::string m_file
Definition: XMLFileCatalog.h:103
Gaudi::XMLFileCatalog::m_doc
xercesc::DOMDocument * m_doc
Definition: XMLFileCatalog.h:100
Gaudi::XMLFileCatalog::m_rdOnly
bool m_rdOnly
Definition: XMLFileCatalog.h:98
Gaudi::XMLFileCatalog::m_msgSvc
IMessageSvc * m_msgSvc
Definition: XMLFileCatalog.h:104
Gaudi::XMLFileCatalog::m_update
bool m_update
Definition: XMLFileCatalog.h:99

Gaudi::XMLFileCatalog::~XMLFileCatalog | ( |  | ) |
| override default

Destructor,.

## Member Function Documentation

DOMNode * XMLFileCatalog::child | ( | xercesc::DOMNode * | par,
|  | CSTR | tag,
|  | CSTR | attr = `""`,
|  | CSTR | val = `""`
| ) |  | const
| private

Definition at line 288 of file XMLFileCatalog.cpp.

289 {
290 for ( XMLCollection c( par ); c; ++c ) {
291 if ( c.tag() == tag ) {
292 if ( !attr.empty() && c.attr( attr ) != val ) continue;
293 return c;
294 }
295 }
296 return 0;
297 }
std::string::empty
T empty(T...args)
gaudirun.c
c
Definition: gaudirun.py:407
compareOutputFiles.par
string par
Definition: compareOutputFiles.py:437

void XMLFileCatalog::commit | ( |  | ) |
| override

Save DOM catalog to file.

Definition at line 454 of file XMLFileCatalog.cpp.

455 {
456 try {
457 if ( dirty() && !readOnly() ) {
458 string xmlfile = getfile( true );
459 XMLStr ii( "LS" );
460 DOMImplementation* imp = DOMImplementationRegistry::getDOMImplementation( ii );
461 std::unique_ptr<XMLFormatTarget> tar{new LocalFileFormatTarget( xmlfile.c_str() )};
462 #if _XERCES_VERSION <= 30000
463 DOMWriter* wr = imp->createDOMWriter();
464 wr->setFeature( XMLUni::fgDOMWRTFormatPrettyPrint, true );
465 wr->writeNode( tar.get(), *m_doc );
466 wr->release();
467 #else
468 DOMLSOutput* output = imp->createLSOutput();
469 output->setByteStream( tar.get() );
470 DOMLSSerializer* wr = imp->createLSSerializer();
471 wr->getDomConfig()->setParameter( XMLStr( "format-pretty-print" ), true );
472 wr->write( m_doc, output );
473 output->release();
474 wr->release();
475 #endif
476 }
477 } catch ( exception& e ) {
478 printError( string( "Cannot open output file:" ) + e.what() );
479 } catch ( ... ) {
480 printError( "Unknown IO rrror." );
481 }
482 }
Gaudi::XMLFileCatalog::readOnly
bool readOnly() const override
Check if the catalog is read-only.
Definition: XMLFileCatalog.h:52
gaudirun.output
output
Definition: gaudirun.py:404
Gaudi::XMLFileCatalog::getfile
std::string getfile(bool create)
Definition: XMLFileCatalog.cpp:484
std::unique_ptr::release
T release(T...args)
std::exception::what
T what(T...args)
Gaudi::XMLFileCatalog::printError
void printError(CSTR msg, bool throw_exc=true) const
Definition: XMLFileCatalog.cpp:206
Gaudi::XMLFileCatalog::m_doc
xercesc::DOMDocument * m_doc
Definition: XMLFileCatalog.h:100
std::exception
STL class.
std::unique_ptr
STL class.
std::string::c_str
T c_str(T...args)
Gaudi::XMLFileCatalog::dirty
bool dirty() const override
Check if the catalog should be updated.
Definition: XMLFileCatalog.h:54

CSTR Gaudi::XMLFileCatalog::connectInfo | ( |  | ) | const
| inline override

Access to connect string.

Definition at line 41 of file XMLFileCatalog.h.

41 { return m_file; }
Gaudi::XMLFileCatalog::m_file
std::string m_file
Definition: XMLFileCatalog.h:103

std::string XMLFileCatalog::createFID | ( |  | ) | const
| override

Catalog interface.

Create file identifier using UUID mechanism.

Create file identifier using UUID mechanism

Definition at line 198 of file XMLFileCatalog.cpp.

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

void XMLFileCatalog::deleteFID | ( | CSTR | FileID | ) | const
| override

Delete FileID Node from the catalog.

Definition at line 338 of file XMLFileCatalog.cpp.

339 {
340 DOMNode *pn = nullptr, *fn = element( fid );
341 if ( fn ) pn = fn->getParentNode();
342 if ( pn ) pn->removeChild( fn );
343 }
Gaudi::XMLFileCatalog::element
xercesc::DOMNode * element(CSTR fid, bool print_err=true) const
Definition: XMLFileCatalog.cpp:331

bool Gaudi::XMLFileCatalog::dirty | ( |  | ) | const
| inline override

Check if the catalog should be updated.

Definition at line 54 of file XMLFileCatalog.h.

54 { return m_update; }
Gaudi::XMLFileCatalog::m_update
bool m_update
Definition: XMLFileCatalog.h:99

void Gaudi::XMLFileCatalog::dropMetaData | ( | CSTR | fid | ) | const
| inline override

Drop all metadata of one FID.

Definition at line 86 of file XMLFileCatalog.h.

86 { dropMetaData( fid, "*" ); }
Gaudi::XMLFileCatalog::dropMetaData
void dropMetaData(CSTR fid) const override
Drop all metadata of one FID.
Definition: XMLFileCatalog.h:86

void XMLFileCatalog::dropMetaData | ( | CSTR | fid,
|  | CSTR | attr
| ) |  | const
| override

Drop specified metadata item.

Definition at line 322 of file XMLFileCatalog.cpp.

323 {
324 vector<DOMNode*> gbc;
325 DOMNode* fn = getDoc( true )->getElementById( XMLStr( fid ) );
326 for ( XMLCollection c{child( fn, MetaNode )}; c; ++c )
327 if ( attr[0] == '*' || !c.attr( attr ).empty() ) gbc.push_back( c );
328 for ( const auto& i : gbc ) fn->removeChild( i );
329 }
gaudirun.c
c
Definition: gaudirun.py:407
std::vector::push_back
T push_back(T...args)
Gaudi::XMLFileCatalog::child
xercesc::DOMNode * child(xercesc::DOMNode *par, CSTR tag, CSTR attr="", CSTR val="") const
Definition: XMLFileCatalog.cpp:288
Gaudi::XMLFileCatalog::getDoc
xercesc::DOMDocument * getDoc(bool throw_if_no_exists=true) const
Definition: XMLFileCatalog.cpp:200
std::vector
STL class.

DOMNode * XMLFileCatalog::element | ( | CSTR | fid,
|  | bool | print_err = `true`
| ) |  | const
| private

Definition at line 331 of file XMLFileCatalog.cpp.

332 {
333 DOMNode* node = getDoc( true )->getElementById( XMLStr( element_name ) );
334 if ( !node && print_err ) printError( "Cannot find element:" + element_name );
335 return node;
336 }
Gaudi::XMLFileCatalog::printError
void printError(CSTR msg, bool throw_exc=true) const
Definition: XMLFileCatalog.cpp:206
Gaudi::XMLFileCatalog::getDoc
xercesc::DOMDocument * getDoc(bool throw_if_no_exists=true) const
Definition: XMLFileCatalog.cpp:200

bool Gaudi::XMLFileCatalog::existsFID | ( | CSTR | fid | ) | const
| inline override

Return the status of a FileID.

Definition at line 64 of file XMLFileCatalog.h.

64 { return element( fid, false ) != 0; }
Gaudi::XMLFileCatalog::element
xercesc::DOMNode * element(CSTR fid, bool print_err=true) const
Definition: XMLFileCatalog.cpp:331

bool Gaudi::XMLFileCatalog::existsLFN | ( | CSTR | lfn | ) | const
| inline override

Return the status of a logical file name.

Definition at line 60 of file XMLFileCatalog.h.

60 { return element( lfn, false ) != 0; }
Gaudi::XMLFileCatalog::element
xercesc::DOMNode * element(CSTR fid, bool print_err=true) const
Definition: XMLFileCatalog.cpp:331

bool Gaudi::XMLFileCatalog::existsPFN | ( | CSTR | pfn | ) | const
| inline override

Return the status of a physical file name.

Definition at line 56 of file XMLFileCatalog.h.

56 { return element( pfn, false ) != 0; }
Gaudi::XMLFileCatalog::element
xercesc::DOMNode * element(CSTR fid, bool print_err=true) const
Definition: XMLFileCatalog.cpp:331

DOMDocument * XMLFileCatalog::getDoc | ( | bool | throw_if_no_exists = `true` | ) | const
| private

Definition at line 200 of file XMLFileCatalog.cpp.

201 {
202 if ( !m_doc && throw_if_no_exists ) printError( "The XML catalog was not started.", true );
203 return m_doc;
204 }
Gaudi::XMLFileCatalog::printError
void printError(CSTR msg, bool throw_exc=true) const
Definition: XMLFileCatalog.cpp:206
Gaudi::XMLFileCatalog::m_doc
xercesc::DOMDocument * m_doc
Definition: XMLFileCatalog.h:100

void XMLFileCatalog::getFID | ( | Strings & | fids | ) | const
| override

Dump all file Identifiers.

Definition at line 259 of file XMLFileCatalog.cpp.

260 {
261 fids.clear();
262 DOMNode* fde = getDoc( true )->getElementsByTagName( XMLStr( "*" ) )->item( 0 );
263 for ( XMLCollection c( child( fde, "File" ), false ); c; ++c ) fids.push_back( c.attr( Attr_ID ) );
264 }
gaudirun.c
c
Definition: gaudirun.py:407
Gaudi::XMLFileCatalog::child
xercesc::DOMNode * child(xercesc::DOMNode *par, CSTR tag, CSTR attr="", CSTR val="") const
Definition: XMLFileCatalog.cpp:288
Gaudi::XMLFileCatalog::getDoc
xercesc::DOMDocument * getDoc(bool throw_if_no_exists=true) const
Definition: XMLFileCatalog.cpp:200

string XMLFileCatalog::getfile | ( | bool | create | ) |
| private

Definition at line 484 of file XMLFileCatalog.cpp.

485 {
486 string protocol, path;
487 XMLURL xerurl;
488 try {
489 xerurl = (const XMLCh*)XMLStr( m_file );
490 protocol = _toString( xerurl.getProtocolName() );
491 path = _toString( xerurl.getPath() );
492 } catch ( const XMLException& e ) {
493 printError( _toString( e.getMessage() ) );
494 }
495 if ( protocol.empty() ) {
496 printError( "Missing protocol." );
497 } else if ( protocol == "http" || protocol == "ftp" ) {
498 m_rdOnly = true;
499 } else if ( protocol == "file" ) {
500 m_rdOnly = false;
501 struct stat buff;
502 int exist = ::stat( path.c_str(), &buff ) != -1;
503 if ( create && !exist ) {
504 MsgStream log( m_msgSvc, "XMLCatalog" );
505 log << MSG::INFO << "File '" << path << "' does not exist. New file created." << endmsg;
506 ofstream out{path};
507 if ( !m_rdOnly && out.is_open() ) {
508 out << (CSTR)EmptyCatalog << endl;
509 } else {
510 printError( "Problem creating file " + path );
511 }
512 out.close();
513 } else if ( exist ) {
514 return path;
515 } else if ( !create ) {
516 return "";
517 }
518 } else {
519 printError( protocol + ": protocol not supported." );
520 }
521 return path;
522 }
Gaudi::XMLFileCatalog::m_file
std::string m_file
Definition: XMLFileCatalog.h:103
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
std::string::empty
T empty(T...args)
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:895
std::ofstream
STL class.
Gaudi::XMLFileCatalog::CSTR
const std::string & CSTR
Definition: XMLFileCatalog.h:29
Gaudi::XMLFileCatalog::printError
void printError(CSTR msg, bool throw_exc=true) const
Definition: XMLFileCatalog.cpp:206
Gaudi::XMLFileCatalog::m_rdOnly
bool m_rdOnly
Definition: XMLFileCatalog.h:98
Gaudi::XMLFileCatalog::m_msgSvc
IMessageSvc * m_msgSvc
Definition: XMLFileCatalog.h:104
MSG::INFO
Definition: IMessageSvc.h:16
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Gaudi.Configuration.log
log
Definition: Configuration.py:13

void XMLFileCatalog::getLFN | ( | CSTR | fid,
|  | Files & | files
| ) |  | const
| override

Dump all logical file names of the catalog associate to the FileID.

Definition at line 273 of file XMLFileCatalog.cpp.

274 {
275 files.clear();
276 for ( XMLCollection c( child( child( element( fid, false ), LFNCOLL ), LFNNODE ), false ); c; ++c )
277 files.emplace_back( c.attr( Attr_name ), fid );
278 }
gaudirun.c
c
Definition: gaudirun.py:407
Gaudi::XMLFileCatalog::element
xercesc::DOMNode * element(CSTR fid, bool print_err=true) const
Definition: XMLFileCatalog.cpp:331
Gaudi::XMLFileCatalog::child
xercesc::DOMNode * child(xercesc::DOMNode *par, CSTR tag, CSTR attr="", CSTR val="") const
Definition: XMLFileCatalog.cpp:288

void XMLFileCatalog::getMetaData | ( | CSTR | fid,
|  | Attributes & | attr
| ) |  | const
| override

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

Definition at line 280 of file XMLFileCatalog.cpp.

281 {
282 attr.clear();
283 for ( XMLCollection c( child( element( fid ), MetaNode ), false ); c; ++c )
284 attr.emplace_back( c.attr( Attr_metaName ), c.attr( Attr_metaValue ) );
285 if ( attr.size() > 0 ) attr.emplace_back( "guid", fid );
286 }
gaudirun.c
c
Definition: gaudirun.py:407
Gaudi::XMLFileCatalog::element
xercesc::DOMNode * element(CSTR fid, bool print_err=true) const
Definition: XMLFileCatalog.cpp:331
Gaudi::XMLFileCatalog::child
xercesc::DOMNode * child(xercesc::DOMNode *par, CSTR tag, CSTR attr="", CSTR val="") const
Definition: XMLFileCatalog.cpp:288

string XMLFileCatalog::getMetaDataItem | ( | CSTR | fid,
|  | CSTR | name
| ) |  | const
| override

Access metadata item.

Definition at line 316 of file XMLFileCatalog.cpp.

317 {
318 XMLCollection c( child( getDoc( true )->getElementById( XMLStr( fid ) ), MetaNode, Attr_metaName, attr ) );
319 return c ? c.attr( attr ) : string( "" );
320 }
gaudirun.c
c
Definition: gaudirun.py:407
std::string
STL class.
Gaudi::XMLFileCatalog::child
xercesc::DOMNode * child(xercesc::DOMNode *par, CSTR tag, CSTR attr="", CSTR val="") const
Definition: XMLFileCatalog.cpp:288
Gaudi::XMLFileCatalog::getDoc
xercesc::DOMDocument * getDoc(bool throw_if_no_exists=true) const
Definition: XMLFileCatalog.cpp:200

void XMLFileCatalog::getPFN | ( | CSTR | fid,
|  | Files & | files
| ) |  | const
| override

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

Definition at line 266 of file XMLFileCatalog.cpp.

267 {
268 files.clear();
269 for ( XMLCollection c( child( child( element( fid, false ), PFNCOLL ), PFNNODE ), false ); c; ++c )
270 files.emplace_back( c.attr( Attr_name ), c.attr( Attr_ftype ) );
271 }
gaudirun.c
c
Definition: gaudirun.py:407
Gaudi::XMLFileCatalog::element
xercesc::DOMNode * element(CSTR fid, bool print_err=true) const
Definition: XMLFileCatalog.cpp:331
Gaudi::XMLFileCatalog::child
xercesc::DOMNode * child(xercesc::DOMNode *par, CSTR tag, CSTR attr="", CSTR val="") const
Definition: XMLFileCatalog.cpp:288

std::pair< DOMElement *, DOMElement * > XMLFileCatalog::i_registerFID | ( | CSTR | fid | ) | const
| private

It creates a new node File with name = fid in the XML file catalog

Definition at line 357 of file XMLFileCatalog.cpp.

358 {
359 if ( readOnly() ) {
360 printError( "Cannot update readonly catalog!" );
361 return {nullptr, nullptr};
362 }
363
365 DOMElement *file = (DOMElement *)element( fid, false ), *phyelem = 0, *logelem = 0;
366 DOMDocument* doc = getDoc( true );
367 if ( !file ) {
368 DOMNode* fde = doc->getElementsByTagName( XMLStr( "*" ) )->item( 0 );
369 file = m_doc->createElement( XMLStr( "File" ) );
370 file->setAttribute( Attr_ID, XMLStr( fid ) );
371 file->setIdAttribute( Attr_ID, true );
372 fde->appendChild( file );
373 m_update = true;
374 }
375 for ( XMLCollection c1( file ); c1; ++c1 ) {
376 char* nam = XMLString::transcode( c1->getNodeName() );
377 if ( nam == PFNCOLL ) phyelem = c1;
378 if ( nam == LFNCOLL ) logelem = c1;
379 XMLString::release( &nam );
380 }
381 if ( !phyelem ) {
382 phyelem = doc->createElement( PFNCOLL );
383 file->appendChild( phyelem );
384 m_update = true;
385 }
386 if ( !logelem ) {
387 logelem = doc->createElement( LFNCOLL );
388 file->appendChild( logelem );
389 m_update = true;
390 }
391 return {logelem, phyelem};
392 }
Gaudi::XMLFileCatalog::readOnly
bool readOnly() const override
Check if the catalog is read-only.
Definition: XMLFileCatalog.h:52
Gaudi::XMLFileCatalog::element
xercesc::DOMNode * element(CSTR fid, bool print_err=true) const
Definition: XMLFileCatalog.cpp:331
Gaudi::XMLFileCatalog::printError
void printError(CSTR msg, bool throw_exc=true) const
Definition: XMLFileCatalog.cpp:206
Gaudi::XMLFileCatalog::m_doc
xercesc::DOMDocument * m_doc
Definition: XMLFileCatalog.h:100
Gaudi::XMLFileCatalog::getDoc
xercesc::DOMDocument * getDoc(bool throw_if_no_exists=true) const
Definition: XMLFileCatalog.cpp:200
Gaudi::XMLFileCatalog::m_update
bool m_update
Definition: XMLFileCatalog.h:99
HiveAlgSequencer.c1
c1
Definition: HiveAlgSequencer.py:25

void XMLFileCatalog::init | ( |  | ) |
| override

Parse the DOM tree of the XML catalog.

Definition at line 215 of file XMLFileCatalog.cpp.

216 {
217 string xmlFile = getfile( false );
218 try {
219 m_parser.reset( new XercesDOMParser );
220 m_parser->setValidationScheme( XercesDOMParser::Val_Auto );
221 m_parser->setDoNamespaces( false );
222 DTDRedirect dtdinmem;
223 m_parser->setEntityResolver( &dtdinmem );
224 if ( !m_errHdlr ) m_errHdlr.reset( new ErrHandler( m_msgSvc ) );
225 m_parser->setErrorHandler( m_errHdlr.get() );
226 if ( !xmlFile.empty() ) {
227 m_parser->parse( xmlFile.c_str() );
228 } else {
229 const std::string& s = EmptyCatalog;
230 MemBufInputSource src( (const XMLByte*)s.c_str(), s.length(), "MemCatalog" );
231 m_parser->parse( src );
232 }
233 m_doc = m_parser->getDocument();
234 } catch ( const XMLException& e ) {
235 printError( "XML parse error[" + xmlFile + "]: " + _toString( e.getMessage() ) );
236 } catch ( const DOMException& e ) {
237 printError( "XML parse error[" + xmlFile + "]: " + _toString( e.getMessage() ) );
238 } catch ( ... ) {
239 printError( "UNKNOWN XML parse error in file " + xmlFile );
240 }
241 }
std::string::empty
T empty(T...args)
Gaudi::XMLFileCatalog::getfile
std::string getfile(bool create)
Definition: XMLFileCatalog.cpp:484
Gaudi::XMLFileCatalog::m_parser
std::unique_ptr< xercesc::XercesDOMParser > m_parser
Definition: XMLFileCatalog.h:101
std::string
STL class.
Gaudi::XMLFileCatalog::printError
void printError(CSTR msg, bool throw_exc=true) const
Definition: XMLFileCatalog.cpp:206
Gaudi::XMLFileCatalog::m_errHdlr
std::unique_ptr< xercesc::ErrorHandler > m_errHdlr
Definition: XMLFileCatalog.h:102
Gaudi::XMLFileCatalog::m_doc
xercesc::DOMDocument * m_doc
Definition: XMLFileCatalog.h:100
std::unique_ptr::reset
T reset(T...args)
std::unique_ptr::get
T get(T...args)
std::string::length
T length(T...args)
std::string::c_str
T c_str(T...args)
gaudirun.s
string s
Definition: gaudirun.py:253
Gaudi::XMLFileCatalog::m_msgSvc
IMessageSvc * m_msgSvc
Definition: XMLFileCatalog.h:104

string XMLFileCatalog::lookupFID | ( | CSTR | lfn | ) | const
| private

Definition at line 243 of file XMLFileCatalog.cpp.

244 {
245 std::string result;
246 DOMNode* e = element( fid, false );
247 e = e ? e->getParentNode() : 0; // Mode up to <logical>
248 e = e ? e->getParentNode() : 0; // Mode up to <File>
249 if ( e ) {
250 if ( e->getAttributes() ) { // Need to check this. The node may be no DOMElement
251 char* nam = XMLString::transcode( ( (DOMElement*)e )->getAttribute( Attr_ID ) );
252 if ( nam ) result = nam;
253 XMLString::release( &nam );
254 }
255 }
256 return result;
257 }
Gaudi::XMLFileCatalog::element
xercesc::DOMNode * element(CSTR fid, bool print_err=true) const
Definition: XMLFileCatalog.cpp:331
std::string
STL class.

std::string Gaudi::XMLFileCatalog::lookupLFN | ( | CSTR | lfn | ) | const
| inline override

Lookup file identifier by logical file name.

Definition at line 62 of file XMLFileCatalog.h.

62 { return lookupFID( lfn ); }
Gaudi::XMLFileCatalog::lookupFID
std::string lookupFID(CSTR lfn) const
Definition: XMLFileCatalog.cpp:243

std::string Gaudi::XMLFileCatalog::lookupPFN | ( | CSTR | fid | ) | const
| inline override

Lookup file identifier by physical file name.

Definition at line 58 of file XMLFileCatalog.h.

58 { return lookupFID( fid ); }
Gaudi::XMLFileCatalog::lookupFID
std::string lookupFID(CSTR lfn) const
Definition: XMLFileCatalog.cpp:243

void XMLFileCatalog::printError | ( | CSTR | msg,
|  | bool | throw_exc = `true`
| ) |  | const
| private

Definition at line 206 of file XMLFileCatalog.cpp.

207 {
208 MsgStream log( m_msgSvc, "XMLCatalog" );
209 log << MSG::FATAL << msg << endmsg;
210 if ( rethrow ) {
211 throw runtime_error( "XMLFileCatalog> " + msg );
212 }
213 }
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
MSG::FATAL
Definition: IMessageSvc.h:16
std::runtime_error
STL class.
Gaudi::XMLFileCatalog::m_msgSvc
IMessageSvc * m_msgSvc
Definition: XMLFileCatalog.h:104
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Gaudi.Configuration.log
log
Definition: Configuration.py:13

bool Gaudi::XMLFileCatalog::readOnly | ( |  | ) | const
| inline override

Check if the catalog is read-only.

Definition at line 52 of file XMLFileCatalog.h.

52 { return m_rdOnly; }
Gaudi::XMLFileCatalog::m_rdOnly
bool m_rdOnly
Definition: XMLFileCatalog.h:98

void XMLFileCatalog::registerFID | ( | CSTR | fid | ) | const
| override

Create a FileID and Node.

Definition at line 345 of file XMLFileCatalog.cpp.

346 {
347 if ( !fid.empty() ) {
348 std::pair<DOMElement*, DOMElement*> res = i_registerFID( fid );
349 if ( res.first == 0 || res.second == 0 ) {
350 printError( "Failed to register FID:" + fid );
351 }
352 return;
353 }
354 throw runtime_error( "XMLFileCatalog> Cannot register LFN for invalid FID:" + fid );
355 }
std::string::empty
T empty(T...args)
Gaudi::XMLFileCatalog::printError
void printError(CSTR msg, bool throw_exc=true) const
Definition: XMLFileCatalog.cpp:206
std::runtime_error
STL class.
std::pair
Gaudi::XMLFileCatalog::i_registerFID
std::pair< xercesc::DOMElement *, xercesc::DOMElement * > i_registerFID(CSTR fid) const
Definition: XMLFileCatalog.cpp:357

void XMLFileCatalog::registerLFN | ( | CSTR | fid,
|  | CSTR | lfn
| ) |  | const
| override

Create a FileID and Node of the logical file name with all the attributes.

Definition at line 425 of file XMLFileCatalog.cpp.

426 {
427 if ( !fid.empty() ) {
428 std::pair<DOMElement*, DOMElement*> res = i_registerFID( fid );
429 DOMElement *logelem = res.first, *fnelem = 0;
430 for ( XMLCollection c( logelem ); c; ++c ) {
431 char* nam = XMLString::transcode( c->getNodeName() );
432 if ( nam == LFNNODE ) {
433 XMLString::release( &nam );
434 nam = XMLString::transcode( c->getAttribute( Attr_name ) );
435 if ( nam == lfn ) {
436 XMLString::release( &nam );
437 fnelem = c;
438 break;
439 }
440 }
441 }
442 if ( !fnelem ) {
443 fnelem = getDoc( true )->createElement( LFNNODE );
444 logelem->appendChild( fnelem );
445 fnelem->setAttribute( Attr_name, XMLStr( lfn ) );
446 fnelem->setIdAttribute( Attr_name, true );
447 m_update = true;
448 }
449 return;
450 }
451 throw runtime_error( "XMLFileCatalog> Cannot register LFN for invalid FID:" + fid );
452 }
std::string::empty
T empty(T...args)
gaudirun.c
c
Definition: gaudirun.py:407
std::runtime_error
STL class.
Gaudi::XMLFileCatalog::getDoc
xercesc::DOMDocument * getDoc(bool throw_if_no_exists=true) const
Definition: XMLFileCatalog.cpp:200
std::pair
Gaudi::XMLFileCatalog::i_registerFID
std::pair< xercesc::DOMElement *, xercesc::DOMElement * > i_registerFID(CSTR fid) const
Definition: XMLFileCatalog.cpp:357
Gaudi::XMLFileCatalog::m_update
bool m_update
Definition: XMLFileCatalog.h:99

void XMLFileCatalog::registerPFN | ( | CSTR | fid,
|  | CSTR | pfn,
|  | CSTR | ftype
| ) |  | const
| override

Create a FileID and Node of the physical file name with all the attributes.

Definition at line 394 of file XMLFileCatalog.cpp.

395 {
396 if ( !fid.empty() ) {
397 std::pair<DOMElement*, DOMElement*> res = i_registerFID( fid );
398 DOMElement *phyelem = res.second, *fnelem = 0;
399 for ( XMLCollection c( phyelem ); c; ++c ) {
400 char* nam = XMLString::transcode( c->getNodeName() );
401 if ( nam == PFNNODE ) {
402 XMLString::release( &nam );
403 nam = XMLString::transcode( c->getAttribute( Attr_name ) );
404 if ( nam == pfn ) {
405 XMLString::release( &nam );
406 fnelem = c;
407 break;
408 }
409 }
410 XMLString::release( &nam );
411 }
412 if ( !fnelem ) {
413 fnelem = getDoc( true )->createElement( PFNNODE );
414 phyelem->appendChild( fnelem );
415 fnelem->setAttribute( Attr_ftype, XMLStr( ftype ) );
416 fnelem->setAttribute( Attr_name, XMLStr( pfn ) );
417 fnelem->setIdAttribute( Attr_name, true );
418 m_update = true;
419 }
420 return;
421 }
422 throw runtime_error( "XMLFileCatalog> Cannot register PFN for invalid FID:" + fid );
423 }
std::string::empty
T empty(T...args)
gaudirun.c
c
Definition: gaudirun.py:407
std::runtime_error
STL class.
Gaudi::XMLFileCatalog::getDoc
xercesc::DOMDocument * getDoc(bool throw_if_no_exists=true) const
Definition: XMLFileCatalog.cpp:200
std::pair
Gaudi::XMLFileCatalog::i_registerFID
std::pair< xercesc::DOMElement *, xercesc::DOMElement * > i_registerFID(CSTR fid) const
Definition: XMLFileCatalog.cpp:357
Gaudi::XMLFileCatalog::m_update
bool m_update
Definition: XMLFileCatalog.h:99

void Gaudi::XMLFileCatalog::rollback | ( |  | ) |
| inline override

Save DOM catalog to file.

Definition at line 47 of file XMLFileCatalog.h.

48 {
49 if ( dirty() ) init();
50 }
Gaudi::XMLFileCatalog::init
void init() override
Parse the DOM tree of the XML catalog.
Definition: XMLFileCatalog.cpp:215
Gaudi::XMLFileCatalog::dirty
bool dirty() const override
Check if the catalog should be updated.
Definition: XMLFileCatalog.h:54

void XMLFileCatalog::setMetaData | ( | CSTR | fid,
|  | CSTR | name,
|  | CSTR | value
| ) |  | const
| override

Insert/update metadata item.

Definition at line 299 of file XMLFileCatalog.cpp.

300 {
301 if ( !readOnly() ) {
302 DOMNode* node = element( fid );
303 DOMElement* mnod = (DOMElement*)child( node, MetaNode, Attr_metaName, attr );
304 if ( !mnod ) {
305 mnod = getDoc( true )->createElement( MetaNode );
306 node->appendChild( mnod );
307 mnod->setAttribute( Attr_metaName, XMLStr( attr ) );
308 }
309 mnod->setAttribute( Attr_metaValue, XMLStr( val ) );
310 m_update = true;
311 return;
312 }
313 printError( "Cannot update readonly catalog!" );
314 }
Gaudi::XMLFileCatalog::readOnly
bool readOnly() const override
Check if the catalog is read-only.
Definition: XMLFileCatalog.h:52
Gaudi::XMLFileCatalog::element
xercesc::DOMNode * element(CSTR fid, bool print_err=true) const
Definition: XMLFileCatalog.cpp:331
Gaudi::XMLFileCatalog::child
xercesc::DOMNode * child(xercesc::DOMNode *par, CSTR tag, CSTR attr="", CSTR val="") const
Definition: XMLFileCatalog.cpp:288
Gaudi::XMLFileCatalog::printError
void printError(CSTR msg, bool throw_exc=true) const
Definition: XMLFileCatalog.cpp:206
Gaudi::XMLFileCatalog::getDoc
xercesc::DOMDocument * getDoc(bool throw_if_no_exists=true) const
Definition: XMLFileCatalog.cpp:200
Gaudi::XMLFileCatalog::m_update
bool m_update
Definition: XMLFileCatalog.h:99

## Member Data Documentation

xercesc::DOMDocument* Gaudi::XMLFileCatalog::m_doc
| private

Definition at line 100 of file XMLFileCatalog.h.

std::unique_ptr<xercesc::ErrorHandler> Gaudi::XMLFileCatalog::m_errHdlr
| private

Definition at line 102 of file XMLFileCatalog.h.

std::string Gaudi::XMLFileCatalog::m_file
| private

Definition at line 103 of file XMLFileCatalog.h.

IMessageSvc* Gaudi::XMLFileCatalog::m_msgSvc
| private

Definition at line 104 of file XMLFileCatalog.h.

std::unique_ptr<xercesc::XercesDOMParser> Gaudi::XMLFileCatalog::m_parser
| private

Definition at line 101 of file XMLFileCatalog.h.

bool Gaudi::XMLFileCatalog::m_rdOnly
| private

Definition at line 98 of file XMLFileCatalog.h.

bool Gaudi::XMLFileCatalog::m_update
| mutable private

Definition at line 99 of file XMLFileCatalog.h.

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

- GaudiUtils/src/component/XMLFileCatalog.h
- GaudiUtils/src/component/XMLFileCatalog.cpp