StdAir Logo  1.00.19
C++ Standard Airline IT Object Library
Loading...
Searching...
No Matches
PreOptimisationMethod.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 PreOptimisationMethod::_labels[LAST_VALUE] =
15 {"None", "Fare Adjustment", "Marginal Revenue Transformation"};
16
17 // //////////////////////////////////////////////////////////////////////
18 const char PreOptimisationMethod::
19 _methodLabels[LAST_VALUE] = {'N', 'F', 'M'};
20
21
22 // //////////////////////////////////////////////////////////////////////
24 : _method (LAST_VALUE) {
25 assert (false);
26 }
27
28 // //////////////////////////////////////////////////////////////////////
29 PreOptimisationMethod::
30 PreOptimisationMethod (const PreOptimisationMethod& iPreOptimisationMethod)
31 : _method (iPreOptimisationMethod._method) {
32 }
33
34 // //////////////////////////////////////////////////////////////////////
35 PreOptimisationMethod::
36 PreOptimisationMethod (const EN_PreOptimisationMethod& iPreOptimisationMethod)
37 : _method (iPreOptimisationMethod) {
38 }
39
40 // //////////////////////////////////////////////////////////////////////
42 switch (iMethod) {
43 case 'N': _method = NONE; break;
44 case 'F': _method = FA; break;
45 case 'M': _method = MRT; break;
46 default: _method = LAST_VALUE; break;
47 }
48
49 if (_method == LAST_VALUE) {
50 const std::string& lLabels = describeLabels();
51 std::ostringstream oMessage;
52 oMessage << "The pre-optimisation method '" << iMethod
53 << "' is not known. Known pre-optimisation methods: " << lLabels;
54 throw CodeConversionException (oMessage.str());
55 }
56 }
57
58 // //////////////////////////////////////////////////////////////////////
59 const std::string& PreOptimisationMethod::
60 getLabel (const EN_PreOptimisationMethod& iMethod) {
61 return _labels[iMethod];
62 }
63
64 // //////////////////////////////////////////////////////////////////////
66 return _methodLabels[iMethod];
67 }
68
69 // //////////////////////////////////////////////////////////////////////
72 std::ostringstream oStr;
73 oStr << _methodLabels[iMethod];
74 return oStr.str();
75 }
76
77 // //////////////////////////////////////////////////////////////////////
79 std::ostringstream ostr;
80 for (unsigned short idx = 0; idx != LAST_VALUE; ++idx) {
81 if (idx != 0) {
82 ostr << ", ";
83 }
84 ostr << _labels[idx] << " (" << _methodLabels[idx] << ")";
85 }
86 return ostr.str();
87 }
88
89 // //////////////////////////////////////////////////////////////////////
93
94 // //////////////////////////////////////////////////////////////////////
96 std::ostringstream oStr;
97 oStr << _methodLabels[_method];
98 return oStr.str();
99 }
100
101 // //////////////////////////////////////////////////////////////////////
102 const std::string PreOptimisationMethod::describe() const {
103 std::ostringstream ostr;
104 ostr << _labels[_method];
105 return ostr.str();
106 }
107
108 // //////////////////////////////////////////////////////////////////////
110 operator== (const EN_PreOptimisationMethod& iMethod) const {
111 return (_method == iMethod);
112 }
113
114}
Handle on the StdAir library context.
static const std::string & getLabel(const EN_PreOptimisationMethod &)
PreOptimisationMethod(const EN_PreOptimisationMethod &)
bool operator==(const EN_PreOptimisationMethod &) const
EN_PreOptimisationMethod getMethod() const
static std::string getMethodLabelAsString(const EN_PreOptimisationMethod &)
static char getMethodLabel(const EN_PreOptimisationMethod &)