Mantid
Loading...
Searching...
No Matches
CatalogInfo.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7//----------------------------------------------------------------------
8// Includes
9//----------------------------------------------------------------------
11
12#include <Poco/AutoPtr.h>
13#include <Poco/DOM/Element.h>
14#include <Poco/DOM/Node.h>
15#include <Poco/DOM/NodeList.h>
16#include <Poco/XML/XMLString.h>
17
18namespace Mantid::Kernel {
23CatalogInfo::CatalogInfo(const Poco::XML::Element *element) {
24 m_catalogName = getAttribute(element, "catalog", "name");
25 m_soapEndPoint = getAttribute(element, "soapendpoint", "url");
26 m_externalDownloadURL = getAttribute(element, "externaldownload", "url");
27 m_catalogPrefix = getAttribute(element, "prefix", "regex");
28 m_windowsPrefix = getAttribute(element, "windows", "replacement");
29 m_macPrefix = getAttribute(element, "mac", "replacement");
30 m_linuxPrefix = getAttribute(element, "linux", "replacement");
31}
32
34 : m_catalogName(other.m_catalogName), m_soapEndPoint(other.m_soapEndPoint),
35 m_externalDownloadURL(other.m_externalDownloadURL), m_catalogPrefix(other.m_catalogPrefix),
36 m_windowsPrefix(other.m_windowsPrefix), m_macPrefix(other.m_macPrefix), m_linuxPrefix(other.m_linuxPrefix) {}
37
41const std::string CatalogInfo::catalogName() const { return (m_catalogName); }
42
46const std::string CatalogInfo::soapEndPoint() const { return (m_soapEndPoint); }
47
51const std::string CatalogInfo::externalDownloadURL() const { return (m_externalDownloadURL); }
52
56const std::string CatalogInfo::catalogPrefix() const { return (m_catalogPrefix); }
57
61const std::string CatalogInfo::windowsPrefix() const { return (m_windowsPrefix); }
62
66const std::string CatalogInfo::macPrefix() const { return (m_macPrefix); }
67
71const std::string CatalogInfo::linuxPrefix() const { return (m_linuxPrefix); }
72
77CatalogInfo *CatalogInfo::clone() const { return new CatalogInfo(*this); }
78
86std::string CatalogInfo::getAttribute(const Poco::XML::Element *element, const std::string &tagName,
87 const std::string &attributeName) {
88 Poco::AutoPtr<Poco::XML::NodeList> elementTag = element->getElementsByTagName(tagName);
89
90 // If the tag exists in the XML file.
91 if (elementTag->length() == 1) {
92 auto *item = dynamic_cast<Poco::XML::Element *>(elementTag->item(0));
93
94 // If the item does exist, then we want to return it.
95 if (!item->getAttribute(attributeName).empty()) {
96 return (item->getAttribute(attributeName));
97 }
98 }
99 return ("");
100}
101
102} // namespace Mantid::Kernel
A class that holds information about catalogs.
Definition: CatalogInfo.h:31
const std::string windowsPrefix() const override
Obtain Windows prefix from the facility file.
Definition: CatalogInfo.cpp:61
std::string getAttribute(const Poco::XML::Element *element, const std::string &tagName, const std::string &attributeName)
Obtain the attribute from a given element tag and attribute name.
Definition: CatalogInfo.cpp:86
const std::string linuxPrefix() const override
Obtain Linux prefix from facility file.
Definition: CatalogInfo.cpp:71
CatalogInfo * clone() const override
Clone.
Definition: CatalogInfo.cpp:77
std::string m_externalDownloadURL
Definition: CatalogInfo.h:64
const std::string macPrefix() const override
Obtain Macintosh prefix from facility file.
Definition: CatalogInfo.cpp:66
const std::string soapEndPoint() const override
Obtain soap end point from the facility file.
Definition: CatalogInfo.cpp:46
const std::string catalogName() const override
Obtain catalog name from the facility file.
Definition: CatalogInfo.cpp:41
CatalogInfo(const Poco::XML::Element *element)
Constructor.
Definition: CatalogInfo.cpp:23
const std::string catalogPrefix() const override
Obtain the regex prefix from the facility file.
Definition: CatalogInfo.cpp:56
const std::string externalDownloadURL() const override
Obtain the external download URL.
Definition: CatalogInfo.cpp:51