-
Notifications
You must be signed in to change notification settings - Fork 122
/
ImplicitFunctionParameterParserFactory.cpp
57 lines (52 loc) · 2.04 KB
/
ImplicitFunctionParameterParserFactory.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <Poco/DOM/DOMParser.h>
#include <Poco/DOM/Document.h>
#include <Poco/DOM/Element.h>
#include <Poco/DOM/NodeList.h>
#include <Poco/DOM/NodeIterator.h>
#include <Poco/DOM/NodeFilter.h>
#include <Poco/File.h>
#include <Poco/Path.h>
#include "MantidAPI/ImplicitFunctionParameterParserFactory.h"
namespace Mantid
{
namespace API
{
ImplicitFunctionParameterParserFactoryImpl::ImplicitFunctionParameterParserFactoryImpl()
{
}
ImplicitFunctionParameterParserFactoryImpl::~ImplicitFunctionParameterParserFactoryImpl()
{
}
boost::shared_ptr<ImplicitFunctionParameterParser> ImplicitFunctionParameterParserFactoryImpl::create(const std::string& xmlString) const
{
UNUSED_ARG(xmlString);
throw std::runtime_error("Use of create in this context is forbidden. Use createUnwrappedInstead.");
}
ImplicitFunctionParameterParser* ImplicitFunctionParameterParserFactoryImpl::createImplicitFunctionParameterParserFromXML(Poco::XML::Element* parametersElement) const
{
if(parametersElement->localName() != "ParameterList")
{
throw std::runtime_error("Expected passed element to be ParameterList.");
}
Poco::AutoPtr<Poco::XML::NodeList> parameters = parametersElement->getElementsByTagName("Parameter");
ImplicitFunctionParameterParser* paramParser = NULL;
ImplicitFunctionParameterParser* nextParser = NULL;
for(unsigned long i = 0 ; i < parameters->length(); i++)
{
Poco::XML::Element* parameter = dynamic_cast<Poco::XML::Element*>(parameters->item(i));
std::string paramParserName = parameter->getChildElement("Type")->innerText() + "Parser"; //Append parser to the name. Fixed convention
ImplicitFunctionParameterParser* childParamParser = this->createUnwrapped(paramParserName);
if(paramParser != NULL)
{
nextParser->setSuccessorParser(childParamParser);
}
else
{
paramParser = childParamParser;
}
nextParser = childParamParser;
}
return paramParser;
}
}
}