Mantid
Loading...
Searching...
No Matches
Triple.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#include <string>
9
10namespace Mantid {
11
12template <typename T>
14 : first(), second(), third()
18{}
19
20template <typename T>
22 : first(A.first), second(A.second), third(A.third)
27{}
28
29template <typename T>
30Triple<T>::Triple(const T &A, const T &B, const T &C)
31 : first(A), second(B), third(C)
38{}
39
40template <typename T>
47{
48 if (this != &A) {
49 first = A.first;
50 second = A.second;
51 third = A.third;
52 }
53 return *this;
54}
55
56template <typename T>
61 = default;
62
63template <typename T>
64bool Triple<T>::operator==(const Triple<T> &A) const
68{
69 return (first == A.first && second == A.second && third == A.third);
70}
71
72template <typename T>
73bool Triple<T>::operator!=(const Triple<T> &A) const
79{
80 return !(*this == A);
81}
82
83template <typename T>
84bool Triple<T>::operator<(const Triple<T> &A) const
90{
91 if (first > A.first)
92 return false;
93 if (first < A.first)
94 return true;
95 if (second > A.second)
96 return false;
97 if (second < A.second)
98 return true;
99 if (third >= A.third)
100 return false;
101 return true;
102}
103
104template <typename T>
105bool Triple<T>::operator>(const Triple<T> &A) const
113{
114 return A.operator<(*this);
115}
116
117template <typename T>
124{
125 switch (A) {
126 case 0:
127 return first;
128 case 1:
129 return second;
130 case 2:
131 return third;
132 default:
133 throw "Range Error";
134 }
135}
136
137template <typename T>
138T Triple<T>::operator[](const int A) const
144{
145 switch (A) {
146 case 0:
147 return first;
148 case 1:
149 return second;
150 case 2:
151 return third;
152 default:
153 throw "Range Error";
154 }
155}
156
157/*
158------------------------------------------------------------------
159 Different Triple
160------------------------------------------------------------------
161*/
162
163template <typename F, typename S, typename T>
165 : first(), second(), third()
169{}
170
171template <typename F, typename S, typename T>
173 : first(A.first), second(A.second), third(A.third)
178{}
179
180template <typename F, typename S, typename T>
181DTriple<F, S, T>::DTriple(const F &A, const S &B, const T &C)
182 : first(A), second(B), third(C)
189{}
190
191template <typename F, typename S, typename T>
198{
199 if (this != &A) {
200 first = A.first;
201 second = A.second;
202 third = A.third;
203 }
204 return *this;
205}
206
207template <typename F, typename S, typename T>
212 = default;
213
214template <typename F, typename S, typename T>
221{
222 return (first == A.first && second == A.second && third == A.third);
223}
224
225template <typename F, typename S, typename T>
230{
231 return !(*this == A);
232}
233
234template <typename F, typename S, typename T>
241{
242 if (first > A.first)
243 return false;
244 if (first < A.first)
245 return true;
246 if (second > A.second)
247 return false;
248 if (second < A.second)
249 return true;
250 if (third >= A.third)
251 return false;
252 return true;
253}
254
255template <typename F, typename S, typename T>
262{
263 return A.operator<(*this);
264}
265
267
268namespace Geometry {
269class Rule;
270}
271
272template class DTriple<Geometry::Rule *, int, Geometry::Rule *>;
273template class DTriple<std::string, int, int>;
274template class DTriple<int, int, double>;
275template class DTriple<int, int, std::string>;
276template class DTriple<int, double, std::string>;
277template class Triple<int>;
278template class Triple<double>;
279
281
282} // Namespace Mantid
Triple of three different things.
Definition: Triple.h:53
bool operator>(const DTriple< F, S, T > &) const
Operator> takes first to last precidence.
Definition: Triple.cpp:256
bool operator!=(const DTriple< F, S, T > &) const
Operator!= any component is not equal.
Definition: Triple.cpp:226
DTriple< F, S, T > & operator=(const DTriple< F, S, T > &)
Assignment from a 3 value input.
Definition: Triple.cpp:192
bool operator==(const DTriple< F, S, T > &) const
Operator== all components must be equal.
Definition: Triple.cpp:215
~DTriple()
Standard Destructor.
S second
Second item.
Definition: Triple.h:56
DTriple()
Standard Constructor.
Definition: Triple.cpp:164
bool operator<(const DTriple< F, S, T > &) const
Operator< takes first to last precidence.
Definition: Triple.cpp:235
T third
Third item.
Definition: Triple.h:57
F first
First item.
Definition: Triple.h:55
Object generation rule tree.
Definition: Rules.h:33
Triple of three identical types.
Definition: Triple.h:22
bool operator==(const Triple< T > &) const
Operator== all components must be equal.
Definition: Triple.cpp:64
T operator[](const int A) const
Accessor Value Function.
Definition: Triple.cpp:138
bool operator>(const Triple< T > &) const
Operator> takes first to last precidence.
Definition: Triple.cpp:105
bool operator<(const Triple< T > &) const
Operator< takes first to last precidence.
Definition: Triple.cpp:84
T second
Second item.
Definition: Triple.h:25
T third
Third item.
Definition: Triple.h:26
Triple< T > & operator=(const Triple< T > &)
Standard Assignment Constructor.
Definition: Triple.cpp:41
Triple()
Standard Constructor.
Definition: Triple.cpp:13
T first
First item.
Definition: Triple.h:24
bool operator!=(const Triple< T > &) const
Operator!= any component is not equal.
Definition: Triple.cpp:73
~Triple()
Standard Destructor.
Helper class which provides the Collimation Length for SANS instruments.