1.00.5
C++ Simulated Airline Inventory Management System Library
FlightVisibilityCode.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/service/Logger.hpp>
9
// Airinv
10
#include <
airinv/AIRINV_Types.hpp
>
11
#include <
airinv/basic/FlightVisibilityCode.hpp
>
12
13
namespace
AIRINV
{
14
15
// //////////////////////////////////////////////////////////////////////
16
const
std::string FlightVisibilityCode::_labels[LAST_VALUE] =
17
{
"Normal"
,
"Hidden"
,
"Pseudo"
};
18
19
const
std::string FlightVisibilityCode::_codeLabels[LAST_VALUE] =
20
{
"NOR"
,
"HID"
,
"PSD"
};
21
22
23
// //////////////////////////////////////////////////////////////////////
24
FlightVisibilityCode::
25
FlightVisibilityCode
(
const
EN_FlightVisibilityCode
& iFlightVisibilityCode)
26
: _code (iFlightVisibilityCode) {
27
}
28
29
// //////////////////////////////////////////////////////////////////////
30
FlightVisibilityCode::FlightVisibilityCode
(
const
std::string& iCode) {
31
_code =
LAST_VALUE
;
32
33
if
(iCode ==
"NOR"
) {
34
_code =
NORMAL
;
35
36
}
else
if
(iCode ==
"HID"
) {
37
_code =
HIDDEN
;
38
39
}
else
if
(iCode ==
"PSD"
) {
40
_code =
PSEUDO
;
41
}
42
43
if
(_code ==
LAST_VALUE
) {
44
const
std::string& lLabels =
describeLabels
();
45
STDAIR_LOG_ERROR (
"The flight visibility code '"
<< iCode
46
<<
"' is not known. Known flight visibility codes: "
47
<< lLabels);
48
throw
stdair::CodeConversionException (
"The flight visibility code '"
49
+ iCode
50
+
"' is not known. Known flight visibility codes: "
51
+ lLabels);
52
}
53
}
54
55
// //////////////////////////////////////////////////////////////////////
56
const
std::string&
FlightVisibilityCode::
57
getLabel
(
const
EN_FlightVisibilityCode
& iCode) {
58
return
_labels[iCode];
59
}
60
61
// //////////////////////////////////////////////////////////////////////
62
const
std::string&
FlightVisibilityCode::
63
getCodeLabel
(
const
EN_FlightVisibilityCode
& iCode) {
64
return
_codeLabels[iCode];
65
}
66
67
// //////////////////////////////////////////////////////////////////////
68
std::string
FlightVisibilityCode::describeLabels
() {
69
std::ostringstream ostr;
70
for
(
unsigned
short
idx = 0; idx !=
LAST_VALUE
; ++idx) {
71
if
(idx != 0) {
72
ostr <<
", "
;
73
}
74
ostr << _labels[idx];
75
}
76
return
ostr.str();
77
}
78
79
// //////////////////////////////////////////////////////////////////////
80
FlightVisibilityCode::EN_FlightVisibilityCode
FlightVisibilityCode::
81
getCode
()
const
{
82
return
_code;
83
}
84
85
// //////////////////////////////////////////////////////////////////////
86
const
std::string
FlightVisibilityCode::describe
()
const
{
87
std::ostringstream ostr;
88
ostr << _labels[_code];
89
return
ostr.str();
90
}
91
92
}
AIRINV::FlightVisibilityCode::EN_FlightVisibilityCode
EN_FlightVisibilityCode
Definition:
FlightVisibilityCode.hpp:17
AIRINV::FlightVisibilityCode::describe
const std::string describe() const
Definition:
FlightVisibilityCode.cpp:86
AIRINV::FlightVisibilityCode::getLabel
static const std::string & getLabel(const EN_FlightVisibilityCode &)
Definition:
FlightVisibilityCode.cpp:57
AIRINV::FlightVisibilityCode::describeLabels
static std::string describeLabels()
Definition:
FlightVisibilityCode.cpp:68
AIRINV::FlightVisibilityCode::NORMAL
@ NORMAL
Definition:
FlightVisibilityCode.hpp:18
AIRINV::FlightVisibilityCode::PSEUDO
@ PSEUDO
Definition:
FlightVisibilityCode.hpp:20
AIRINV::FlightVisibilityCode::getCodeLabel
static const std::string & getCodeLabel(const EN_FlightVisibilityCode &)
Definition:
FlightVisibilityCode.cpp:63
AIRINV::FlightVisibilityCode::HIDDEN
@ HIDDEN
Definition:
FlightVisibilityCode.hpp:19
AIRINV_Types.hpp
AIRINV::FlightVisibilityCode::FlightVisibilityCode
FlightVisibilityCode(const EN_FlightVisibilityCode &)
Definition:
FlightVisibilityCode.cpp:25
AIRINV
Definition:
AIRINV_Master_Service.hpp:38
AIRINV::FlightVisibilityCode::getCode
EN_FlightVisibilityCode getCode() const
Definition:
FlightVisibilityCode.cpp:81
AIRINV::FlightVisibilityCode::LAST_VALUE
@ LAST_VALUE
Definition:
FlightVisibilityCode.hpp:21
FlightVisibilityCode.hpp
Generated on Sun Aug 9 2020 00:00:00 for AirInv by
1.8.18