1.00.26
C++ Standard Airline IT Object Library
Toggle main menu visibility
Loading...
Searching...
No Matches
DemandGenerationMethod.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/DemandGenerationMethod.hpp
>
10
11
namespace
stdair
{
12
13
// //////////////////////////////////////////////////////////////////////
14
const
std::string DemandGenerationMethod::_labels[
LAST_VALUE
] =
15
{
"PoissonProcess"
,
"StatisticsOrder"
};
16
17
// //////////////////////////////////////////////////////////////////////
18
const
char
DemandGenerationMethod::_methodLabels[
LAST_VALUE
] = {
'P'
,
'S'
};
19
20
21
// //////////////////////////////////////////////////////////////////////
22
DemandGenerationMethod::DemandGenerationMethod
() : _method (
LAST_VALUE
) {
23
assert (
false
);
24
}
25
26
// //////////////////////////////////////////////////////////////////////
27
DemandGenerationMethod::
28
DemandGenerationMethod (
const
DemandGenerationMethod
& iDemandGenerationMethod)
29
: _method (iDemandGenerationMethod._method) {
30
}
31
32
// //////////////////////////////////////////////////////////////////////
33
DemandGenerationMethod::
34
DemandGenerationMethod
(
const
EN_DemandGenerationMethod
& iDemandGenerationMethod)
35
: _method (iDemandGenerationMethod) {
36
}
37
38
// //////////////////////////////////////////////////////////////////////
39
DemandGenerationMethod::EN_DemandGenerationMethod
40
DemandGenerationMethod::getMethod
(
const
char
iMethodChar) {
41
EN_DemandGenerationMethod
oMethod;
42
switch
(iMethodChar) {
43
case
'P'
: oMethod =
POI_PRO
;
break
;
44
case
'S'
: oMethod =
STA_ORD
;
break
;
45
default
: oMethod =
LAST_VALUE
;
break
;
46
}
47
48
if
(oMethod ==
LAST_VALUE
) {
49
const
std::string& lLabels =
describeLabels
();
50
std::ostringstream oMessage;
51
oMessage <<
"The demand (booking request) generation method '"
52
<< iMethodChar
53
<<
"' is not known. Known demand (booking request) generation "
54
<<
"methods: "
<< lLabels;
55
throw
CodeConversionException
(oMessage.str());
56
}
57
58
return
oMethod;
59
}
60
61
// //////////////////////////////////////////////////////////////////////
62
DemandGenerationMethod::DemandGenerationMethod
(
const
char
iMethodChar)
63
: _method (
getMethod
(iMethodChar)) {
64
}
65
66
// //////////////////////////////////////////////////////////////////////
67
DemandGenerationMethod::
68
DemandGenerationMethod
(
const
std::string& iMethodStr) {
69
//
70
const
size_t
lSize = iMethodStr.size();
71
assert (lSize == 1);
72
const
char
lMethodChar = iMethodStr[0];
73
_method =
getMethod
(lMethodChar);
74
}
75
76
// //////////////////////////////////////////////////////////////////////
77
const
std::string&
DemandGenerationMethod::
78
getLabel
(
const
EN_DemandGenerationMethod
& iMethod) {
79
return
_labels[iMethod];
80
}
81
82
// //////////////////////////////////////////////////////////////////////
83
char
DemandGenerationMethod::
84
getMethodLabel
(
const
EN_DemandGenerationMethod
& iMethod) {
85
return
_methodLabels[iMethod];
86
}
87
88
// //////////////////////////////////////////////////////////////////////
89
std::string
DemandGenerationMethod::
90
getMethodLabelAsString
(
const
EN_DemandGenerationMethod
& iMethod) {
91
std::ostringstream oStr;
92
oStr << _methodLabels[iMethod];
93
return
oStr.str();
94
}
95
96
// //////////////////////////////////////////////////////////////////////
97
std::string
DemandGenerationMethod::describeLabels
() {
98
std::ostringstream ostr;
99
for
(
unsigned
short
idx = 0; idx !=
LAST_VALUE
; ++idx) {
100
if
(idx != 0) {
101
ostr <<
", "
;
102
}
103
ostr << _labels[idx];
104
}
105
return
ostr.str();
106
}
107
108
// //////////////////////////////////////////////////////////////////////
109
DemandGenerationMethod::EN_DemandGenerationMethod
110
DemandGenerationMethod::getMethod
()
const
{
111
return
_method;
112
}
113
114
// //////////////////////////////////////////////////////////////////////
115
char
DemandGenerationMethod::getMethodAsChar
()
const
{
116
const
char
oMethodChar = _methodLabels[_method];
117
return
oMethodChar;
118
}
119
120
// //////////////////////////////////////////////////////////////////////
121
std::string
DemandGenerationMethod::getMethodAsString
()
const
{
122
std::ostringstream oStr;
123
oStr << _methodLabels[_method];
124
return
oStr.str();
125
}
126
127
// //////////////////////////////////////////////////////////////////////
128
const
std::string
DemandGenerationMethod::describe
()
const
{
129
std::ostringstream ostr;
130
ostr << _labels[_method];
131
return
ostr.str();
132
}
133
134
// //////////////////////////////////////////////////////////////////////
135
bool
DemandGenerationMethod::
136
operator==
(
const
EN_DemandGenerationMethod
& iMethod)
const
{
137
return
(_method == iMethod);
138
}
139
140
}
DemandGenerationMethod.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::DemandGenerationMethod::describe
const std::string describe() const
Definition
DemandGenerationMethod.cpp:128
stdair::DemandGenerationMethod::getMethodLabelAsString
static std::string getMethodLabelAsString(const EN_DemandGenerationMethod &)
Definition
DemandGenerationMethod.cpp:90
stdair::DemandGenerationMethod::getLabel
static const std::string & getLabel(const EN_DemandGenerationMethod &)
Definition
DemandGenerationMethod.cpp:78
stdair::DemandGenerationMethod::EN_DemandGenerationMethod
EN_DemandGenerationMethod
Definition
DemandGenerationMethod.hpp:19
stdair::DemandGenerationMethod::LAST_VALUE
@ LAST_VALUE
Definition
DemandGenerationMethod.hpp:22
stdair::DemandGenerationMethod::STA_ORD
@ STA_ORD
Definition
DemandGenerationMethod.hpp:21
stdair::DemandGenerationMethod::POI_PRO
@ POI_PRO
Definition
DemandGenerationMethod.hpp:20
stdair::DemandGenerationMethod::getMethod
EN_DemandGenerationMethod getMethod() const
Definition
DemandGenerationMethod.cpp:110
stdair::DemandGenerationMethod::DemandGenerationMethod
DemandGenerationMethod(const EN_DemandGenerationMethod &)
Definition
DemandGenerationMethod.cpp:34
stdair::DemandGenerationMethod::getMethod
static EN_DemandGenerationMethod getMethod(const char)
Definition
DemandGenerationMethod.cpp:40
stdair::DemandGenerationMethod::getMethodAsChar
char getMethodAsChar() const
Definition
DemandGenerationMethod.cpp:115
stdair::DemandGenerationMethod::describeLabels
static std::string describeLabels()
Definition
DemandGenerationMethod.cpp:97
stdair::DemandGenerationMethod::operator==
bool operator==(const EN_DemandGenerationMethod &) const
Definition
DemandGenerationMethod.cpp:136
stdair::DemandGenerationMethod::getMethodAsString
std::string getMethodAsString() const
Definition
DemandGenerationMethod.cpp:121
stdair::DemandGenerationMethod::getMethodLabel
static char getMethodLabel(const EN_DemandGenerationMethod &)
Definition
DemandGenerationMethod.cpp:84
stdair::CodeConversionException
Definition
stdair_exceptions.hpp:133
Generated for StdAir by
1.17.0