Mantid
Loading...
Searching...
No Matches
CoordTransformDistanceParser.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 +
11
12namespace Mantid::DataObjects {
15
16//-----------------------------------------------------------------------------------------------
17/*
18Create the transform object.
19@param coordTransElement : xml coordinate transform element
20@return a fully constructed coordinate transform object.
21*/
23CoordTransformDistanceParser::createTransform(Poco::XML::Element *coordTransElement) const {
24 // Typdef the parameter parsers required.
29
30 using namespace Poco::XML;
31 if ("CoordTransform" != coordTransElement->localName()) {
32 std::string message = "This is not a coordinate transform element: " + coordTransElement->localName();
33 throw std::invalid_argument(message);
34 }
35 if ("CoordTransformDistance" != coordTransElement->getChildElement("Type")->innerText()) {
36 // Delegate
37 if (!m_successor) {
38 throw std::runtime_error("CoordTransformDistanceParser has no successor parser.");
39 }
40 return m_successor->createTransform(coordTransElement);
41 }
42
43 Element *paramListElement = coordTransElement->getChildElement("ParameterList");
44 Poco::AutoPtr<Poco::XML::NodeList> parameters = paramListElement->getElementsByTagName("Parameter");
45
46 // Parse the in dimension parameter.
47 InDimParameterParser inDimParamParser;
48 auto *parameter = dynamic_cast<Poco::XML::Element *>(parameters->item(0));
49 std::shared_ptr<Mantid::API::InDimParameter> inDimParameter(inDimParamParser.createWithoutDelegation(parameter));
50
51 // Parse the out dimension parameter.
52 OutDimParameterParser outDimParamParser;
53 parameter = dynamic_cast<Poco::XML::Element *>(parameters->item(1));
54 std::shared_ptr<Mantid::API::OutDimParameter> outDimParameter(outDimParamParser.createWithoutDelegation(parameter));
55 UNUSED_ARG(outDimParameter); // not actually used as an input.
56
57 // Parse the coordinate centre parameter.
58 CoordCenterParser coordCenterParser;
59 parameter = dynamic_cast<Poco::XML::Element *>(parameters->item(2));
60 std::shared_ptr<Mantid::DataObjects::CoordCenterVectorParam> coordCenterParam(
61 coordCenterParser.createWithoutDelegation(parameter));
62
63 // Parse the dimensions used parameter.
64 DimsUsedParser dimsUsedParser;
65 parameter = dynamic_cast<Poco::XML::Element *>(parameters->item(3));
66 std::shared_ptr<Mantid::DataObjects::DimensionsUsedVectorParam> dimsUsedVecParm(
67 dimsUsedParser.createWithoutDelegation(parameter));
68
70 auto transform = new CoordTransformDistance(inDimParameter->getValue(), coordCenterParam->getPointerToStart(),
71 dimsUsedVecParm->getPointerToStart());
72
73 return transform;
74}
75} // namespace Mantid::DataObjects
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
Definition: System.h:64
Unique SingleValueParameter Declaration for InputNDimensions.
XML Parser for single value parameter types.
XML parser for vector value (n elements) parameter types.
Mantid::API::CoordTransform * createTransform(Poco::XML::Element *coordTransElement) const override
Create the transform object.
Unique CoordCenterVectorParam type declaration for ndimensional coordinate centers.