1.00.26
C++ Standard Airline IT Object Library
Toggle main menu visibility
Loading...
Searching...
No Matches
SampleType.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/SampleType.hpp
>
10
11
namespace
stdair
{
12
13
// //////////////////////////////////////////////////////////////////////
14
const
std::string SampleType::_labels[
LAST_VALUE
] =
15
{
"All"
,
"AllForPartnerships"
,
"RevenueManagement"
,
"Inventory"
,
"Schedule"
,
16
"RevenueAccounting"
,
"FareQuote"
,
"CRS"
,
"DemandGeneration"
,
"EventManagement"
,
17
"CustomerChoice"
};
18
19
// //////////////////////////////////////////////////////////////////////
20
const
char
SampleType::
21
_typeLabels[
LAST_VALUE
] = {
'A'
,
'P'
,
'R'
,
'I'
,
'S'
,
'T'
,
'F'
,
'C'
,
'D'
,
'E'
,
'M'
};
22
23
24
// //////////////////////////////////////////////////////////////////////
25
SampleType::SampleType
()
26
: _type (
LAST_VALUE
) {
27
assert (
false
);
28
}
29
30
// //////////////////////////////////////////////////////////////////////
31
SampleType::SampleType
(
const
SampleType
& iSampleType)
32
: _type (iSampleType._type) {
33
}
34
35
// //////////////////////////////////////////////////////////////////////
36
SampleType::SampleType
(
const
EN_SampleType
& iSampleType)
37
: _type (iSampleType) {
38
}
39
40
// //////////////////////////////////////////////////////////////////////
41
SampleType::SampleType
(
const
char
iType) {
42
switch
(iType) {
43
case
'A'
: _type =
ALL
;
break
;
44
case
'P'
: _type =
A4P
;
break
;
45
case
'R'
: _type =
RMS
;
break
;
46
case
'I'
: _type =
INV
;
break
;
47
case
'S'
: _type =
SCH
;
break
;
48
case
'T'
: _type =
RAC
;
break
;
49
case
'F'
: _type =
FQT
;
break
;
50
case
'C'
: _type =
CRS
;
break
;
51
case
'D'
: _type =
DEM
;
break
;
52
case
'E'
: _type =
EVT
;
break
;
53
case
'M'
: _type =
CCM
;
break
;
54
default
: _type =
LAST_VALUE
;
break
;
55
}
56
57
if
(_type ==
LAST_VALUE
) {
58
const
std::string& lLabels =
describeLabels
();
59
std::ostringstream oMessage;
60
oMessage <<
"The sample type '"
<< iType
61
<<
"' is not known. Known sample types: "
<< lLabels;
62
throw
CodeConversionException
(oMessage.str());
63
}
64
}
65
66
// //////////////////////////////////////////////////////////////////////
67
const
std::string&
SampleType::getLabel
(
const
EN_SampleType
& iType) {
68
return
_labels[iType];
69
}
70
71
// //////////////////////////////////////////////////////////////////////
72
char
SampleType::getTypeLabel
(
const
EN_SampleType
& iType) {
73
return
_typeLabels[iType];
74
}
75
76
// //////////////////////////////////////////////////////////////////////
77
std::string
SampleType::getTypeLabelAsString
(
const
EN_SampleType
& iType) {
78
std::ostringstream oStr;
79
oStr << _typeLabels[iType];
80
return
oStr.str();
81
}
82
83
// //////////////////////////////////////////////////////////////////////
84
std::string
SampleType::describeLabels
() {
85
std::ostringstream ostr;
86
for
(
unsigned
short
idx = 0; idx !=
LAST_VALUE
; ++idx) {
87
if
(idx != 0) {
88
ostr <<
", "
;
89
}
90
ostr << _labels[idx];
91
}
92
return
ostr.str();
93
}
94
95
// //////////////////////////////////////////////////////////////////////
96
SampleType::EN_SampleType
SampleType::getType
()
const
{
97
return
_type;
98
}
99
100
// //////////////////////////////////////////////////////////////////////
101
std::string
SampleType::getTypeAsString
()
const
{
102
std::ostringstream oStr;
103
oStr << _typeLabels[_type];
104
return
oStr.str();
105
}
106
107
// //////////////////////////////////////////////////////////////////////
108
const
std::string
SampleType::describe
()
const
{
109
std::ostringstream ostr;
110
ostr << _labels[_type];
111
return
ostr.str();
112
}
113
114
// //////////////////////////////////////////////////////////////////////
115
bool
SampleType::operator==
(
const
EN_SampleType
& iType)
const
{
116
return
(_type == iType);
117
}
118
119
}
SampleType.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::SampleType::SampleType
SampleType(const EN_SampleType &)
Definition
SampleType.cpp:36
stdair::SampleType::describeLabels
static std::string describeLabels()
Definition
SampleType.cpp:84
stdair::SampleType::operator==
bool operator==(const EN_SampleType &) const
Definition
SampleType.cpp:115
stdair::SampleType::describe
const std::string describe() const
Definition
SampleType.cpp:108
stdair::SampleType::getType
EN_SampleType getType() const
Definition
SampleType.cpp:96
stdair::SampleType::getTypeLabel
static char getTypeLabel(const EN_SampleType &)
Definition
SampleType.cpp:72
stdair::SampleType::getLabel
static const std::string & getLabel(const EN_SampleType &)
Definition
SampleType.cpp:67
stdair::SampleType::getTypeAsString
std::string getTypeAsString() const
Definition
SampleType.cpp:101
stdair::SampleType::EN_SampleType
EN_SampleType
Definition
SampleType.hpp:27
stdair::SampleType::SCH
@ SCH
Definition
SampleType.hpp:32
stdair::SampleType::FQT
@ FQT
Definition
SampleType.hpp:34
stdair::SampleType::A4P
@ A4P
Definition
SampleType.hpp:29
stdair::SampleType::DEM
@ DEM
Definition
SampleType.hpp:36
stdair::SampleType::CCM
@ CCM
Definition
SampleType.hpp:38
stdair::SampleType::RMS
@ RMS
Definition
SampleType.hpp:30
stdair::SampleType::EVT
@ EVT
Definition
SampleType.hpp:37
stdair::SampleType::INV
@ INV
Definition
SampleType.hpp:31
stdair::SampleType::RAC
@ RAC
Definition
SampleType.hpp:33
stdair::SampleType::LAST_VALUE
@ LAST_VALUE
Definition
SampleType.hpp:39
stdair::SampleType::CRS
@ CRS
Definition
SampleType.hpp:35
stdair::SampleType::ALL
@ ALL
Definition
SampleType.hpp:28
stdair::SampleType::getTypeLabelAsString
static std::string getTypeLabelAsString(const EN_SampleType &)
Definition
SampleType.cpp:77
stdair::CodeConversionException
Definition
stdair_exceptions.hpp:133
Generated for StdAir by
1.17.0