1.00.26
C++ Standard Airline IT Object Library
Toggle main menu visibility
Loading...
Searching...
No Matches
PassengerChoiceModel.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/PassengerChoiceModel.hpp
>
10
11
namespace
stdair
{
12
13
// //////////////////////////////////////////////////////////////////////
14
const
std::string PassengerChoiceModel::_labels[
LAST_VALUE
] =
15
{
"HardRestrictionModel"
,
"PriceOrientedModel"
,
"HybridModel"
};
16
17
// //////////////////////////////////////////////////////////////////////
18
const
char
PassengerChoiceModel::
19
_modelLabels[
LAST_VALUE
] = {
'R'
,
'P'
,
'H'
};
20
21
22
// //////////////////////////////////////////////////////////////////////
23
PassengerChoiceModel::PassengerChoiceModel
()
24
: _model (
LAST_VALUE
) {
25
assert (
false
);
26
}
27
28
// //////////////////////////////////////////////////////////////////////
29
PassengerChoiceModel::
30
PassengerChoiceModel (
const
PassengerChoiceModel
& iPassengerChoiceModel)
31
: _model (iPassengerChoiceModel._model) {
32
}
33
34
// //////////////////////////////////////////////////////////////////////
35
PassengerChoiceModel::
36
PassengerChoiceModel
(
const
EN_PassengerChoiceModel
& iPassengerChoiceModel)
37
: _model (iPassengerChoiceModel) {
38
}
39
40
// //////////////////////////////////////////////////////////////////////
41
PassengerChoiceModel::PassengerChoiceModel
(
const
char
iModel) {
42
switch
(iModel) {
43
case
'R'
: _model =
HARD_RESTRICTION
;
break
;
44
case
'P'
: _model =
PRICE_ORIENTED
;
break
;
45
case
'H'
: _model =
HYBRID
;
break
;
46
default
: _model =
LAST_VALUE
;
break
;
47
}
48
49
if
(_model ==
LAST_VALUE
) {
50
const
std::string& lLabels =
describeLabels
();
51
std::ostringstream oMessage;
52
oMessage <<
"The passenger choice model '"
53
<<
"' is not known. Known passenger choice models "
<< lLabels;
54
throw
stdair::CodeConversionException
(oMessage.str());
55
}
56
}
57
58
// //////////////////////////////////////////////////////////////////////
59
const
std::string&
PassengerChoiceModel::
60
getLabel
(
const
EN_PassengerChoiceModel
& iModel) {
61
return
_labels[iModel];
62
}
63
64
// //////////////////////////////////////////////////////////////////////
65
char
PassengerChoiceModel::getModelLabel
(
const
EN_PassengerChoiceModel
& iModel) {
66
return
_modelLabels[iModel];
67
}
68
69
// //////////////////////////////////////////////////////////////////////
70
std::string
PassengerChoiceModel::
71
getModelLabelAsString
(
const
EN_PassengerChoiceModel
& iModel) {
72
std::ostringstream oStr;
73
oStr << _modelLabels[iModel];
74
return
oStr.str();
75
}
76
77
// //////////////////////////////////////////////////////////////////////
78
std::string
PassengerChoiceModel::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] <<
" ("
<< _modelLabels[idx] <<
")"
;
85
}
86
return
ostr.str();
87
}
88
89
// //////////////////////////////////////////////////////////////////////
90
PassengerChoiceModel::EN_PassengerChoiceModel
PassengerChoiceModel::getModel
()
const
{
91
return
_model;
92
}
93
94
// //////////////////////////////////////////////////////////////////////
95
std::string
PassengerChoiceModel::getModelAsString
()
const
{
96
std::ostringstream oStr;
97
oStr << _modelLabels[_model];
98
return
oStr.str();
99
}
100
101
// //////////////////////////////////////////////////////////////////////
102
const
std::string
PassengerChoiceModel::describe
()
const
{
103
std::ostringstream ostr;
104
ostr << _labels[_model];
105
return
ostr.str();
106
}
107
108
// //////////////////////////////////////////////////////////////////////
109
bool
PassengerChoiceModel::
110
operator==
(
const
EN_PassengerChoiceModel
& iModel)
const
{
111
return
(_model == iModel);
112
}
113
114
}
PassengerChoiceModel.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::PassengerChoiceModel::describe
const std::string describe() const
Definition
PassengerChoiceModel.cpp:102
stdair::PassengerChoiceModel::PassengerChoiceModel
PassengerChoiceModel(const EN_PassengerChoiceModel &)
Definition
PassengerChoiceModel.cpp:36
stdair::PassengerChoiceModel::getModel
EN_PassengerChoiceModel getModel() const
Definition
PassengerChoiceModel.cpp:90
stdair::PassengerChoiceModel::getLabel
static const std::string & getLabel(const EN_PassengerChoiceModel &)
Definition
PassengerChoiceModel.cpp:60
stdair::PassengerChoiceModel::EN_PassengerChoiceModel
EN_PassengerChoiceModel
Definition
PassengerChoiceModel.hpp:17
stdair::PassengerChoiceModel::PRICE_ORIENTED
@ PRICE_ORIENTED
Definition
PassengerChoiceModel.hpp:19
stdair::PassengerChoiceModel::HYBRID
@ HYBRID
Definition
PassengerChoiceModel.hpp:20
stdair::PassengerChoiceModel::LAST_VALUE
@ LAST_VALUE
Definition
PassengerChoiceModel.hpp:21
stdair::PassengerChoiceModel::HARD_RESTRICTION
@ HARD_RESTRICTION
Definition
PassengerChoiceModel.hpp:18
stdair::PassengerChoiceModel::getModelAsString
std::string getModelAsString() const
Definition
PassengerChoiceModel.cpp:95
stdair::PassengerChoiceModel::getModelLabel
static char getModelLabel(const EN_PassengerChoiceModel &)
Definition
PassengerChoiceModel.cpp:65
stdair::PassengerChoiceModel::describeLabels
static std::string describeLabels()
Definition
PassengerChoiceModel.cpp:78
stdair::PassengerChoiceModel::getModelLabelAsString
static std::string getModelLabelAsString(const EN_PassengerChoiceModel &)
Definition
PassengerChoiceModel.cpp:71
stdair::PassengerChoiceModel::operator==
bool operator==(const EN_PassengerChoiceModel &) const
Definition
PassengerChoiceModel.cpp:110
stdair::CodeConversionException
Definition
stdair_exceptions.hpp:133
Generated for StdAir by
1.17.0