1.00.26
C++ Standard Airline IT Object Library
Toggle main menu visibility
Loading...
Searching...
No Matches
ForecastingMethod.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/stdair_exceptions.hpp
>
9
#include <
stdair/basic/ForecastingMethod.hpp
>
10
11
namespace
stdair
{
12
13
// //////////////////////////////////////////////////////////////////////
14
const
std::string ForecastingMethod::_labels[
LAST_VALUE
] =
15
{
"Q Forecasting"
,
"Hybrid Forecasting"
,
"Old QFF"
,
"New QFF"
,
16
"Based Forecasting"
};
17
18
// //////////////////////////////////////////////////////////////////////
19
const
char
ForecastingMethod::
20
_methodLabels[
LAST_VALUE
] = {
'Q'
,
'H'
,
'O'
,
'N'
,
'B'
};
21
22
23
// //////////////////////////////////////////////////////////////////////
24
ForecastingMethod::ForecastingMethod
()
25
: _method (
LAST_VALUE
) {
26
assert (
false
);
27
}
28
29
// //////////////////////////////////////////////////////////////////////
30
ForecastingMethod::
31
ForecastingMethod (
const
ForecastingMethod
& iForecastingMethod)
32
: _method (iForecastingMethod._method) {
33
}
34
35
// //////////////////////////////////////////////////////////////////////
36
ForecastingMethod::
37
ForecastingMethod
(
const
EN_ForecastingMethod
& iForecastingMethod)
38
: _method (iForecastingMethod) {
39
}
40
41
// //////////////////////////////////////////////////////////////////////
42
ForecastingMethod::ForecastingMethod
(
const
char
iMethod) {
43
switch
(iMethod) {
44
case
'Q'
: _method =
Q_FORECASTING
;
break
;
45
case
'H'
: _method =
HYBRID_FORECASTING
;
break
;
46
case
'O'
: _method =
OLD_QFF
;
break
;
47
case
'N'
: _method =
NEW_QFF
;
break
;
48
case
'B'
: _method =
BASED_FORECASTING
;
break
;
49
default
: _method =
LAST_VALUE
;
break
;
50
}
51
52
if
(_method ==
LAST_VALUE
) {
53
const
std::string& lLabels =
describeLabels
();
54
std::ostringstream oMessage;
55
oMessage <<
"The forecasting method '"
<< iMethod
56
<<
"' is not known. Known forecasting methods: "
<< lLabels;
57
throw
CodeConversionException
(oMessage.str());
58
}
59
}
60
61
// //////////////////////////////////////////////////////////////////////
62
const
std::string&
ForecastingMethod::
63
getLabel
(
const
EN_ForecastingMethod
& iMethod) {
64
return
_labels[iMethod];
65
}
66
67
// //////////////////////////////////////////////////////////////////////
68
char
ForecastingMethod::getMethodLabel
(
const
EN_ForecastingMethod
& iMethod) {
69
return
_methodLabels[iMethod];
70
}
71
72
// //////////////////////////////////////////////////////////////////////
73
std::string
ForecastingMethod::
74
getMethodLabelAsString
(
const
EN_ForecastingMethod
& iMethod) {
75
std::ostringstream oStr;
76
oStr << _methodLabels[iMethod];
77
return
oStr.str();
78
}
79
80
// //////////////////////////////////////////////////////////////////////
81
std::string
ForecastingMethod::describeLabels
() {
82
std::ostringstream ostr;
83
for
(
unsigned
short
idx = 0; idx !=
LAST_VALUE
; ++idx) {
84
if
(idx != 0) {
85
ostr <<
", "
;
86
}
87
ostr << _labels[idx] <<
" ("
<< _methodLabels[idx] <<
")"
;
88
}
89
return
ostr.str();
90
}
91
92
// //////////////////////////////////////////////////////////////////////
93
ForecastingMethod::EN_ForecastingMethod
ForecastingMethod::getMethod
()
const
{
94
return
_method;
95
}
96
97
// //////////////////////////////////////////////////////////////////////
98
std::string
ForecastingMethod::getMethodAsString
()
const
{
99
std::ostringstream oStr;
100
oStr << _methodLabels[_method];
101
return
oStr.str();
102
}
103
104
// //////////////////////////////////////////////////////////////////////
105
const
std::string
ForecastingMethod::describe
()
const
{
106
std::ostringstream ostr;
107
ostr << _labels[_method];
108
return
ostr.str();
109
}
110
111
// //////////////////////////////////////////////////////////////////////
112
bool
ForecastingMethod::
113
operator==
(
const
EN_ForecastingMethod
& iMethod)
const
{
114
return
(_method == iMethod);
115
}
116
117
}
ForecastingMethod.hpp
stdair_exceptions.hpp
stdair
Handle on the StdAir library context.
Definition
BasChronometer.cpp:9
stdair::LOG::LAST_VALUE
@ LAST_VALUE
Definition
stdair_log.hpp:25
stdair::ForecastingMethod::getMethodLabel
static char getMethodLabel(const EN_ForecastingMethod &)
Definition
ForecastingMethod.cpp:68
stdair::ForecastingMethod::getMethodAsString
std::string getMethodAsString() const
Definition
ForecastingMethod.cpp:98
stdair::ForecastingMethod::EN_ForecastingMethod
EN_ForecastingMethod
Definition
ForecastingMethod.hpp:17
stdair::ForecastingMethod::LAST_VALUE
@ LAST_VALUE
Definition
ForecastingMethod.hpp:23
stdair::ForecastingMethod::HYBRID_FORECASTING
@ HYBRID_FORECASTING
Definition
ForecastingMethod.hpp:19
stdair::ForecastingMethod::Q_FORECASTING
@ Q_FORECASTING
Definition
ForecastingMethod.hpp:18
stdair::ForecastingMethod::OLD_QFF
@ OLD_QFF
Definition
ForecastingMethod.hpp:20
stdair::ForecastingMethod::BASED_FORECASTING
@ BASED_FORECASTING
Definition
ForecastingMethod.hpp:22
stdair::ForecastingMethod::NEW_QFF
@ NEW_QFF
Definition
ForecastingMethod.hpp:21
stdair::ForecastingMethod::ForecastingMethod
ForecastingMethod(const EN_ForecastingMethod &)
Definition
ForecastingMethod.cpp:37
stdair::ForecastingMethod::operator==
bool operator==(const EN_ForecastingMethod &) const
Definition
ForecastingMethod.cpp:113
stdair::ForecastingMethod::describeLabels
static std::string describeLabels()
Definition
ForecastingMethod.cpp:81
stdair::ForecastingMethod::getMethodLabelAsString
static std::string getMethodLabelAsString(const EN_ForecastingMethod &)
Definition
ForecastingMethod.cpp:74
stdair::ForecastingMethod::getMethod
EN_ForecastingMethod getMethod() const
Definition
ForecastingMethod.cpp:93
stdair::ForecastingMethod::getLabel
static const std::string & getLabel(const EN_ForecastingMethod &)
Definition
ForecastingMethod.cpp:63
stdair::ForecastingMethod::describe
const std::string describe() const
Definition
ForecastingMethod.cpp:105
stdair::CodeConversionException
Definition
stdair_exceptions.hpp:133
Generated for StdAir by
1.17.0