1.00.15
C++ Simulated Airline Inventory Management System Library
Toggle main menu visibility
Loading...
Searching...
No Matches
FlightTypeCode.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/FlightTypeCode.hpp
>
12
13
namespace
AIRINV
{
14
15
// //////////////////////////////////////////////////////////////////////
16
const
std::string FlightTypeCode::_labels[LAST_VALUE] =
17
{
"Domestic"
,
"International"
,
"Ground Handling"
};
18
19
const
std::string FlightTypeCode::_codeLabels[LAST_VALUE] =
20
{
"DOM"
,
"INT"
,
"GRD"
};
21
22
23
// //////////////////////////////////////////////////////////////////////
24
FlightTypeCode::FlightTypeCode
(
const
EN_FlightTypeCode
& iFlightTypeCode)
25
: _code (iFlightTypeCode) {
26
}
27
28
// //////////////////////////////////////////////////////////////////////
29
FlightTypeCode::FlightTypeCode
(
const
std::string& iCode) {
30
_code =
LAST_VALUE
;
31
32
if
(iCode ==
"DOM"
) {
33
_code =
DOMESTIC
;
34
35
}
else
if
(iCode ==
"INT"
) {
36
_code =
INTERNATIONAL
;
37
38
}
else
if
(iCode ==
"GRD"
) {
39
_code =
GROUND_HANDLING
;
40
}
41
42
if
(_code ==
LAST_VALUE
) {
43
const
std::string& lLabels =
describeLabels
();
44
STDAIR_LOG_ERROR (
"The flight type code '"
<< iCode
45
<<
"' is not known. Known flight type codes: "
46
<< lLabels);
47
throw
stdair::CodeConversionException (
"The flight type code '"
+ iCode
48
+
"' is not known. Known flight type codes: "
49
+ lLabels);
50
}
51
}
52
53
// //////////////////////////////////////////////////////////////////////
54
const
std::string&
FlightTypeCode::getLabel
(
const
EN_FlightTypeCode
& iCode) {
55
return
_labels[iCode];
56
}
57
58
// //////////////////////////////////////////////////////////////////////
59
const
std::string&
FlightTypeCode::
60
getCodeLabel
(
const
EN_FlightTypeCode
& iCode) {
61
return
_codeLabels[iCode];
62
}
63
64
// //////////////////////////////////////////////////////////////////////
65
std::string
FlightTypeCode::describeLabels
() {
66
std::ostringstream ostr;
67
for
(
unsigned
short
idx = 0; idx !=
LAST_VALUE
; ++idx) {
68
if
(idx != 0) {
69
ostr <<
", "
;
70
}
71
ostr << _labels[idx];
72
}
73
return
ostr.str();
74
}
75
76
// //////////////////////////////////////////////////////////////////////
77
FlightTypeCode::EN_FlightTypeCode
FlightTypeCode::getCode
()
const
{
78
return
_code;
79
}
80
81
// //////////////////////////////////////////////////////////////////////
82
const
std::string
FlightTypeCode::describe
()
const
{
83
std::ostringstream ostr;
84
ostr << _labels[_code];
85
return
ostr.str();
86
}
87
88
}
AIRINV_Types.hpp
FlightTypeCode.hpp
AIRINV
Definition
AIRINV_Master_Service.hpp:38
AIRINV::FlightTypeCode::getLabel
static const std::string & getLabel(const EN_FlightTypeCode &)
Definition
FlightTypeCode.cpp:54
AIRINV::FlightTypeCode::getCode
EN_FlightTypeCode getCode() const
Definition
FlightTypeCode.cpp:77
AIRINV::FlightTypeCode::getCodeLabel
static const std::string & getCodeLabel(const EN_FlightTypeCode &)
Definition
FlightTypeCode.cpp:60
AIRINV::FlightTypeCode::FlightTypeCode
FlightTypeCode(const EN_FlightTypeCode &)
Definition
FlightTypeCode.cpp:24
AIRINV::FlightTypeCode::describeLabels
static std::string describeLabels()
Definition
FlightTypeCode.cpp:65
AIRINV::FlightTypeCode::EN_FlightTypeCode
EN_FlightTypeCode
Definition
FlightTypeCode.hpp:17
AIRINV::FlightTypeCode::GROUND_HANDLING
@ GROUND_HANDLING
Definition
FlightTypeCode.hpp:20
AIRINV::FlightTypeCode::LAST_VALUE
@ LAST_VALUE
Definition
FlightTypeCode.hpp:21
AIRINV::FlightTypeCode::DOMESTIC
@ DOMESTIC
Definition
FlightTypeCode.hpp:18
AIRINV::FlightTypeCode::INTERNATIONAL
@ INTERNATIONAL
Definition
FlightTypeCode.hpp:19
AIRINV::FlightTypeCode::describe
const std::string describe() const
Definition
FlightTypeCode.cpp:82
Generated on
for AirInv by
1.17.0