1.00.26
C++ Standard Airline IT Object Library
Toggle main menu visibility
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
8
#include <
stdair/stdair_exceptions.hpp
>
9
#include <
stdair/basic/UnconstrainingMethod.hpp
>
10
11
namespace
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
// //////////////////////////////////////////////////////////////////////
23
UnconstrainingMethod::UnconstrainingMethod
()
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
// //////////////////////////////////////////////////////////////////////
41
UnconstrainingMethod::UnconstrainingMethod
(
const
char
iMethod) {
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
// //////////////////////////////////////////////////////////////////////
63
char
UnconstrainingMethod::getMethodLabel
(
const
EN_UnconstrainingMethod
& iMethod) {
64
return
_methodLabels[iMethod];
65
}
66
67
// //////////////////////////////////////////////////////////////////////
68
std::string
UnconstrainingMethod::
69
getMethodLabelAsString
(
const
EN_UnconstrainingMethod
& iMethod) {
70
std::ostringstream oStr;
71
oStr << _methodLabels[iMethod];
72
return
oStr.str();
73
}
74
75
// //////////////////////////////////////////////////////////////////////
76
std::string
UnconstrainingMethod::describeLabels
() {
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
// //////////////////////////////////////////////////////////////////////
88
UnconstrainingMethod::EN_UnconstrainingMethod
UnconstrainingMethod::getMethod
()
const
{
89
return
_method;
90
}
91
92
// //////////////////////////////////////////////////////////////////////
93
std::string
UnconstrainingMethod::getMethodAsString
()
const
{
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
// //////////////////////////////////////////////////////////////////////
107
bool
UnconstrainingMethod::
108
operator==
(
const
EN_UnconstrainingMethod
& iMethod)
const
{
109
return
(_method == iMethod);
110
}
111
112
}
UnconstrainingMethod.hpp
stdair_exceptions.hpp
stdair
Handle on the StdAir library context.
Definition
BasChronometer.cpp:9
stdair::LOG::LAST_VALUE
@ LAST_VALUE
Definition
stdair_log.hpp:25
stdair::UnconstrainingMethod::operator==
bool operator==(const EN_UnconstrainingMethod &) const
Definition
UnconstrainingMethod.cpp:108
stdair::UnconstrainingMethod::getMethodAsString
std::string getMethodAsString() const
Definition
UnconstrainingMethod.cpp:93
stdair::UnconstrainingMethod::UnconstrainingMethod
UnconstrainingMethod(const EN_UnconstrainingMethod &)
Definition
UnconstrainingMethod.cpp:36
stdair::UnconstrainingMethod::describeLabels
static std::string describeLabels()
Definition
UnconstrainingMethod.cpp:76
stdair::UnconstrainingMethod::getMethodLabel
static char getMethodLabel(const EN_UnconstrainingMethod &)
Definition
UnconstrainingMethod.cpp:63
stdair::UnconstrainingMethod::describe
const std::string describe() const
Definition
UnconstrainingMethod.cpp:100
stdair::UnconstrainingMethod::getMethod
EN_UnconstrainingMethod getMethod() const
Definition
UnconstrainingMethod.cpp:88
stdair::UnconstrainingMethod::getLabel
static const std::string & getLabel(const EN_UnconstrainingMethod &)
Definition
UnconstrainingMethod.cpp:58
stdair::UnconstrainingMethod::getMethodLabelAsString
static std::string getMethodLabelAsString(const EN_UnconstrainingMethod &)
Definition
UnconstrainingMethod.cpp:69
stdair::UnconstrainingMethod::EN_UnconstrainingMethod
EN_UnconstrainingMethod
Definition
UnconstrainingMethod.hpp:17
stdair::UnconstrainingMethod::LAST_VALUE
@ LAST_VALUE
Definition
UnconstrainingMethod.hpp:19
stdair::UnconstrainingMethod::EM
@ EM
Definition
UnconstrainingMethod.hpp:18
stdair::CodeConversionException
Definition
stdair_exceptions.hpp:133
Generated for StdAir by
1.17.0