StdAir Logo  1.00.15
C++ Standard Airline IT Object Library
Loading...
Searching...
No Matches
TravelSolutionStruct.cpp
Go to the documentation of this file.
1// //////////////////////////////////////////////////////////////////////
2// Import section
3// //////////////////////////////////////////////////////////////////////
4// STL
5#include <cassert>
6#include <sstream>
7// StdAir
12
13namespace stdair {
14
15 // ////////////////////////////////////////////////////////////////////
16 TravelSolutionStruct::TravelSolutionStruct() : _chosenFareOption (NULL) {
17 }
18
19 // ////////////////////////////////////////////////////////////////////
21 _chosenFareOption = NULL;
22 }
23
24 // ////////////////////////////////////////////////////////////////////
26 TravelSolutionStruct (const TravelSolutionStruct& iTravelSolution)
27 : _segmentPath (iTravelSolution._segmentPath),
28 _classAvailabilityMapHolder (iTravelSolution._classAvailabilityMapHolder),
29 _classObjectIDMapHolder (iTravelSolution._classObjectIDMapHolder),
30 _classYieldMapHolder (iTravelSolution._classYieldMapHolder),
31 _bidPriceVectorHolder (iTravelSolution._bidPriceVectorHolder),
32 _classBpvMapHolder (iTravelSolution._classBpvMapHolder),
33 _fareOptionList (iTravelSolution._fareOptionList),
34 _chosenFareOption (iTravelSolution._chosenFareOption) {
35 }
36
37 // ////////////////////////////////////////////////////////////////////
38 void TravelSolutionStruct::toStream (std::ostream& ioOut) const {
39 ioOut << describe();
40 }
41
42 // ////////////////////////////////////////////////////////////////////
43 void TravelSolutionStruct::fromStream (std::istream& ioIn) {
44 }
45
46 // ////////////////////////////////////////////////////////////////////
48 std::ostringstream oStr;
49
50 //
51 oStr << "Segment path: ";
52 unsigned short idx = 0;
53 for (SegmentPath_T::const_iterator lItSegmentPath = _segmentPath.begin();
54 lItSegmentPath != _segmentPath.end(); ++lItSegmentPath, ++idx) {
55 if (idx != 0) {
56 oStr << " - ";
57 }
58 const std::string& lSegmentPathString = *lItSegmentPath;
59 const stdair::ParsedKey& lSegmentParsedKey =
60 stdair::BomKeyManager::extractKeys (lSegmentPathString);
61 const std::string& lSegmentKey = lSegmentParsedKey.toString();
62 oStr << lSegmentKey;
63 }
64 return oStr.str();
65 }
66
67 // ////////////////////////////////////////////////////////////////////
68 const std::string TravelSolutionStruct::describe() const {
69 std::ostringstream oStr;
70
71 //
72 oStr << "Segment path: ";
73 unsigned short idx = 0;
74 for (SegmentPath_T::const_iterator lItSegmentPath = _segmentPath.begin();
75 lItSegmentPath != _segmentPath.end(); ++lItSegmentPath, ++idx) {
76 if (idx != 0) {
77 oStr << "-";
78 }
79 const std::string& lSegmentPathString = *lItSegmentPath;
80 const stdair::ParsedKey& lSegmentParsedKey =
81 stdair::BomKeyManager::extractKeys (lSegmentPathString);
82 const std::string& lSegmentKey = lSegmentParsedKey.toString();
83 oStr << lSegmentKey;
84 }
85 oStr << " ### ";
86
87 //
88 if (_chosenFareOption != NULL) {
89 oStr << "Chosen fare option: " << _chosenFareOption->describe()
90 << " ## Among: ";
91 } else {
92 oStr << "Fare options: ";
93 }
94
95 //
96 idx = 0;
97 for (FareOptionList_T::const_iterator lItFareOption= _fareOptionList.begin();
98 lItFareOption != _fareOptionList.end(); ++lItFareOption, ++idx) {
99 if (idx != 0) {
100 oStr << " , ";
101 }
102 const FareOptionStruct& lFareOption = *lItFareOption;
103 oStr << lFareOption.describe();
104 }
105
106 return oStr.str();
107 }
108
109 // ////////////////////////////////////////////////////////////////////
110 const std::string TravelSolutionStruct::display() const {
111 std::ostringstream oStr;
112
113 // List of segment keys (one per segment)
114 unsigned short idx = 0;
115 for (SegmentPath_T::const_iterator itSegPath = _segmentPath.begin();
116 itSegPath != _segmentPath.end(); ++itSegPath, ++idx) {
117 if (idx != 0) {
118 oStr << " ; ";
119 }
120 const std::string& lSegmentPathString = *itSegPath;
121 const stdair::ParsedKey& lSegmentParsedKey =
122 stdair::BomKeyManager::extractKeys (lSegmentPathString);
123 const std::string& lSegmentKey = lSegmentParsedKey.toString();
124 oStr << "[" << idx << "] " << lSegmentKey;
125 }
126
127 // List of fare options (for the whole O&D)
128 oStr << " --- ";
129 idx = 0;
130 for (FareOptionList_T::const_iterator itFareOption = _fareOptionList.begin();
131 itFareOption != _fareOptionList.end(); ++itFareOption, ++idx) {
132 if (idx != 0) {
133 oStr << " , ";
134 }
135 const FareOptionStruct& lFareOption = *itFareOption;
136 oStr << lFareOption.display();
137 }
138
139 // List of booking class availability maps: one map per segment
140 oStr << " --- ";
141 for (ClassAvailabilityMapHolder_T::const_iterator itSegMap =
142 _classAvailabilityMapHolder.begin();
143 itSegMap != _classAvailabilityMapHolder.end(); ++itSegMap, ++idx) {
144 if (idx != 0) {
145 oStr << " ; ";
146 }
147
148 // Retrieve the booking class availability map
149 const ClassAvailabilityStruct& lClassAvlMap = *itSegMap;
150 oStr << "[" << idx << "] ";
151
152 const std::string lClassAvlMapString = lClassAvlMap.describe();
153 oStr << lClassAvlMapString;
154 }
155
156 return oStr.str();
157 }
158
159 // ////////////////////////////////////////////////////////////////////
160 void TravelSolutionStruct::addSegment (const std::string& iKey) {
161 _segmentPath.push_back (iKey);
162 }
163
164 // ////////////////////////////////////////////////////////////////////
167 const ClassAvailabilityStruct lClassAvlStruct (iClassAvlMap);
168 _classAvailabilityMapHolder.push_back (lClassAvlStruct);
169 }
170
171 // ////////////////////////////////////////////////////////////////////
174 _classObjectIDMapHolder.push_back (iMap);
175 }
176
177 // ////////////////////////////////////////////////////////////////////
180 _classYieldMapHolder.push_back (iMap);
181 }
182
183 // ////////////////////////////////////////////////////////////////////
186 _bidPriceVectorHolder.push_back (iBpv);
187 }
188
189 // ////////////////////////////////////////////////////////////////////
191 addClassBpvMap (const ClassBpvMap_T& iMap) {
192 _classBpvMapHolder.push_back (iMap);
193 }
194
195 // ////////////////////////////////////////////////////////////////////
197 addFareOption (const FareOptionStruct& iFareOption) {
198 _fareOptionList.push_back (iFareOption);
199 }
200
201}
Handle on the StdAir library context.
std::map< const ClassCode_T, Availability_T > ClassAvailabilityMap_T
std::map< const ClassCode_T, YieldValue_T > ClassYieldMap_T
std::map< const ClassCode_T, const BidPriceVector_T * > ClassBpvMap_T
std::vector< BidPrice_T > BidPriceVector_T
std::map< const ClassCode_T, BookingClassID_T > ClassObjectIDMap_T
static ParsedKey extractKeys(const std::string &iFullKeyStr)
Structure holding the elements of a travel solution.
Structure holding the elements of a fare option.
const std::string display() const
const std::string describe() const
const std::string toString() const
Structure holding the elements of a travel solution.
void addSegment(const std::string &)
void addClassYieldMap(const ClassYieldMap_T &)
void addBidPriceVector(const BidPriceVector_T &)
void toStream(std::ostream &ioOut) const
void addClassObjectIDMap(const ClassObjectIDMap_T &)
void addFareOption(const FareOptionStruct &)
const std::string display() const
const std::string describe() const
void addClassBpvMap(const ClassBpvMap_T &)
void addClassAvailabilityMap(const ClassAvailabilityMap_T &)
const std::string describeSegmentPath() const
void fromStream(std::istream &ioIn)