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
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
}
Generated on Tue Dec 25 2012 22:19:41 for AirInv by
1.8.1.1