StdAir Logo  1.00.16
C++ Standard Airline IT Object Library
Loading...
Searching...
No Matches
UnconstrainingMethod.cpp
Go to the documentation of this file.
1// //////////////////////////////////////////////////////////////////////
2// Import section
3// //////////////////////////////////////////////////////////////////////
4// STL
5#include <cassert>
6#include <sstream>
7// StdAir
10
11namespace stdair {
12
13 // //////////////////////////////////////////////////////////////////////
14 const std::string UnconstrainingMethod::_labels[LAST_VALUE] =
15 { "Expectation-Maximisation" };
16
17 // //////////////////////////////////////////////////////////////////////
18 const char UnconstrainingMethod::
19 _methodLabels[LAST_VALUE] = { 'E' };
20
21
22 // //////////////////////////////////////////////////////////////////////
24 : _method (LAST_VALUE) {
25 assert (false);
26 }
27
28 // //////////////////////////////////////////////////////////////////////
29 UnconstrainingMethod::
30 UnconstrainingMethod (const UnconstrainingMethod& iUnconstrainingMethod)
31 : _method (iUnconstrainingMethod._method) {
32 }
33
34 // //////////////////////////////////////////////////////////////////////
35 UnconstrainingMethod::
36 UnconstrainingMethod (const EN_UnconstrainingMethod& iUnconstrainingMethod)
37 : _method (iUnconstrainingMethod) {
38 }
39
40 // //////////////////////////////////////////////////////////////////////
42 switch (iMethod) {
43 case 'E': _method = EM; break;
44 default: _method = LAST_VALUE; break;
45 }
46
47 if (_method == LAST_VALUE) {
48 const std::string& lLabels = describeLabels();
49 std::ostringstream oMessage;
50 oMessage << "The unconstraining method '" << iMethod
51 << "' is not known. Known unconstraining methods: " << lLabels;
52 throw CodeConversionException (oMessage.str());
53 }
54 }
55
56 // //////////////////////////////////////////////////////////////////////
57 const std::string& UnconstrainingMethod::
58 getLabel (const EN_UnconstrainingMethod& iMethod) {
59 return _labels[iMethod];
60 }
61
62 // //////////////////////////////////////////////////////////////////////
64 return _methodLabels[iMethod];
65 }
66
67 // //////////////////////////////////////////////////////////////////////
70 std::ostringstream oStr;
71 oStr << _methodLabels[iMethod];
72 return oStr.str();
73 }
74
75 // //////////////////////////////////////////////////////////////////////
77 std::ostringstream ostr;
78 for (unsigned short idx = 0; idx != LAST_VALUE; ++idx) {
79 if (idx != 0) {
80 ostr << ", ";
81 }
82 ostr << _labels[idx] << " (" << _methodLabels[idx] << ")";
83 }
84 return ostr.str();
85 }
86
87 // //////////////////////////////////////////////////////////////////////
91
92 // //////////////////////////////////////////////////////////////////////
94 std::ostringstream oStr;
95 oStr << _methodLabels[_method];
96 return oStr.str();
97 }
98
99 // //////////////////////////////////////////////////////////////////////
100 const std::string UnconstrainingMethod::describe() const {
101 std::ostringstream ostr;
102 ostr << _labels[_method];
103 return ostr.str();
104 }
105
106 // //////////////////////////////////////////////////////////////////////
108 operator== (const EN_UnconstrainingMethod& iMethod) const {
109 return (_method == iMethod);
110 }
111
112}
Handle on the StdAir library context.
bool operator==(const EN_UnconstrainingMethod &) const
UnconstrainingMethod(const EN_UnconstrainingMethod &)
static char getMethodLabel(const EN_UnconstrainingMethod &)
const std::string describe() const
EN_UnconstrainingMethod getMethod() const
static const std::string & getLabel(const EN_UnconstrainingMethod &)
static std::string getMethodLabelAsString(const EN_UnconstrainingMethod &)