Mantid
Loading...
Searching...
No Matches
MDGeometryXMLBuilder.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 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#pragma once
8
9#include "MantidGeometry/DllConfig.h"
11#include <algorithm>
12#include <string>
13#include <vector>
14
15namespace Mantid {
16namespace Geometry {
17
30template <typename CheckDimensionPolicy> class MANTID_GEOMETRY_DLL MDGeometryBuilderXML {
31
32public:
35
38
40 bool addOrdinaryDimension(IMDDimension_const_sptr dimensionToAdd) const;
41
43 void addManyOrdinaryDimensions(const VecIMDDimension_sptr &manyDims) const;
44
46 bool addXDimension(const IMDDimension_const_sptr &dimension) const;
47
49 bool addYDimension(const IMDDimension_const_sptr &dimension) const;
50
52 bool addZDimension(const IMDDimension_const_sptr &dimension) const;
53
55 bool addTDimension(const IMDDimension_const_sptr &dimension) const;
56
59
62
64 const std::string &create() const;
65
67 bool hasXDimension() const;
68
70 bool hasYDimension() const;
71
73 bool hasZDimension() const;
74
76 bool hasTDimension() const;
77
79 bool hasIntegratedTDimension() const;
80
81private:
82 using DimensionContainerType = std::vector<IMDDimension_const_sptr>;
83
85
87
89
91
93
95 void applyPolicyChecking(const IMDDimension &dimensionToAdd) const;
96
99 mutable bool m_changed;
100
102 mutable std::string m_lastResult;
103};
104
105/*
106 @class StrictDimensionPolicy
107 @brief Unary operator that throws if the dimension provided is integrated.
108 @author Owen Arnold
109 @date May 2011
110 @version 1.0
111*/
112struct MANTID_GEOMETRY_DLL StrictDimensionPolicy {
113public:
115 void operator()(const IMDDimension &item) {
116 if (true == item.getIsIntegrated()) {
117 std::string message = "StrictDimensionPolicy bans the use of integrated "
118 "IMDDimensions mapped to x, y, z or t in a "
119 "IMDWorkspace."
120 "Attempted to do so with IMDDimension: " +
121 item.getDimensionId();
122 throw std::invalid_argument(message);
123 }
124 }
125};
126
127/*
128 @class NoDimensionPolicy
129 @brief Unary operator that has no effect.
130 @author Owen Arnold
131 @date May 2011
132*/
133struct MANTID_GEOMETRY_DLL NoDimensionPolicy {
134 void operator()(const IMDDimension &) {
135 // Do nothing.
136 }
137};
138} // namespace Geometry
139} // namespace Mantid
The class describes one dimension of multidimensional dataset representing an orthogonal dimension an...
Definition: IMDDimension.h:39
virtual bool getIsIntegrated() const
Definition: IMDDimension.h:91
virtual const std::string & getDimensionId() const =0
short name which identify the dimension among other dimension.
std::string m_lastResult
Variable suports lazy calculation.
std::vector< IMDDimension_const_sptr > DimensionContainerType
bool m_changed
Flag indicating that some change in the inputs has occured.
std::unique_ptr< T > create(const P &parent, const IndexArg &indexArg, const HistArg &histArg)
This is the create() method that all the other create() methods call.
std::vector< IMDDimension_sptr > VecIMDDimension_sptr
Vector of shared pointers to IMDDimensions.
Definition: IMDDimension.h:105
std::shared_ptr< const IMDDimension > IMDDimension_const_sptr
Shared Pointer to const IMDDimension.
Definition: IMDDimension.h:101
Helper class which provides the Collimation Length for SANS instruments.
void operator()(const IMDDimension &)
void operator()(const IMDDimension &item)