| The Gaudi Framework v27r1

- 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...
virtual | ~XMLFileCatalog ()=default
| Destructor,. More...
virtual std::string | createFID () const
| Catalog interface. More...
virtual CSTR | connectInfo () const
| Access to connect string. More...
virtual void | init ()
| Parse the DOM tree of the XML catalog. More...
virtual void | commit ()
| Save DOM catalog to file. More...
virtual void | rollback ()
| Save DOM catalog to file. More...
virtual bool | readOnly () const
| Check if the catalog is read-only. More...
virtual bool | dirty () const
| Check if the catalog should be updated. More...
virtual bool | existsPFN (CSTR pfn) const
| Return the status of a physical file name. More...
virtual std::string | lookupPFN (CSTR fid) const
| Lookup file identifier by physical file name. More...
virtual bool | existsLFN (CSTR lfn) const
| Return the status of a logical file name. More...
virtual std::string | lookupLFN (CSTR lfn) const
| Lookup file identifier by logical file name. More...
virtual bool | existsFID (CSTR fid) const
| Return the status of a FileID. More...
virtual void | getPFN (CSTR fid, Files &files) const
| Dump all physical file names of the catalog and their attributes associate to the FileID. More...
virtual void | getLFN (CSTR fid, Files &files) const
| Dump all logical file names of the catalog associate to the FileID. More...
virtual void | getFID (Strings &fids) const
| Dump all file Identifiers. More...
virtual void | deleteFID (CSTR FileID) const
| Delete FileID Node from the catalog. More...
virtual void | registerPFN (CSTR fid, CSTR pfn, CSTR ftype) const
| Create a FileID and Node of the physical file name with all the attributes. More...
virtual void | registerLFN (CSTR fid, CSTR lfn) const
| Create a FileID and Node of the logical file name with all the attributes. More...
virtual void | registerFID (CSTR fid) const
| Create a FileID and Node. More...
virtual void | getMetaData (CSTR fid, Attributes &attr) const
| Dump all MetaData of the catalog for a given file ID. More...
virtual std::string | getMetaDataItem (CSTR fid, CSTR name) const
| Access metadata item. More...
virtual void | setMetaData (CSTR fid, CSTR name, CSTR value) const
| Insert/update metadata item. More...
virtual void | dropMetaData (CSTR fid) const
| Drop all metadata of one FID. More...
virtual void | dropMetaData (CSTR fid, CSTR attr) const
| 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 25 of file XMLFileCatalog.h.

## Member Typedef Documentation

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

Definition at line 27 of file XMLFileCatalog.h.

## Constructor & Destructor Documentation

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

Create a catalog file, initialization of XercesC.

Definition at line 205 of file XMLFileCatalog.cpp.

206 : m_rdOnly(false),m_update(false),m_doc(0),
207 m_file(uri), m_msgSvc(m)
208 {
209 }
Gaudi::XMLFileCatalog::m_file
std::string m_file
Definition: XMLFileCatalog.h:97
Gaudi::XMLFileCatalog::m_doc
xercesc::DOMDocument * m_doc
Definition: XMLFileCatalog.h:94
Gaudi::XMLFileCatalog::m_rdOnly
bool m_rdOnly
Definition: XMLFileCatalog.h:92
Gaudi::XMLFileCatalog::m_msgSvc
IMessageSvc * m_msgSvc
Definition: XMLFileCatalog.h:98
Gaudi::XMLFileCatalog::m_update
bool m_update
Definition: XMLFileCatalog.h:93

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

Destructor,.

## Member Function Documentation

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

Definition at line 303 of file XMLFileCatalog.cpp.

303 {
304 for(XMLCollection c(par); c; ++c ) {
305 if( c.tag() == tag ) {
306 if( !attr.empty() && c.attr(attr) != val) continue;
307 return c;
308 }
309 }
310 return 0;
311 }
std::string::empty
T empty(T...args)
gaudirun.c
tuple c
Definition: gaudirun.py:391
compareOutputFiles.par
string par
Definition: compareOutputFiles.py:386

void XMLFileCatalog::commit | ( |  | ) |
| virtual

Save DOM catalog to file.

Definition at line 460 of file XMLFileCatalog.cpp.

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

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

Access to connect string.

Definition at line 39 of file XMLFileCatalog.h.

39 { return m_file; }
Gaudi::XMLFileCatalog::m_file
std::string m_file
Definition: XMLFileCatalog.h:97

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

Catalog interface.

Create file identifier using UUID mechanism.

Create file identifier using UUID mechanism

Definition at line 212 of file XMLFileCatalog.cpp.

212 {
213 return createGuidAsString();
214 }
Gaudi::createGuidAsString
std::string createGuidAsString()
Create file identifier using UUID mechanism.
Definition: XMLFileCatalog.cpp:188

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

Delete FileID Node from the catalog.

Definition at line 349 of file XMLFileCatalog.cpp.

349 {
350 DOMNode *pn = nullptr, *fn = element(fid);
351 if ( fn ) pn = fn->getParentNode();
352 if ( pn ) pn->removeChild(fn);
353 }
Gaudi::XMLFileCatalog::element
xercesc::DOMNode * element(CSTR fid, bool print_err=true) const
Definition: XMLFileCatalog.cpp:343

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

Check if the catalog should be updated.

Definition at line 49 of file XMLFileCatalog.h.

49 { return m_update; }
Gaudi::XMLFileCatalog::m_update
bool m_update
Definition: XMLFileCatalog.h:93

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

Drop all metadata of one FID.

Definition at line 81 of file XMLFileCatalog.h.

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

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

Drop specified metadata item.

Definition at line 334 of file XMLFileCatalog.cpp.

334 {
335 vector<DOMNode*> gbc;
336 DOMNode* fn = getDoc(true)->getElementById(XMLStr(fid));
337 for(XMLCollection c{child(fn,MetaNode)}; c; ++c)
338 if ( attr[0]=='*' || !c.attr(attr).empty() ) gbc.push_back(c);
339 for(const auto &i : gbc)
340 fn->removeChild(i);
341 }
gaudirun.c
tuple c
Definition: gaudirun.py:391
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:303
Gaudi::XMLFileCatalog::getDoc
xercesc::DOMDocument * getDoc(bool throw_if_no_exists=true) const
Definition: XMLFileCatalog.cpp:216
std::vector
STL class.
ana.i
list i
Definition: ana.py:128

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

Definition at line 343 of file XMLFileCatalog.cpp.

343 {
344 DOMNode* node = getDoc(true)->getElementById(XMLStr(element_name));
345 if ( !node && print_err ) printError("Cannot find element:"+element_name);
346 return node;
347 }
Gaudi::XMLFileCatalog::printError
void printError(CSTR msg, bool throw_exc=true) const
Definition: XMLFileCatalog.cpp:222
Gaudi::XMLFileCatalog::getDoc
xercesc::DOMDocument * getDoc(bool throw_if_no_exists=true) const
Definition: XMLFileCatalog.cpp:216

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

Return the status of a FileID.

Definition at line 59 of file XMLFileCatalog.h.

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

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

Return the status of a logical file name.

Definition at line 55 of file XMLFileCatalog.h.

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

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

Return the status of a physical file name.

Definition at line 51 of file XMLFileCatalog.h.

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

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

Definition at line 216 of file XMLFileCatalog.cpp.

216 {
217 if ( !m_doc && throw_if_no_exists )
218 printError("The XML catalog was not started.",true);
219 return m_doc;
220 }
Gaudi::XMLFileCatalog::printError
void printError(CSTR msg, bool throw_exc=true) const
Definition: XMLFileCatalog.cpp:222
Gaudi::XMLFileCatalog::m_doc
xercesc::DOMDocument * m_doc
Definition: XMLFileCatalog.h:94

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

Dump all file Identifiers.

Definition at line 276 of file XMLFileCatalog.cpp.

276 {
277 fids.clear();
278 DOMNode* fde = getDoc(true)->getElementsByTagName(XMLStr("*"))->item(0);
279 for(XMLCollection c(child(fde,"File"), false); c; ++c)
280 fids.push_back(c.attr(Attr_ID));
281 }
gaudirun.c
tuple c
Definition: gaudirun.py:391
Gaudi::XMLFileCatalog::child
xercesc::DOMNode * child(xercesc::DOMNode *par, CSTR tag, CSTR attr="", CSTR val="") const
Definition: XMLFileCatalog.cpp:303
Gaudi::XMLFileCatalog::getDoc
xercesc::DOMDocument * getDoc(bool throw_if_no_exists=true) const
Definition: XMLFileCatalog.cpp:216

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

Definition at line 491 of file XMLFileCatalog.cpp.

491 {
492 string protocol, path;
493 XMLURL xerurl;
494 try{
495 xerurl = (const XMLCh*)XMLStr(m_file);
496 protocol = _toString(xerurl.getProtocolName());
497 path = _toString(xerurl.getPath());
498 }
499 catch (const XMLException& e ) {
500 printError(_toString(e.getMessage()));
501 }
502 if ( protocol.empty() ) {
503 printError("Missing protocol.");
504 }
505 else if ( protocol == "http" || protocol == "ftp" ) {
506 m_rdOnly = true;
507 }
508 else if ( protocol == "file" ) {
509 m_rdOnly = false;
510 struct stat buff;
511 int exist = ::stat(path.c_str(),&buff) != -1;
512 if ( create && !exist ) {
513 MsgStream log(m_msgSvc,"XMLCatalog");
514 log << MSG::INFO << "File '" << path << "' does not exist. New file created." << endmsg;
515 ofstream out{path};
516 if( !m_rdOnly && out.is_open() ) {
517 out << (CSTR)EmptyCatalog << endl;
518 }
519 else {
520 printError("Problem creating file "+path);
521 }
522 out.close();
523 }
524 else if ( exist ) {
525 return path;
526 }
527 else if ( !create ) {
528 return "";
529 }
530 }
531 else {
532 printError(protocol + ": protocol not supported.");
533 }
534 return path;
535 }
Gaudi::XMLFileCatalog::m_file
std::string m_file
Definition: XMLFileCatalog.h:97
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
std::string::empty
T empty(T...args)
Gaudi.Configuration.log
tuple log
Definition: Configuration.py:13
std::ofstream
STL class.
Gaudi::XMLFileCatalog::CSTR
const std::string & CSTR
Definition: XMLFileCatalog.h:27
Gaudi::XMLFileCatalog::printError
void printError(CSTR msg, bool throw_exc=true) const
Definition: XMLFileCatalog.cpp:222
Gaudi::Utils::Histos::path
GAUDI_API std::string path(const AIDA::IBaseHistogram *aida)
get the path in THS for AIDA histogram
Definition: HistoTableFormat.cpp:191
Gaudi::XMLFileCatalog::m_rdOnly
bool m_rdOnly
Definition: XMLFileCatalog.h:92
Gaudi::XMLFileCatalog::m_msgSvc
IMessageSvc * m_msgSvc
Definition: XMLFileCatalog.h:98
MSG::INFO
Definition: IMessageSvc.h:19
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

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

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

Definition at line 289 of file XMLFileCatalog.cpp.

289 {
290 files.clear();
291 for(XMLCollection c(child(child(element(fid,false),LFNCOLL),LFNNODE), false); c; ++c)
292 files.emplace_back(c.attr(Attr_name),fid);
293 }
gaudirun.c
tuple c
Definition: gaudirun.py:391
Gaudi::XMLFileCatalog::element
xercesc::DOMNode * element(CSTR fid, bool print_err=true) const
Definition: XMLFileCatalog.cpp:343
Gaudi::XMLFileCatalog::child
xercesc::DOMNode * child(xercesc::DOMNode *par, CSTR tag, CSTR attr="", CSTR val="") const
Definition: XMLFileCatalog.cpp:303

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

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

Definition at line 295 of file XMLFileCatalog.cpp.

295 {
296 attr.clear();
297 for(XMLCollection c(child(element(fid),MetaNode), false); c; ++c)
298 attr.emplace_back(c.attr(Attr_metaName),c.attr(Attr_metaValue));
299 if ( attr.size() > 0 )
300 attr.emplace_back("guid",fid);
301 }
gaudirun.c
tuple c
Definition: gaudirun.py:391
Gaudi::XMLFileCatalog::element
xercesc::DOMNode * element(CSTR fid, bool print_err=true) const
Definition: XMLFileCatalog.cpp:343
Gaudi::XMLFileCatalog::child
xercesc::DOMNode * child(xercesc::DOMNode *par, CSTR tag, CSTR attr="", CSTR val="") const
Definition: XMLFileCatalog.cpp:303

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

Access metadata item.

Definition at line 329 of file XMLFileCatalog.cpp.

329 {
330 XMLCollection c(child(getDoc(true)->getElementById(XMLStr(fid)),MetaNode,Attr_metaName,attr));
331 return c ? c.attr(attr) : string("");
332 }
gaudirun.c
tuple c
Definition: gaudirun.py:391
std::string
STL class.
Gaudi::XMLFileCatalog::child
xercesc::DOMNode * child(xercesc::DOMNode *par, CSTR tag, CSTR attr="", CSTR val="") const
Definition: XMLFileCatalog.cpp:303
Gaudi::XMLFileCatalog::getDoc
xercesc::DOMDocument * getDoc(bool throw_if_no_exists=true) const
Definition: XMLFileCatalog.cpp:216

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

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

Definition at line 283 of file XMLFileCatalog.cpp.

283 {
284 files.clear();
285 for(XMLCollection c(child(child(element(fid,false),PFNCOLL),PFNNODE), false); c; ++c)
286 files.emplace_back(c.attr(Attr_name),c.attr(Attr_ftype));
287 }
gaudirun.c
tuple c
Definition: gaudirun.py:391
Gaudi::XMLFileCatalog::element
xercesc::DOMNode * element(CSTR fid, bool print_err=true) const
Definition: XMLFileCatalog.cpp:343
Gaudi::XMLFileCatalog::child
xercesc::DOMNode * child(xercesc::DOMNode *par, CSTR tag, CSTR attr="", CSTR val="") const
Definition: XMLFileCatalog.cpp:303

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

366 {
367 if ( readOnly() ) {
368 printError("Cannot update readonly catalog!");
369 return { nullptr, nullptr};
370 }
371
373 DOMElement *file = (DOMElement*)element(fid,false), *phyelem = 0, *logelem = 0;
374 DOMDocument* doc = getDoc(true);
375 if ( !file ) {
376 DOMNode* fde = doc->getElementsByTagName(XMLStr("*"))->item(0);
377 file = m_doc->createElement(XMLStr("File"));
378 file->setAttribute(Attr_ID, XMLStr(fid));
379 file->setIdAttribute(Attr_ID, true);
380 fde->appendChild(file);
381 m_update = true;
382 }
383 for(XMLCollection c1(file); c1; ++c1 ) {
384 char* nam = XMLString::transcode(c1->getNodeName());
385 if ( nam == PFNCOLL ) phyelem = c1;
386 if ( nam == LFNCOLL ) logelem = c1;
387 XMLString::release(&nam);
388 }
389 if ( !phyelem ) {
390 phyelem = doc->createElement(PFNCOLL);
391 file->appendChild(phyelem);
392 m_update = true;
393 }
394 if ( !logelem ) {
395 logelem = doc->createElement(LFNCOLL);
396 file->appendChild(logelem);
397 m_update = true;
398 }
399 return {logelem,phyelem};
400 }
Gaudi::XMLFileCatalog::readOnly
virtual bool readOnly() const
Check if the catalog is read-only.
Definition: XMLFileCatalog.h:47
Gaudi::XMLFileCatalog::element
xercesc::DOMNode * element(CSTR fid, bool print_err=true) const
Definition: XMLFileCatalog.cpp:343
Gaudi::XMLFileCatalog::printError
void printError(CSTR msg, bool throw_exc=true) const
Definition: XMLFileCatalog.cpp:222
Gaudi::XMLFileCatalog::m_doc
xercesc::DOMDocument * m_doc
Definition: XMLFileCatalog.h:94
Gaudi::XMLFileCatalog::getDoc
xercesc::DOMDocument * getDoc(bool throw_if_no_exists=true) const
Definition: XMLFileCatalog.cpp:216
ana.file
list file
Definition: ana.py:160
HiveAlgSequencer.c1
tuple c1
Definition: HiveAlgSequencer.py:25
Gaudi::XMLFileCatalog::m_update
bool m_update
Definition: XMLFileCatalog.h:93

void XMLFileCatalog::init | ( |  | ) |
| virtual

Parse the DOM tree of the XML catalog.

Definition at line 230 of file XMLFileCatalog.cpp.

230 {
231 string xmlFile = getfile(false);
232 try{
233 m_parser.reset( new XercesDOMParser );
234 m_parser->setValidationScheme(XercesDOMParser::Val_Auto);
235 m_parser->setDoNamespaces(false);
236 DTDRedirect dtdinmem;
237 m_parser->setEntityResolver(&dtdinmem);
238 if ( ! m_errHdlr ) m_errHdlr.reset( new ErrHandler(m_msgSvc) );
239 m_parser->setErrorHandler(m_errHdlr.get());
240 if ( !xmlFile.empty() ) {
241 m_parser->parse(xmlFile.c_str());
242 }
243 else {
244 const std::string& s = EmptyCatalog;
245 MemBufInputSource src((const XMLByte*)s.c_str(),s.length(),"MemCatalog");
246 m_parser->parse(src);
247 }
248 m_doc = m_parser->getDocument();
249 }
250 catch (const XMLException& e) {
251 printError("XML parse error["+xmlFile+"]: "+_toString(e.getMessage()));
252 }
253 catch (const DOMException& e) {
254 printError("XML parse error["+xmlFile+"]: "+_toString(e.getMessage()));
255 }
256 catch (...) {
257 printError("UNKNOWN XML parse error in file "+xmlFile);
258 }
259 }
std::string::empty
T empty(T...args)
Gaudi::XMLFileCatalog::getfile
std::string getfile(bool create)
Definition: XMLFileCatalog.cpp:491
Gaudi::XMLFileCatalog::m_parser
std::unique_ptr< xercesc::XercesDOMParser > m_parser
Definition: XMLFileCatalog.h:95
std::string
STL class.
Gaudi::XMLFileCatalog::printError
void printError(CSTR msg, bool throw_exc=true) const
Definition: XMLFileCatalog.cpp:222
Gaudi::XMLFileCatalog::m_errHdlr
std::unique_ptr< xercesc::ErrorHandler > m_errHdlr
Definition: XMLFileCatalog.h:96
Gaudi::XMLFileCatalog::m_doc
xercesc::DOMDocument * m_doc
Definition: XMLFileCatalog.h:94
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:245
Gaudi::XMLFileCatalog::m_msgSvc
IMessageSvc * m_msgSvc
Definition: XMLFileCatalog.h:98

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

Definition at line 261 of file XMLFileCatalog.cpp.

261 {
262 std::string result;
263 DOMNode* e = element(fid,false);
264 e = e ? e->getParentNode() : 0; // Mode up to <logical>
265 e = e ? e->getParentNode() : 0; // Mode up to <File>
266 if ( e ) {
267 if ( e->getAttributes() ) { // Need to check this. The node may be no DOMElement
268 char* nam = XMLString::transcode(((DOMElement*)e)->getAttribute(Attr_ID));
269 if ( nam ) result = nam;
270 XMLString::release(&nam);
271 }
272 }
273 return result;
274 }
Gaudi::XMLFileCatalog::element
xercesc::DOMNode * element(CSTR fid, bool print_err=true) const
Definition: XMLFileCatalog.cpp:343
std::string
STL class.

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

Lookup file identifier by logical file name.

Definition at line 57 of file XMLFileCatalog.h.

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

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

Lookup file identifier by physical file name.

Definition at line 53 of file XMLFileCatalog.h.

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

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

Definition at line 222 of file XMLFileCatalog.cpp.

222 {
223 MsgStream log(m_msgSvc,"XMLCatalog");
224 log << MSG::FATAL << msg << endmsg;
225 if ( rethrow ) {
226 throw runtime_error("XMLFileCatalog> "+msg);
227 }
228 }
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
Gaudi.Configuration.log
tuple log
Definition: Configuration.py:13
MSG::FATAL
Definition: IMessageSvc.h:22
std::runtime_error
STL class.
Gaudi::XMLFileCatalog::m_msgSvc
IMessageSvc * m_msgSvc
Definition: XMLFileCatalog.h:98
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

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

Check if the catalog is read-only.

Definition at line 47 of file XMLFileCatalog.h.

47 { return m_rdOnly; }
Gaudi::XMLFileCatalog::m_rdOnly
bool m_rdOnly
Definition: XMLFileCatalog.h:92

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

Create a FileID and Node.

Definition at line 355 of file XMLFileCatalog.cpp.

355 {
356 if ( !fid.empty() ) {
357 std::pair<DOMElement*, DOMElement*> res = i_registerFID(fid);
358 if ( res.first == 0 || res.second == 0 ) {
359 printError("Failed to register FID:"+fid);
360 }
361 return;
362 }
363 throw runtime_error("XMLFileCatalog> Cannot register LFN for invalid FID:"+fid);
364 }
std::string::empty
T empty(T...args)
Gaudi::XMLFileCatalog::printError
void printError(CSTR msg, bool throw_exc=true) const
Definition: XMLFileCatalog.cpp:222
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:366

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

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

Definition at line 432 of file XMLFileCatalog.cpp.

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

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

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

Definition at line 402 of file XMLFileCatalog.cpp.

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

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

Save DOM catalog to file.

Definition at line 45 of file XMLFileCatalog.h.

45 { if ( dirty() ) init(); }
Gaudi::XMLFileCatalog::init
virtual void init()
Parse the DOM tree of the XML catalog.
Definition: XMLFileCatalog.cpp:230
Gaudi::XMLFileCatalog::dirty
virtual bool dirty() const
Check if the catalog should be updated.
Definition: XMLFileCatalog.h:49

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

Insert/update metadata item.

Definition at line 313 of file XMLFileCatalog.cpp.

313 {
314 if ( !readOnly() ) {
315 DOMNode* node = element(fid);
316 DOMElement* mnod = (DOMElement*)child(node,MetaNode,Attr_metaName,attr);
317 if (!mnod){
318 mnod = getDoc(true)->createElement(MetaNode);
319 node->appendChild(mnod);
320 mnod->setAttribute(Attr_metaName,XMLStr(attr));
321 }
322 mnod->setAttribute(Attr_metaValue,XMLStr(val));
323 m_update = true;
324 return;
325 }
326 printError("Cannot update readonly catalog!");
327 }
Gaudi::XMLFileCatalog::readOnly
virtual bool readOnly() const
Check if the catalog is read-only.
Definition: XMLFileCatalog.h:47
Gaudi::XMLFileCatalog::element
xercesc::DOMNode * element(CSTR fid, bool print_err=true) const
Definition: XMLFileCatalog.cpp:343
Gaudi::XMLFileCatalog::child
xercesc::DOMNode * child(xercesc::DOMNode *par, CSTR tag, CSTR attr="", CSTR val="") const
Definition: XMLFileCatalog.cpp:303
Gaudi::XMLFileCatalog::printError
void printError(CSTR msg, bool throw_exc=true) const
Definition: XMLFileCatalog.cpp:222
Gaudi::XMLFileCatalog::getDoc
xercesc::DOMDocument * getDoc(bool throw_if_no_exists=true) const
Definition: XMLFileCatalog.cpp:216
Gaudi::XMLFileCatalog::m_update
bool m_update
Definition: XMLFileCatalog.h:93

## Member Data Documentation

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

Definition at line 94 of file XMLFileCatalog.h.

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

Definition at line 96 of file XMLFileCatalog.h.

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

Definition at line 97 of file XMLFileCatalog.h.

IMessageSvc* Gaudi::XMLFileCatalog::m_msgSvc
| private

Definition at line 98 of file XMLFileCatalog.h.

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

Definition at line 95 of file XMLFileCatalog.h.

bool Gaudi::XMLFileCatalog::m_rdOnly
| private

Definition at line 92 of file XMLFileCatalog.h.

bool Gaudi::XMLFileCatalog::m_update
| mutable private

Definition at line 93 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