StdAir Logo  1.00.19
C++ Standard Airline IT Object Library
Loading...
Searching...
No Matches
PartnershipTechnique.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 PartnershipTechnique::_labels[LAST_VALUE] =
15 { "None",
16 "RevenueAvailabilityExchangeDemandAggregation",
17 "RevenueAvailabilityExchangeYieldProration",
18 "InterlineBidPriceDemandAggregation",
19 "InterlineBidPriceYieldProration",
20 "NonProtectionistInterlineBidPriceYieldProration",
21 "RevenueManagementCooperation",
22 "AdvancedRevenueManagementCooperation"};
23
24 // //////////////////////////////////////////////////////////////////////
25 const char PartnershipTechnique::_techniqueLabels[LAST_VALUE] = { 'N',
26 'r',
27 'R',
28 'i',
29 'I',
30 'U',
31 'C',
32 'A'};
33
34
35 // //////////////////////////////////////////////////////////////////////
37 assert (false);
38 }
39
40 // //////////////////////////////////////////////////////////////////////
41 PartnershipTechnique::
42 PartnershipTechnique (const PartnershipTechnique& iPartnershipTechnique)
43 : _technique (iPartnershipTechnique._technique) {
44 }
45
46 // //////////////////////////////////////////////////////////////////////
47 PartnershipTechnique::
48 PartnershipTechnique (const EN_PartnershipTechnique& iPartnershipTechnique)
49 : _technique (iPartnershipTechnique) {
50 }
51
52 // //////////////////////////////////////////////////////////////////////
54 PartnershipTechnique::getTechnique (const char iTechniqueChar) {
55 EN_PartnershipTechnique oTechnique;
56 switch (iTechniqueChar) {
57 case 'N': oTechnique = NONE; break;
58 case 'r': oTechnique = RAE_DA; break;
59 case 'R': oTechnique = RAE_YP; break;
60 case 'i': oTechnique = IBP_DA; break;
61 case 'I': oTechnique = IBP_YP; break;
62 case 'U': oTechnique = IBP_YP_U; break;
63 case 'C': oTechnique = RMC; break;
64 case 'A': oTechnique = A_RMC; break;
65 default: oTechnique = LAST_VALUE; break;
66 }
67
68 if (oTechnique == LAST_VALUE) {
69 const std::string& lLabels = describeLabels();
70 std::ostringstream oMessage;
71 oMessage << "The partnership technique '"
72 << iTechniqueChar
73 << "' is not known. Known partnership techniques: "
74 << lLabels;
75 throw CodeConversionException (oMessage.str());
76 }
77
78 return oTechnique;
79 }
80
81 // //////////////////////////////////////////////////////////////////////
83 : _technique (getTechnique (iTechniqueChar)) {
84 }
85
86 // //////////////////////////////////////////////////////////////////////
87 PartnershipTechnique::
88 PartnershipTechnique (const std::string& iTechniqueStr) {
89 //
90 const size_t lSize = iTechniqueStr.size();
91 assert (lSize == 1);
92 const char lTechniqueChar = iTechniqueStr[0];
93 _technique = getTechnique (lTechniqueChar);
94 }
95
96 // //////////////////////////////////////////////////////////////////////
97 const std::string& PartnershipTechnique::
98 getLabel (const EN_PartnershipTechnique& iTechnique) {
99 return _labels[iTechnique];
100 }
101
102 // //////////////////////////////////////////////////////////////////////
105 return _techniqueLabels[iTechnique];
106 }
107
108 // //////////////////////////////////////////////////////////////////////
111 std::ostringstream oStr;
112 oStr << _techniqueLabels[iTechnique];
113 return oStr.str();
114 }
115
116 // //////////////////////////////////////////////////////////////////////
118 std::ostringstream ostr;
119 for (unsigned short idx = 0; idx != LAST_VALUE; ++idx) {
120 if (idx != 0) {
121 ostr << ", ";
122 }
123 ostr << _labels[idx] << " (" << _techniqueLabels[idx] << ")";
124 }
125 return ostr.str();
126 }
127
128 // //////////////////////////////////////////////////////////////////////
131 return _technique;
132 }
133
134 // //////////////////////////////////////////////////////////////////////
136 const char oTechniqueChar = _techniqueLabels[_technique];
137 return oTechniqueChar;
138 }
139
140 // //////////////////////////////////////////////////////////////////////
142 std::ostringstream oStr;
143 oStr << _techniqueLabels[_technique];
144 return oStr.str();
145 }
146
147 // //////////////////////////////////////////////////////////////////////
148 const std::string PartnershipTechnique::describe() const {
149 std::ostringstream ostr;
150 ostr << _labels[_technique];
151 return ostr.str();
152 }
153
154 // //////////////////////////////////////////////////////////////////////
156 operator== (const EN_PartnershipTechnique& iTechnique) const {
157 return (_technique == iTechnique);
158 }
159
160}
Handle on the StdAir library context.
const std::string describe() const
bool operator==(const EN_PartnershipTechnique &) const
EN_PartnershipTechnique getTechnique() const
static std::string getTechniqueLabelAsString(const EN_PartnershipTechnique &)
static char getTechniqueLabel(const EN_PartnershipTechnique &)
static EN_PartnershipTechnique getTechnique(const char)
PartnershipTechnique(const EN_PartnershipTechnique &)
static const std::string & getLabel(const EN_PartnershipTechnique &)