| The Gaudi Framework v28r2p1 (f1a77ff4)

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

187 : m_rdOnly(false),m_update(false),m_doc(0),
188 m_file(uri), m_msgSvc(m)
189 {
190 }
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

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

284 {
285 for(XMLCollection c(par); c; ++c ) {
286 if( c.tag() == tag ) {
287 if( !attr.empty() && c.attr(attr) != val) continue;
288 return c;
289 }
290 }
291 return 0;
292 }
std::string::empty
T empty(T...args)
gaudirun.c
c
Definition: gaudirun.py:391
compareOutputFiles.par
string par
Definition: compareOutputFiles.py:386

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

Save DOM catalog to file.

Definition at line 441 of file XMLFileCatalog.cpp.

441 {
442 try {
443 if ( dirty() && !readOnly() ) {
444 string xmlfile = getfile(true);
445 XMLStr ii("LS");
446 DOMImplementation *imp = DOMImplementationRegistry::getDOMImplementation(ii);
447 std::unique_ptr<XMLFormatTarget> tar{ new LocalFileFormatTarget(xmlfile.c_str()) };
448 #if _XERCES_VERSION <= 30000
449 DOMWriter *wr = imp->createDOMWriter();
450 wr->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
451 wr->writeNode(tar.get(), *m_doc);
452 wr->release();
453 #else
454 DOMLSOutput *output = imp->createLSOutput();
455 output->setByteStream(tar.get());
456 DOMLSSerializer *wr = imp->createLSSerializer();
457 wr->getDomConfig()->setParameter(XMLStr("format-pretty-print"), true);
458 wr->write(m_doc, output);
459 output->release();
460 wr->release();
461 #endif
462 }
463 }
464 catch ( exception& e ) {
465 printError(string("Cannot open output file:")+e.what());
466 }
467 catch (...) {
468 printError("Unknown IO rrror.");
469 }
470 }
Gaudi::XMLFileCatalog::readOnly
bool readOnly() const override
Check if the catalog is read-only.
Definition: XMLFileCatalog.h:47
gaudirun.output
output
Definition: gaudirun.py:388
Gaudi::XMLFileCatalog::getfile
std::string getfile(bool create)
Definition: XMLFileCatalog.cpp:472
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:203
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)
Gaudi::XMLFileCatalog::dirty
bool dirty() const override
Check if the catalog should be updated.
Definition: XMLFileCatalog.h:49

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

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
| override

Catalog interface.

Create file identifier using UUID mechanism.

Create file identifier using UUID mechanism

Definition at line 193 of file XMLFileCatalog.cpp.

193 {
194 return createGuidAsString();
195 }
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 330 of file XMLFileCatalog.cpp.

330 {
331 DOMNode *pn = nullptr, *fn = element(fid);
332 if ( fn ) pn = fn->getParentNode();
333 if ( pn ) pn->removeChild(fn);
334 }
Gaudi::XMLFileCatalog::element
xercesc::DOMNode * element(CSTR fid, bool print_err=true) const
Definition: XMLFileCatalog.cpp:324

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

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

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

Drop all metadata of one FID.

Definition at line 81 of file XMLFileCatalog.h.

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

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

Drop specified metadata item.

Definition at line 315 of file XMLFileCatalog.cpp.

315 {
316 vector<DOMNode*> gbc;
317 DOMNode* fn = getDoc(true)->getElementById(XMLStr(fid));
318 for(XMLCollection c{child(fn,MetaNode)}; c; ++c)
319 if ( attr[0]=='*' || !c.attr(attr).empty() ) gbc.push_back(c);
320 for(const auto &i : gbc)
321 fn->removeChild(i);
322 }
gaudirun.c
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:284
Gaudi::XMLFileCatalog::getDoc
xercesc::DOMDocument * getDoc(bool throw_if_no_exists=true) const
Definition: XMLFileCatalog.cpp:197
std::vector
STL class.

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

Definition at line 324 of file XMLFileCatalog.cpp.

324 {
325 DOMNode* node = getDoc(true)->getElementById(XMLStr(element_name));
326 if ( !node && print_err ) printError("Cannot find element:"+element_name);
327 return node;
328 }
Gaudi::XMLFileCatalog::printError
void printError(CSTR msg, bool throw_exc=true) const
Definition: XMLFileCatalog.cpp:203
Gaudi::XMLFileCatalog::getDoc
xercesc::DOMDocument * getDoc(bool throw_if_no_exists=true) const
Definition: XMLFileCatalog.cpp:197

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

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:324

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

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:324

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

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:324

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

Definition at line 197 of file XMLFileCatalog.cpp.

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

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

Dump all file Identifiers.

Definition at line 257 of file XMLFileCatalog.cpp.

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

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

Definition at line 472 of file XMLFileCatalog.cpp.

472 {
473 string protocol, path;
474 XMLURL xerurl;
475 try{
476 xerurl = (const XMLCh*)XMLStr(m_file);
477 protocol = _toString(xerurl.getProtocolName());
478 path = _toString(xerurl.getPath());
479 }
480 catch (const XMLException& e ) {
481 printError(_toString(e.getMessage()));
482 }
483 if ( protocol.empty() ) {
484 printError("Missing protocol.");
485 }
486 else if ( protocol == "http" || protocol == "ftp" ) {
487 m_rdOnly = true;
488 }
489 else if ( protocol == "file" ) {
490 m_rdOnly = false;
491 struct stat buff;
492 int exist = ::stat(path.c_str(),&buff) != -1;
493 if ( create && !exist ) {
494 MsgStream log(m_msgSvc,"XMLCatalog");
495 log << MSG::INFO << "File '" << path << "' does not exist. New file created." << endmsg;
496 ofstream out{path};
497 if( !m_rdOnly && out.is_open() ) {
498 out << (CSTR)EmptyCatalog << endl;
499 }
500 else {
501 printError("Problem creating file "+path);
502 }
503 out.close();
504 }
505 else if ( exist ) {
506 return path;
507 }
508 else if ( !create ) {
509 return "";
510 }
511 }
512 else {
513 printError(protocol + ": protocol not supported.");
514 }
515 return path;
516 }
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)
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:772
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:203
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
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 270 of file XMLFileCatalog.cpp.

270 {
271 files.clear();
272 for(XMLCollection c(child(child(element(fid,false),LFNCOLL),LFNNODE), false); c; ++c)
273 files.emplace_back(c.attr(Attr_name),fid);
274 }
gaudirun.c
c
Definition: gaudirun.py:391
Gaudi::XMLFileCatalog::element
xercesc::DOMNode * element(CSTR fid, bool print_err=true) const
Definition: XMLFileCatalog.cpp:324
Gaudi::XMLFileCatalog::child
xercesc::DOMNode * child(xercesc::DOMNode *par, CSTR tag, CSTR attr="", CSTR val="") const
Definition: XMLFileCatalog.cpp:284

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

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

Definition at line 276 of file XMLFileCatalog.cpp.

276 {
277 attr.clear();
278 for(XMLCollection c(child(element(fid),MetaNode), false); c; ++c)
279 attr.emplace_back(c.attr(Attr_metaName),c.attr(Attr_metaValue));
280 if ( attr.size() > 0 )
281 attr.emplace_back("guid",fid);
282 }
gaudirun.c
c
Definition: gaudirun.py:391
Gaudi::XMLFileCatalog::element
xercesc::DOMNode * element(CSTR fid, bool print_err=true) const
Definition: XMLFileCatalog.cpp:324
Gaudi::XMLFileCatalog::child
xercesc::DOMNode * child(xercesc::DOMNode *par, CSTR tag, CSTR attr="", CSTR val="") const
Definition: XMLFileCatalog.cpp:284

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

Access metadata item.

Definition at line 310 of file XMLFileCatalog.cpp.

310 {
311 XMLCollection c(child(getDoc(true)->getElementById(XMLStr(fid)),MetaNode,Attr_metaName,attr));
312 return c ? c.attr(attr) : string("");
313 }
gaudirun.c
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:284
Gaudi::XMLFileCatalog::getDoc
xercesc::DOMDocument * getDoc(bool throw_if_no_exists=true) const
Definition: XMLFileCatalog.cpp:197

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

264 {
265 files.clear();
266 for(XMLCollection c(child(child(element(fid,false),PFNCOLL),PFNNODE), false); c; ++c)
267 files.emplace_back(c.attr(Attr_name),c.attr(Attr_ftype));
268 }
gaudirun.c
c
Definition: gaudirun.py:391
Gaudi::XMLFileCatalog::element
xercesc::DOMNode * element(CSTR fid, bool print_err=true) const
Definition: XMLFileCatalog.cpp:324
Gaudi::XMLFileCatalog::child
xercesc::DOMNode * child(xercesc::DOMNode *par, CSTR tag, CSTR attr="", CSTR val="") const
Definition: XMLFileCatalog.cpp:284

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

347 {
348 if ( readOnly() ) {
349 printError("Cannot update readonly catalog!");
350 return { nullptr, nullptr};
351 }
352
354 DOMElement *file = (DOMElement*)element(fid,false), *phyelem = 0, *logelem = 0;
355 DOMDocument* doc = getDoc(true);
356 if ( !file ) {
357 DOMNode* fde = doc->getElementsByTagName(XMLStr("*"))->item(0);
358 file = m_doc->createElement(XMLStr("File"));
359 file->setAttribute(Attr_ID, XMLStr(fid));
360 file->setIdAttribute(Attr_ID, true);
361 fde->appendChild(file);
362 m_update = true;
363 }
364 for(XMLCollection c1(file); c1; ++c1 ) {
365 char* nam = XMLString::transcode(c1->getNodeName());
366 if ( nam == PFNCOLL ) phyelem = c1;
367 if ( nam == LFNCOLL ) logelem = c1;
368 XMLString::release(&nam);
369 }
370 if ( !phyelem ) {
371 phyelem = doc->createElement(PFNCOLL);
372 file->appendChild(phyelem);
373 m_update = true;
374 }
375 if ( !logelem ) {
376 logelem = doc->createElement(LFNCOLL);
377 file->appendChild(logelem);
378 m_update = true;
379 }
380 return {logelem,phyelem};
381 }
Gaudi::XMLFileCatalog::readOnly
bool readOnly() const override
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:324
Gaudi::XMLFileCatalog::printError
void printError(CSTR msg, bool throw_exc=true) const
Definition: XMLFileCatalog.cpp:203
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:197
Gaudi::XMLFileCatalog::m_update
bool m_update
Definition: XMLFileCatalog.h:93
HiveAlgSequencer.c1
c1
Definition: HiveAlgSequencer.py:25

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

Parse the DOM tree of the XML catalog.

Definition at line 211 of file XMLFileCatalog.cpp.

211 {
212 string xmlFile = getfile(false);
213 try{
214 m_parser.reset( new XercesDOMParser );
215 m_parser->setValidationScheme(XercesDOMParser::Val_Auto);
216 m_parser->setDoNamespaces(false);
217 DTDRedirect dtdinmem;
218 m_parser->setEntityResolver(&dtdinmem);
219 if ( ! m_errHdlr ) m_errHdlr.reset( new ErrHandler(m_msgSvc) );
220 m_parser->setErrorHandler(m_errHdlr.get());
221 if ( !xmlFile.empty() ) {
222 m_parser->parse(xmlFile.c_str());
223 }
224 else {
225 const std::string& s = EmptyCatalog;
226 MemBufInputSource src((const XMLByte*)s.c_str(),s.length(),"MemCatalog");
227 m_parser->parse(src);
228 }
229 m_doc = m_parser->getDocument();
230 }
231 catch (const XMLException& e) {
232 printError("XML parse error["+xmlFile+"]: "+_toString(e.getMessage()));
233 }
234 catch (const DOMException& e) {
235 printError("XML parse error["+xmlFile+"]: "+_toString(e.getMessage()));
236 }
237 catch (...) {
238 printError("UNKNOWN XML parse error in file "+xmlFile);
239 }
240 }
std::string::empty
T empty(T...args)
Gaudi::XMLFileCatalog::getfile
std::string getfile(bool create)
Definition: XMLFileCatalog.cpp:472
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:203
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 242 of file XMLFileCatalog.cpp.

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

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

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:242

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

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:242

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

Definition at line 203 of file XMLFileCatalog.cpp.

203 {
204 MsgStream log(m_msgSvc,"XMLCatalog");
205 log << MSG::FATAL << msg << endmsg;
206 if ( rethrow ) {
207 throw runtime_error("XMLFileCatalog> "+msg);
208 }
209 }
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
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
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 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
| override

Create a FileID and Node.

Definition at line 336 of file XMLFileCatalog.cpp.

336 {
337 if ( !fid.empty() ) {
338 std::pair<DOMElement*, DOMElement*> res = i_registerFID(fid);
339 if ( res.first == 0 || res.second == 0 ) {
340 printError("Failed to register FID:"+fid);
341 }
342 return;
343 }
344 throw runtime_error("XMLFileCatalog> Cannot register LFN for invalid FID:"+fid);
345 }
std::string::empty
T empty(T...args)
Gaudi::XMLFileCatalog::printError
void printError(CSTR msg, bool throw_exc=true) const
Definition: XMLFileCatalog.cpp:203
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:347

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

413 {
414 if ( !fid.empty() ) {
415 std::pair<DOMElement*, DOMElement*> res = i_registerFID(fid);
416 DOMElement* logelem = res.first, *fnelem = 0;
417 for(XMLCollection c(logelem); c; ++c ) {
418 char* nam = XMLString::transcode(c->getNodeName());
419 if ( nam == LFNNODE ) {
420 XMLString::release(&nam);
421 nam = XMLString::transcode(c->getAttribute(Attr_name));
422 if ( nam == lfn ) {
423 XMLString::release(&nam);
424 fnelem = c;
425 break;
426 }
427 }
428 }
429 if ( !fnelem ) {
430 fnelem = getDoc(true)->createElement(LFNNODE);
431 logelem->appendChild(fnelem);
432 fnelem->setAttribute(Attr_name,XMLStr(lfn));
433 fnelem->setIdAttribute(Attr_name, true);
434 m_update = true;
435 }
436 return;
437 }
438 throw runtime_error("XMLFileCatalog> Cannot register LFN for invalid FID:"+fid);
439 }
std::string::empty
T empty(T...args)
gaudirun.c
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:197
std::pair
Gaudi::XMLFileCatalog::i_registerFID
std::pair< xercesc::DOMElement *, xercesc::DOMElement * > i_registerFID(CSTR fid) const
Definition: XMLFileCatalog.cpp:347
Gaudi::XMLFileCatalog::m_update
bool m_update
Definition: XMLFileCatalog.h:93

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

383 {
384 if ( !fid.empty() ) {
385 std::pair<DOMElement*,DOMElement*> res = i_registerFID(fid);
386 DOMElement* phyelem = res.second, *fnelem = 0;
387 for(XMLCollection c(phyelem); c; ++c ) {
388 char* nam = XMLString::transcode(c->getNodeName());
389 if ( nam == PFNNODE ) {
390 XMLString::release(&nam);
391 nam = XMLString::transcode(c->getAttribute(Attr_name));
392 if ( nam == pfn ) {
393 XMLString::release(&nam);
394 fnelem = c;
395 break;
396 }
397 }
398 XMLString::release(&nam);
399 }
400 if ( !fnelem ) {
401 fnelem = getDoc(true)->createElement(PFNNODE);
402 phyelem->appendChild(fnelem);
403 fnelem->setAttribute(Attr_ftype,XMLStr(ftype));
404 fnelem->setAttribute(Attr_name,XMLStr(pfn));
405 fnelem->setIdAttribute(Attr_name, true);
406 m_update = true;
407 }
408 return;
409 }
410 throw runtime_error("XMLFileCatalog> Cannot register PFN for invalid FID:"+fid);
411 }
std::string::empty
T empty(T...args)
gaudirun.c
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:197
std::pair
Gaudi::XMLFileCatalog::i_registerFID
std::pair< xercesc::DOMElement *, xercesc::DOMElement * > i_registerFID(CSTR fid) const
Definition: XMLFileCatalog.cpp:347
Gaudi::XMLFileCatalog::m_update
bool m_update
Definition: XMLFileCatalog.h:93

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

Save DOM catalog to file.

Definition at line 45 of file XMLFileCatalog.h.

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

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

Insert/update metadata item.

Definition at line 294 of file XMLFileCatalog.cpp.

294 {
295 if ( !readOnly() ) {
296 DOMNode* node = element(fid);
297 DOMElement* mnod = (DOMElement*)child(node,MetaNode,Attr_metaName,attr);
298 if (!mnod){
299 mnod = getDoc(true)->createElement(MetaNode);
300 node->appendChild(mnod);
301 mnod->setAttribute(Attr_metaName,XMLStr(attr));
302 }
303 mnod->setAttribute(Attr_metaValue,XMLStr(val));
304 m_update = true;
305 return;
306 }
307 printError("Cannot update readonly catalog!");
308 }
Gaudi::XMLFileCatalog::readOnly
bool readOnly() const override
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:324
Gaudi::XMLFileCatalog::child
xercesc::DOMNode * child(xercesc::DOMNode *par, CSTR tag, CSTR attr="", CSTR val="") const
Definition: XMLFileCatalog.cpp:284
Gaudi::XMLFileCatalog::printError
void printError(CSTR msg, bool throw_exc=true) const
Definition: XMLFileCatalog.cpp:203
Gaudi::XMLFileCatalog::getDoc
xercesc::DOMDocument * getDoc(bool throw_if_no_exists=true) const
Definition: XMLFileCatalog.cpp:197
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