StdAir Logo  1.00.21
C++ Standard Airline IT Object Library
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
10
11namespace 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 // //////////////////////////////////////////////////////////////////////
25 : _method (LAST_VALUE) {
26 assert (false);
27 }
28
29 // //////////////////////////////////////////////////////////////////////
30 ForecastingMethod::
31 ForecastingMethod (const ForecastingMethod& iForecastingMethod)
32 : _method (iForecastingMethod._method) {
33 }
34
35 // //////////////////////////////////////////////////////////////////////
37 ForecastingMethod (const EN_ForecastingMethod& iForecastingMethod)
38 : _method (iForecastingMethod) {
39 }
40
41 // //////////////////////////////////////////////////////////////////////
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 // //////////////////////////////////////////////////////////////////////
69 return _methodLabels[iMethod];
70 }
71
72 // //////////////////////////////////////////////////////////////////////
75 std::ostringstream oStr;
76 oStr << _methodLabels[iMethod];
77 return oStr.str();
78 }
79
80 // //////////////////////////////////////////////////////////////////////
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 // //////////////////////////////////////////////////////////////////////
96
97 // //////////////////////////////////////////////////////////////////////
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 // //////////////////////////////////////////////////////////////////////
113 operator== (const EN_ForecastingMethod& iMethod) const {
114 return (_method == iMethod);
115 }
116
117}
Handle on the StdAir library context.
static char getMethodLabel(const EN_ForecastingMethod &)
std::string getMethodAsString() const
ForecastingMethod(const EN_ForecastingMethod &)
bool operator==(const EN_ForecastingMethod &) const
static std::string describeLabels()
static std::string getMethodLabelAsString(const EN_ForecastingMethod &)
EN_ForecastingMethod getMethod() const
static const std::string & getLabel(const EN_ForecastingMethod &)
const std::string describe() const