1.00.26
C++ Standard Airline IT Object Library
Toggle main menu visibility
Loading...
Searching...
No Matches
PreOptimisationMethod.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/PreOptimisationMethod.hpp
>
10
11
namespace
stdair
{
12
13
// //////////////////////////////////////////////////////////////////////
14
const
std::string PreOptimisationMethod::_labels[
LAST_VALUE
] =
15
{
"None"
,
"Fare Adjustment"
,
"Marginal Revenue Transformation"
};
16
17
// //////////////////////////////////////////////////////////////////////
18
const
char
PreOptimisationMethod::
19
_methodLabels[
LAST_VALUE
] = {
'N'
,
'F'
,
'M'
};
20
21
22
// //////////////////////////////////////////////////////////////////////
23
PreOptimisationMethod::PreOptimisationMethod
()
24
: _method (
LAST_VALUE
) {
25
assert (
false
);
26
}
27
28
// //////////////////////////////////////////////////////////////////////
29
PreOptimisationMethod::
30
PreOptimisationMethod (
const
PreOptimisationMethod
& iPreOptimisationMethod)
31
: _method (iPreOptimisationMethod._method) {
32
}
33
34
// //////////////////////////////////////////////////////////////////////
35
PreOptimisationMethod::
36
PreOptimisationMethod
(
const
EN_PreOptimisationMethod
& iPreOptimisationMethod)
37
: _method (iPreOptimisationMethod) {
38
}
39
40
// //////////////////////////////////////////////////////////////////////
41
PreOptimisationMethod::PreOptimisationMethod
(
const
char
iMethod) {
42
switch
(iMethod) {
43
case
'N'
: _method =
NONE
;
break
;
44
case
'F'
: _method =
FA
;
break
;
45
case
'M'
: _method =
MRT
;
break
;
46
default
: _method =
LAST_VALUE
;
break
;
47
}
48
49
if
(_method ==
LAST_VALUE
) {
50
const
std::string& lLabels =
describeLabels
();
51
std::ostringstream oMessage;
52
oMessage <<
"The pre-optimisation method '"
<< iMethod
53
<<
"' is not known. Known pre-optimisation methods: "
<< lLabels;
54
throw
CodeConversionException
(oMessage.str());
55
}
56
}
57
58
// //////////////////////////////////////////////////////////////////////
59
const
std::string&
PreOptimisationMethod::
60
getLabel
(
const
EN_PreOptimisationMethod
& iMethod) {
61
return
_labels[iMethod];
62
}
63
64
// //////////////////////////////////////////////////////////////////////
65
char
PreOptimisationMethod::getMethodLabel
(
const
EN_PreOptimisationMethod
& iMethod) {
66
return
_methodLabels[iMethod];
67
}
68
69
// //////////////////////////////////////////////////////////////////////
70
std::string
PreOptimisationMethod::
71
getMethodLabelAsString
(
const
EN_PreOptimisationMethod
& iMethod) {
72
std::ostringstream oStr;
73
oStr << _methodLabels[iMethod];
74
return
oStr.str();
75
}
76
77
// //////////////////////////////////////////////////////////////////////
78
std::string
PreOptimisationMethod::describeLabels
() {
79
std::ostringstream ostr;
80
for
(
unsigned
short
idx = 0; idx !=
LAST_VALUE
; ++idx) {
81
if
(idx != 0) {
82
ostr <<
", "
;
83
}
84
ostr << _labels[idx] <<
" ("
<< _methodLabels[idx] <<
")"
;
85
}
86
return
ostr.str();
87
}
88
89
// //////////////////////////////////////////////////////////////////////
90
PreOptimisationMethod::EN_PreOptimisationMethod
PreOptimisationMethod::getMethod
()
const
{
91
return
_method;
92
}
93
94
// //////////////////////////////////////////////////////////////////////
95
std::string
PreOptimisationMethod::getMethodAsString
()
const
{
96
std::ostringstream oStr;
97
oStr << _methodLabels[_method];
98
return
oStr.str();
99
}
100
101
// //////////////////////////////////////////////////////////////////////
102
const
std::string
PreOptimisationMethod::describe
()
const
{
103
std::ostringstream ostr;
104
ostr << _labels[_method];
105
return
ostr.str();
106
}
107
108
// //////////////////////////////////////////////////////////////////////
109
bool
PreOptimisationMethod::
110
operator==
(
const
EN_PreOptimisationMethod
& iMethod)
const
{
111
return
(_method == iMethod);
112
}
113
114
}
PreOptimisationMethod.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::PreOptimisationMethod::getLabel
static const std::string & getLabel(const EN_PreOptimisationMethod &)
Definition
PreOptimisationMethod.cpp:60
stdair::PreOptimisationMethod::PreOptimisationMethod
PreOptimisationMethod(const EN_PreOptimisationMethod &)
Definition
PreOptimisationMethod.cpp:36
stdair::PreOptimisationMethod::describeLabels
static std::string describeLabels()
Definition
PreOptimisationMethod.cpp:78
stdair::PreOptimisationMethod::describe
const std::string describe() const
Definition
PreOptimisationMethod.cpp:102
stdair::PreOptimisationMethod::operator==
bool operator==(const EN_PreOptimisationMethod &) const
Definition
PreOptimisationMethod.cpp:110
stdair::PreOptimisationMethod::getMethod
EN_PreOptimisationMethod getMethod() const
Definition
PreOptimisationMethod.cpp:90
stdair::PreOptimisationMethod::getMethodLabelAsString
static std::string getMethodLabelAsString(const EN_PreOptimisationMethod &)
Definition
PreOptimisationMethod.cpp:71
stdair::PreOptimisationMethod::EN_PreOptimisationMethod
EN_PreOptimisationMethod
Definition
PreOptimisationMethod.hpp:17
stdair::PreOptimisationMethod::LAST_VALUE
@ LAST_VALUE
Definition
PreOptimisationMethod.hpp:21
stdair::PreOptimisationMethod::MRT
@ MRT
Definition
PreOptimisationMethod.hpp:20
stdair::PreOptimisationMethod::FA
@ FA
Definition
PreOptimisationMethod.hpp:19
stdair::PreOptimisationMethod::NONE
@ NONE
Definition
PreOptimisationMethod.hpp:18
stdair::PreOptimisationMethod::getMethodLabel
static char getMethodLabel(const EN_PreOptimisationMethod &)
Definition
PreOptimisationMethod.cpp:65
stdair::PreOptimisationMethod::getMethodAsString
std::string getMethodAsString() const
Definition
PreOptimisationMethod.cpp:95
stdair::CodeConversionException
Definition
stdair_exceptions.hpp:133
Generated for StdAir by
1.17.0