1.00.0
C++ Simulated Airline Inventory Management System library
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
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
}
Generated on Tue Dec 25 2012 22:19:41 for AirInv by
1.8.1.1