The Gaudi Framework  v41r0 (bdbe7744)
Loading...
Searching...
No Matches
Gaudi::XMLFileCatalog Class Reference

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

#include </builds/gaudi/Gaudi/GaudiUtils/src/component/XMLFileCatalog.h>

Inheritance diagram for Gaudi::XMLFileCatalog:
Collaboration diagram for Gaudi::XMLFileCatalog:

Public Member Functions

 XMLFileCatalog (CSTR url, IMessageSvc *m)
 Create a catalog file, initialization of XercesC.
std::string createFID () const override
 Catalog interface.
CSTR connectInfo () const override
 Access to connect string.
void init () override
 Parse the DOM tree of the XML catalog.
void commit () override
 Save DOM catalog to file.
void rollback () override
 Save DOM catalog to file.
bool readOnly () const override
 Check if the catalog is read-only.
bool dirty () const override
 Check if the catalog should be updated.
bool existsPFN (CSTR pfn) const override
 Return the status of a physical file name.
std::string lookupPFN (CSTR fid) const override
 Lookup file identifier by physical file name.
bool existsLFN (CSTR lfn) const override
 Return the status of a logical file name.
std::string lookupLFN (CSTR lfn) const override
 Lookup file identifier by logical file name.
bool existsFID (CSTR fid) const override
 Return the status of a FileID.
void getPFN (CSTR fid, Files &files) const override
 Dump all physical file names of the catalog and their attributes associate to the FileID.
void getLFN (CSTR fid, Files &files) const override
 Dump all logical file names of the catalog associate to the FileID.
void getFID (Strings &fids) const override
 Dump all file Identifiers.
void deleteFID (CSTR FileID) const override
 Delete FileID Node from the catalog.
void registerPFN (CSTR fid, CSTR pfn, CSTR ftype) const override
 Create a FileID and Node of the physical file name with all the attributes.
void registerLFN (CSTR fid, CSTR lfn) const override
 Create a FileID and Node of the logical file name with all the attributes.
void registerFID (CSTR fid) const override
 Create a FileID and Node.
void renamePFN (CSTR pfn, CSTR new_pfn) const override
 rename a PFN
void deletePFN (CSTR pfn) const override
 remove a PFN
void getMetaData (CSTR fid, Attributes &attr) const override
 Dump all MetaData of the catalog for a given file ID.
std::string getMetaDataItem (CSTR fid, CSTR name) const override
 Access metadata item.
void setMetaData (CSTR fid, CSTR name, CSTR value) const override
 Insert/update metadata item.
void dropMetaData (CSTR fid) const override
 Drop all metadata of one FID.
void dropMetaData (CSTR fid, CSTR attr) const override
 Drop specified metadata item.
Public Member Functions inherited from implements< IFileCatalog >
void const * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast.
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface.
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames.
 implements ()=default
 Default constructor.
implements & operator= (const implements &)
 Assignment operator (do not touch the reference count).
unsigned long addRef () const override
 Reference Interface instance.
unsigned long release () const override
 Release Interface instance.
unsigned long refCount () const override
 Current reference count.

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 = false
bool m_update = false
xercesc::DOMDocument * m_doc = nullptr
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
 Typedef to this class.
using extend_interfaces_base
 Typedef to the base of this class.
using iids
Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids
 take union of the ext_iids of all Interfaces...
Protected Member Functions inherited from implements< IFileCatalog >
unsigned long decRef () const override
Protected Attributes inherited from implements< IFileCatalog >
std::atomic_ulong m_refCount
 Reference counter.

Detailed Description

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

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

Definition at line 36 of file XMLFileCatalog.h.

Member Typedef Documentation

◆ CSTR

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

Definition at line 38 of file XMLFileCatalog.h.

Constructor & Destructor Documentation

◆ XMLFileCatalog()

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

Create a catalog file, initialization of XercesC.

Definition at line 189 of file XMLFileCatalog.cpp.

189: m_file( uri ), m_msgSvc( m ) {}

Member Function Documentation

◆ child()

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

Definition at line 270 of file XMLFileCatalog.cpp.

270 {
271 for ( XMLCollection c( par ); c; ++c ) {
272 if ( c.tag() == tag ) {
273 if ( !attr.empty() && c.attr( attr ) != val ) continue;
274 return c;
275 }
276 }
277 return 0;
278}

◆ commit()

void XMLFileCatalog::commit ( )
override

Save DOM catalog to file.

Definition at line 449 of file XMLFileCatalog.cpp.

449 {
450 try {
451 if ( dirty() && !readOnly() ) {
452 string xmlfile = getfile( true );
453 XMLStr ii( "LS" );
454 DOMImplementation* imp = DOMImplementationRegistry::getDOMImplementation( ii );
455 auto tar = std::make_unique<LocalFileFormatTarget>( xmlfile.c_str() );
456#if _XERCES_VERSION <= 30000
457 DOMWriter* wr = imp->createDOMWriter();
458 wr->setFeature( XMLUni::fgDOMWRTFormatPrettyPrint, true );
459 wr->writeNode( tar.get(), *m_doc );
460 wr->release();
461#else
462 DOMLSOutput* output = imp->createLSOutput();
463 output->setByteStream( tar.get() );
464 DOMLSSerializer* wr = imp->createLSSerializer();
465 wr->getDomConfig()->setParameter( XMLStr( "format-pretty-print" ), true );
466 wr->write( m_doc, output );
467 output->release();
468 wr->release();
469#endif
470 }
471 } catch ( exception& e ) { printError( string( "Cannot open output file:" ) + e.what() ); } catch ( ... ) {
472 printError( "Unknown IO rrror." );
473 }
474}
std::string getfile(bool create)
void printError(CSTR msg, bool throw_exc=true) const
xercesc::DOMDocument * m_doc
bool dirty() const override
Check if the catalog should be updated.
bool readOnly() const override
Check if the catalog is read-only.

◆ connectInfo()

CSTR Gaudi::XMLFileCatalog::connectInfo ( ) const
inlineoverride

Access to connect string.

Definition at line 48 of file XMLFileCatalog.h.

48{ return m_file; }

◆ createFID()

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

Catalog interface.

Create file identifier using UUID mechanism.

Create file identifier using UUID mechanism

Definition at line 192 of file XMLFileCatalog.cpp.

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

◆ deleteFID()

void XMLFileCatalog::deleteFID ( CSTR FileID) const
override

Delete FileID Node from the catalog.

Definition at line 315 of file XMLFileCatalog.cpp.

315 {
316 DOMNode *pn = nullptr, *fn = element( fid );
317 if ( fn ) pn = fn->getParentNode();
318 if ( pn ) pn->removeChild( fn );
319}
xercesc::DOMNode * element(CSTR fid, bool print_err=true) const

◆ deletePFN()

void XMLFileCatalog::deletePFN ( CSTR pfn) const
override

remove a PFN

Definition at line 338 of file XMLFileCatalog.cpp.

338 {
339 DOMNode* node = getDoc( true )->getElementById( XMLStr( pfn ) );
340 if ( node ) {
341 DOMNode* pcoll_node = node->getParentNode();
342 pcoll_node->removeChild( node );
343 m_update = true;
344 for ( XMLCollection pcoll( pcoll_node, true ); pcoll; ++pcoll ) {
345 return; // there are other PFN entries left, so we are done
346 }
347 // delete empty file entry
348 DOMNode* file_node = pcoll_node->getParentNode();
349 file_node->getParentNode()->removeChild( file_node );
350 }
351}
xercesc::DOMDocument * getDoc(bool throw_if_no_exists=true) const

◆ dirty()

bool Gaudi::XMLFileCatalog::dirty ( ) const
inlineoverride

Check if the catalog should be updated.

Definition at line 60 of file XMLFileCatalog.h.

60{ return m_update; }

◆ dropMetaData() [1/2]

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

Drop all metadata of one FID.

Definition at line 96 of file XMLFileCatalog.h.

96{ dropMetaData( fid, "*" ); }
void dropMetaData(CSTR fid) const override
Drop all metadata of one FID.

◆ dropMetaData() [2/2]

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

Drop specified metadata item.

Definition at line 301 of file XMLFileCatalog.cpp.

301 {
302 vector<DOMNode*> gbc;
303 DOMNode* fn = getDoc( true )->getElementById( XMLStr( fid ) );
304 for ( XMLCollection c{ child( fn, MetaNode ) }; c; ++c )
305 if ( attr[0] == '*' || !c.attr( attr ).empty() ) gbc.push_back( c );
306 for ( const auto& i : gbc ) fn->removeChild( i );
307}
xercesc::DOMNode * child(xercesc::DOMNode *par, CSTR tag, CSTR attr="", CSTR val="") const

◆ element()

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

Definition at line 309 of file XMLFileCatalog.cpp.

309 {
310 DOMNode* node = getDoc( true )->getElementById( XMLStr( element_name ) );
311 if ( !node && print_err ) printError( "Cannot find element:" + element_name );
312 return node;
313}

◆ existsFID()

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

Return the status of a FileID.

Definition at line 70 of file XMLFileCatalog.h.

70{ return element( fid, false ) != 0; }

◆ existsLFN()

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

Return the status of a logical file name.

Definition at line 66 of file XMLFileCatalog.h.

66{ return element( lfn, false ) != 0; }

◆ existsPFN()

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

Return the status of a physical file name.

Definition at line 62 of file XMLFileCatalog.h.

62{ return element( pfn, false ) != 0; }

◆ getDoc()

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

Definition at line 194 of file XMLFileCatalog.cpp.

194 {
195 if ( !m_doc && throw_if_no_exists ) printError( "The XML catalog was not started.", true );
196 return m_doc;
197}

◆ getFID()

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

Dump all file Identifiers.

Definition at line 245 of file XMLFileCatalog.cpp.

245 {
246 fids.clear();
247 DOMNode* fde = getDoc( true )->getElementsByTagName( XMLStr( "*" ) )->item( 0 );
248 for ( XMLCollection c( child( fde, "File" ), false ); c; ++c ) fids.push_back( c.attr( Attr_ID ) );
249}

◆ getfile()

string XMLFileCatalog::getfile ( bool create)
private

Definition at line 476 of file XMLFileCatalog.cpp.

476 {
477 string protocol, path;
478 XMLURL xerurl;
479 try {
480 xerurl = (const XMLCh*)XMLStr( m_file );
481 protocol = _toString( xerurl.getProtocolName() );
482 path = _toString( xerurl.getPath() );
483 } catch ( const XMLException& e ) { printError( _toString( e.getMessage() ) ); }
484 if ( protocol.empty() ) {
485 printError( "Missing protocol." );
486 } else if ( protocol == "http" || protocol == "ftp" ) {
487 m_rdOnly = true;
488 } else if ( protocol == "file" ) {
489 m_rdOnly = false;
490 struct stat buff;
491 int exist = ::stat( path.c_str(), &buff ) != -1;
492 if ( create && !exist ) {
493 MsgStream log( m_msgSvc, "XMLCatalog" );
494 log << MSG::INFO << "File '" << path << "' does not exist. New file created." << endmsg;
495 ofstream out{ path };
496 if ( !m_rdOnly && out.is_open() ) {
497 out << (CSTR)EmptyCatalog << endl;
498 } else {
499 printError( "Problem creating file " + path );
500 }
501 out.close();
502 } else if ( exist ) {
503 return path;
504 } else if ( !create ) {
505 return "";
506 }
507 } else {
508 printError( protocol + ": protocol not supported." );
509 }
510 return path;
511}
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
const std::string & CSTR
GAUDI_API std::string path(const AIDA::IBaseHistogram *aida)
get the path in THS for AIDA histogram
@ INFO
Definition IMessageSvc.h:22

◆ getLFN()

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

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

Definition at line 257 of file XMLFileCatalog.cpp.

257 {
258 files.clear();
259 for ( XMLCollection c( child( child( element( fid, false ), LFNCOLL ), LFNNODE ), false ); c; ++c )
260 files.emplace_back( c.attr( Attr_name ), fid );
261}

◆ getMetaData()

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

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

Definition at line 263 of file XMLFileCatalog.cpp.

263 {
264 attr.clear();
265 for ( XMLCollection c( child( element( fid ), MetaNode ), false ); c; ++c )
266 attr.emplace_back( c.attr( Attr_metaName ), c.attr( Attr_metaValue ) );
267 if ( attr.size() > 0 ) attr.emplace_back( "guid", fid );
268}

◆ getMetaDataItem()

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

Access metadata item.

Definition at line 296 of file XMLFileCatalog.cpp.

296 {
297 XMLCollection c( child( getDoc( true )->getElementById( XMLStr( fid ) ), MetaNode, Attr_metaName, attr ) );
298 return c ? c.attr( attr ) : string( "" );
299}

◆ getPFN()

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 251 of file XMLFileCatalog.cpp.

251 {
252 files.clear();
253 for ( XMLCollection c( child( child( element( fid, false ), PFNCOLL ), PFNNODE ), false ); c; ++c )
254 files.emplace_back( c.attr( Attr_name ), c.attr( Attr_ftype ) );
255}

◆ i_registerFID()

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 353 of file XMLFileCatalog.cpp.

353 {
354 if ( readOnly() ) {
355 printError( "Cannot update readonly catalog!" );
356 return { nullptr, nullptr };
357 }
358
360 DOMElement * file = (DOMElement*)element( fid, false ), *phyelem = 0, *logelem = 0;
361 DOMDocument* doc = getDoc( true );
362 if ( !file ) {
363 DOMNode* fde = doc->getElementsByTagName( XMLStr( "*" ) )->item( 0 );
364 file = m_doc->createElement( XMLStr( "File" ) );
365 file->setAttribute( Attr_ID, XMLStr( fid ) );
366 file->setIdAttribute( Attr_ID, true );
367 fde->appendChild( file );
368 m_update = true;
369 }
370 for ( XMLCollection c1( file ); c1; ++c1 ) {
371 char* nam = XMLString::transcode( c1->getNodeName() );
372 if ( nam == PFNCOLL ) phyelem = c1;
373 if ( nam == LFNCOLL ) logelem = c1;
374 XMLString::release( &nam );
375 }
376 if ( !phyelem ) {
377 phyelem = doc->createElement( PFNCOLL );
378 file->appendChild( phyelem );
379 m_update = true;
380 }
381 if ( !logelem ) {
382 logelem = doc->createElement( LFNCOLL );
383 file->appendChild( logelem );
384 m_update = true;
385 }
386 return { logelem, phyelem };
387}

◆ init()

void XMLFileCatalog::init ( )
override

Parse the DOM tree of the XML catalog.

Definition at line 205 of file XMLFileCatalog.cpp.

205 {
206 string xmlFile = getfile( false );
207 try {
208 m_parser = std::make_unique<XercesDOMParser>();
209 m_parser->setValidationScheme( XercesDOMParser::Val_Auto );
210 m_parser->setDoNamespaces( false );
211 DTDRedirect dtdinmem;
212 m_parser->setEntityResolver( &dtdinmem );
213 if ( !m_errHdlr ) m_errHdlr = std::make_unique<ErrHandler>( m_msgSvc );
214 m_parser->setErrorHandler( m_errHdlr.get() );
215 if ( !xmlFile.empty() ) {
216 m_parser->parse( xmlFile.c_str() );
217 } else {
218 const std::string& s = EmptyCatalog;
219 MemBufInputSource src( reinterpret_cast<const XMLByte*>( s.c_str() ), s.length(), "MemCatalog" );
220 m_parser->parse( src );
221 }
222 m_doc = m_parser->getDocument();
223 } catch ( const XMLException& e ) {
224 printError( "XML parse error[" + xmlFile + "]: " + _toString( e.getMessage() ) );
225 } catch ( const DOMException& e ) {
226 printError( "XML parse error[" + xmlFile + "]: " + _toString( e.getMessage() ) );
227 } catch ( ... ) { printError( "UNKNOWN XML parse error in file " + xmlFile ); }
228}
std::unique_ptr< xercesc::ErrorHandler > m_errHdlr
std::unique_ptr< xercesc::XercesDOMParser > m_parser

◆ lookupFID()

string XMLFileCatalog::lookupFID ( CSTR lfn) const
private

Definition at line 230 of file XMLFileCatalog.cpp.

230 {
231 std::string result;
232 DOMNode* e = element( fid, false );
233 e = e ? e->getParentNode() : 0; // Mode up to <logical>
234 e = e ? e->getParentNode() : 0; // Mode up to <File>
235 if ( e ) {
236 if ( e->getAttributes() ) { // Need to check this. The node may be no DOMElement
237 char* nam = XMLString::transcode( ( dynamic_cast<DOMElement*>( e ) )->getAttribute( Attr_ID ) );
238 if ( nam ) result = nam;
239 XMLString::release( &nam );
240 }
241 }
242 return result;
243}

◆ lookupLFN()

std::string Gaudi::XMLFileCatalog::lookupLFN ( CSTR lfn) const
inlineoverride

Lookup file identifier by logical file name.

Definition at line 68 of file XMLFileCatalog.h.

68{ return lookupFID( lfn ); }
std::string lookupFID(CSTR lfn) const

◆ lookupPFN()

std::string Gaudi::XMLFileCatalog::lookupPFN ( CSTR fid) const
inlineoverride

Lookup file identifier by physical file name.

Definition at line 64 of file XMLFileCatalog.h.

64{ return lookupFID( fid ); }

◆ printError()

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

Definition at line 199 of file XMLFileCatalog.cpp.

199 {
200 MsgStream log( m_msgSvc, "XMLCatalog" );
201 log << MSG::FATAL << msg << endmsg;
202 if ( rethrow ) throw runtime_error( "XMLFileCatalog> " + msg );
203}
@ FATAL
Definition IMessageSvc.h:22

◆ readOnly()

bool Gaudi::XMLFileCatalog::readOnly ( ) const
inlineoverride

Check if the catalog is read-only.

Definition at line 58 of file XMLFileCatalog.h.

58{ return m_rdOnly; }

◆ registerFID()

void XMLFileCatalog::registerFID ( CSTR fid) const
override

Create a FileID and Node.

Definition at line 321 of file XMLFileCatalog.cpp.

321 {
322 if ( !fid.empty() ) {
323 std::pair<DOMElement*, DOMElement*> res = i_registerFID( fid );
324 if ( res.first == 0 || res.second == 0 ) { printError( "Failed to register FID:" + fid ); }
325 return;
326 }
327 throw runtime_error( "XMLFileCatalog> Cannot register LFN for invalid FID:" + fid );
328}
std::pair< xercesc::DOMElement *, xercesc::DOMElement * > i_registerFID(CSTR fid) const

◆ registerLFN()

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 419 of file XMLFileCatalog.cpp.

419 {
420 if ( !fid.empty() ) {
421 std::pair<DOMElement*, DOMElement*> res = i_registerFID( fid );
422 DOMElement * logelem = res.first, *fnelem = 0;
423 for ( XMLCollection c( logelem ); c; ++c ) {
424 char* nam = XMLString::transcode( c->getNodeName() );
425 if ( nam == LFNNODE ) {
426 XMLString::release( &nam );
427 nam = XMLString::transcode( c->getAttribute( Attr_name ) );
428 if ( nam == lfn ) {
429 XMLString::release( &nam );
430 fnelem = c;
431 break;
432 } else {
433 XMLString::release( &nam );
434 }
435 }
436 }
437 if ( !fnelem ) {
438 fnelem = getDoc( true )->createElement( LFNNODE );
439 logelem->appendChild( fnelem );
440 fnelem->setAttribute( Attr_name, XMLStr( lfn ) );
441 fnelem->setIdAttribute( Attr_name, true );
442 m_update = true;
443 }
444 return;
445 }
446 throw runtime_error( "XMLFileCatalog> Cannot register LFN for invalid FID:" + fid );
447}

◆ registerPFN()

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 389 of file XMLFileCatalog.cpp.

389 {
390 if ( !fid.empty() ) {
391 std::pair<DOMElement*, DOMElement*> res = i_registerFID( fid );
392 DOMElement * phyelem = res.second, *fnelem = 0;
393 for ( XMLCollection c( phyelem ); c; ++c ) {
394 char* nam = XMLString::transcode( c->getNodeName() );
395 if ( nam == PFNNODE ) {
396 XMLString::release( &nam );
397 nam = XMLString::transcode( c->getAttribute( Attr_name ) );
398 if ( nam == pfn ) {
399 XMLString::release( &nam );
400 fnelem = c;
401 break;
402 }
403 }
404 XMLString::release( &nam );
405 }
406 if ( !fnelem ) {
407 fnelem = getDoc( true )->createElement( PFNNODE );
408 phyelem->appendChild( fnelem );
409 fnelem->setAttribute( Attr_ftype, XMLStr( ftype ) );
410 fnelem->setAttribute( Attr_name, XMLStr( pfn ) );
411 fnelem->setIdAttribute( Attr_name, true );
412 m_update = true;
413 }
414 return;
415 }
416 throw runtime_error( "XMLFileCatalog> Cannot register PFN for invalid FID:" + fid );
417}

◆ renamePFN()

void XMLFileCatalog::renamePFN ( CSTR pfn,
CSTR new_pfn ) const
override

rename a PFN

Definition at line 330 of file XMLFileCatalog.cpp.

330 {
331 DOMNode* node = getDoc( true )->getElementById( XMLStr( pfn ) );
332 if ( node && node->getNodeType() == DOMNode::ELEMENT_NODE ) {
333 ( dynamic_cast<DOMElement*>( node ) )->setAttribute( Attr_name, XMLStr( new_pfn ) );
334 m_update = true;
335 }
336}

◆ rollback()

void Gaudi::XMLFileCatalog::rollback ( )
inlineoverride

Save DOM catalog to file.

Definition at line 54 of file XMLFileCatalog.h.

54 {
55 if ( dirty() ) init();
56 }
void init() override
Parse the DOM tree of the XML catalog.

◆ setMetaData()

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

Insert/update metadata item.

Definition at line 280 of file XMLFileCatalog.cpp.

280 {
281 if ( !readOnly() ) {
282 DOMNode* node = element( fid );
283 DOMElement* mnod = (DOMElement*)child( node, MetaNode, Attr_metaName, attr );
284 if ( !mnod ) {
285 mnod = getDoc( true )->createElement( MetaNode );
286 node->appendChild( mnod );
287 mnod->setAttribute( Attr_metaName, XMLStr( attr ) );
288 }
289 mnod->setAttribute( Attr_metaValue, XMLStr( val ) );
290 m_update = true;
291 return;
292 }
293 printError( "Cannot update readonly catalog!" );
294}

Member Data Documentation

◆ m_doc

xercesc::DOMDocument* Gaudi::XMLFileCatalog::m_doc = nullptr
private

Definition at line 110 of file XMLFileCatalog.h.

◆ m_errHdlr

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

Definition at line 112 of file XMLFileCatalog.h.

◆ m_file

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

Definition at line 113 of file XMLFileCatalog.h.

◆ m_msgSvc

IMessageSvc* Gaudi::XMLFileCatalog::m_msgSvc
private

Definition at line 114 of file XMLFileCatalog.h.

◆ m_parser

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

Definition at line 111 of file XMLFileCatalog.h.

◆ m_rdOnly

bool Gaudi::XMLFileCatalog::m_rdOnly = false
private

Definition at line 108 of file XMLFileCatalog.h.

◆ m_update

bool Gaudi::XMLFileCatalog::m_update = false
mutableprivate

Definition at line 109 of file XMLFileCatalog.h.


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