StdAir Logo  1.00.13
C++ Standard Airline IT Object Library
Loading...
Searching...
No Matches
SampleType.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 SampleType::_labels[LAST_VALUE] =
15 { "All", "AllForPartnerships", "RevenueManagement", "Inventory", "Schedule",
16 "RevenueAccounting", "FareQuote", "CRS", "DemandGeneration", "EventManagement",
17 "CustomerChoice" };
18
19 // //////////////////////////////////////////////////////////////////////
20 const char SampleType::
21 _typeLabels[LAST_VALUE] = { 'A', 'P', 'R', 'I', 'S', 'T', 'F', 'C', 'D', 'E', 'M' };
22
23
24 // //////////////////////////////////////////////////////////////////////
25 SampleType::SampleType()
26 : _type (LAST_VALUE) {
27 assert (false);
28 }
29
30 // //////////////////////////////////////////////////////////////////////
31 SampleType::SampleType (const SampleType& iSampleType)
32 : _type (iSampleType._type) {
33 }
34
35 // //////////////////////////////////////////////////////////////////////
36 SampleType::SampleType (const EN_SampleType& iSampleType)
37 : _type (iSampleType) {
38 }
39
40 // //////////////////////////////////////////////////////////////////////
41 SampleType::SampleType (const char iType) {
42 switch (iType) {
43 case 'A': _type = ALL; break;
44 case 'P': _type = A4P; break;
45 case 'R': _type = RMS; break;
46 case 'I': _type = INV; break;
47 case 'S': _type = SCH; break;
48 case 'T': _type = RAC; break;
49 case 'F': _type = FQT; break;
50 case 'C': _type = CRS; break;
51 case 'D': _type = DEM; break;
52 case 'E': _type = EVT; break;
53 case 'M': _type = CCM; break;
54 default: _type = LAST_VALUE; break;
55 }
56
57 if (_type == LAST_VALUE) {
58 const std::string& lLabels = describeLabels();
59 std::ostringstream oMessage;
60 oMessage << "The sample type '" << iType
61 << "' is not known. Known sample types: " << lLabels;
62 throw CodeConversionException (oMessage.str());
63 }
64 }
65
66 // //////////////////////////////////////////////////////////////////////
67 const std::string& SampleType::getLabel (const EN_SampleType& iType) {
68 return _labels[iType];
69 }
70
71 // //////////////////////////////////////////////////////////////////////
73 return _typeLabels[iType];
74 }
75
76 // //////////////////////////////////////////////////////////////////////
78 std::ostringstream oStr;
79 oStr << _typeLabels[iType];
80 return oStr.str();
81 }
82
83 // //////////////////////////////////////////////////////////////////////
85 std::ostringstream ostr;
86 for (unsigned short idx = 0; idx != LAST_VALUE; ++idx) {
87 if (idx != 0) {
88 ostr << ", ";
89 }
90 ostr << _labels[idx];
91 }
92 return ostr.str();
93 }
94
95 // //////////////////////////////////////////////////////////////////////
97 return _type;
98 }
99
100 // //////////////////////////////////////////////////////////////////////
101 std::string SampleType::getTypeAsString() const {
102 std::ostringstream oStr;
103 oStr << _typeLabels[_type];
104 return oStr.str();
105 }
106
107 // //////////////////////////////////////////////////////////////////////
108 const std::string SampleType::describe() const {
109 std::ostringstream ostr;
110 ostr << _labels[_type];
111 return ostr.str();
112 }
113
114 // //////////////////////////////////////////////////////////////////////
115 bool SampleType::operator== (const EN_SampleType& iType) const {
116 return (_type == iType);
117 }
118
119}
Handle on the StdAir library context.
Enumeration of BOM sample types.
static std::string describeLabels()
bool operator==(const EN_SampleType &) const
const std::string describe() const
EN_SampleType getType() const
static char getTypeLabel(const EN_SampleType &)
static const std::string & getLabel(const EN_SampleType &)
std::string getTypeAsString() const
static std::string getTypeLabelAsString(const EN_SampleType &)