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