Mantid
Loading...
Searching...
No Matches
ImplicitFunctionParameterParserFactory.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 +
8
9#include <Poco/DOM/Element.h>
10#include <Poco/DOM/NodeList.h>
11
12namespace Mantid::API {
13
14std::shared_ptr<ImplicitFunctionParameterParser>
15ImplicitFunctionParameterParserFactoryImpl::create(const std::string &xmlString) const {
16 UNUSED_ARG(xmlString);
17 throw std::runtime_error("Use of create in this context is forbidden. Use "
18 "createUnwrappedInstead.");
19}
20
23 Poco::XML::Element *parametersElement) const {
24 if (parametersElement->localName() != "ParameterList") {
25 throw std::runtime_error("Expected passed element to be ParameterList.");
26 }
27 Poco::AutoPtr<Poco::XML::NodeList> parameters = parametersElement->getElementsByTagName("Parameter");
28 ImplicitFunctionParameterParser *paramParser = nullptr;
29 ImplicitFunctionParameterParser *nextParser = nullptr;
30 for (unsigned long i = 0; i < parameters->length(); i++) {
31 auto *parameter = dynamic_cast<Poco::XML::Element *>(parameters->item(i));
32 std::string paramParserName =
33 parameter->getChildElement("Type")->innerText() + "Parser"; // Append parser to the name. Fixed convention
34 ImplicitFunctionParameterParser *childParamParser = this->createUnwrapped(paramParserName);
35 if (paramParser != nullptr) {
36 nextParser->setSuccessorParser(childParamParser);
37 } else {
38 paramParser = childParamParser;
39 }
40 nextParser = childParamParser;
41 }
42 return paramParser;
43}
44} // namespace Mantid::API
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
Definition: System.h:64
ImplicitFunctionParameterParser * createImplicitFunctionParameterParserFromXML(Poco::XML::Element *parametersElement) const
std::shared_ptr< ImplicitFunctionParameterParser > create(const std::string &xmlString) const override
Creates a new instance of the class with the given name.
virtual void setSuccessorParser(ImplicitFunctionParameterParser *paramParser)=0
virtual ImplicitFunctionParameterParser * createUnwrapped(const std::string &className) const
Creates a new instance of the class with the given name, which is not wrapped in a boost shared_ptr.