1.00.26
C++ Standard Airline IT Object Library
Toggle main menu visibility
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
8
#include <
stdair/basic/BasConst_BookingClass.hpp
>
9
#include <
stdair/bom/TravelSolutionStruct.hpp
>
10
#include <
stdair/bom/BomKeyManager.hpp
>
11
#include <
stdair/bom/ParsedKey.hpp
>
12
13
namespace
stdair
{
14
15
// ////////////////////////////////////////////////////////////////////
16
TravelSolutionStruct::TravelSolutionStruct
() : _chosenFareOption (NULL) {
17
}
18
19
// ////////////////////////////////////////////////////////////////////
20
TravelSolutionStruct::~TravelSolutionStruct
() {
21
_chosenFareOption = NULL;
22
}
23
24
// ////////////////////////////////////////////////////////////////////
25
TravelSolutionStruct::
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
// ////////////////////////////////////////////////////////////////////
47
const
std::string
TravelSolutionStruct::describeSegmentPath
()
const
{
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
// ////////////////////////////////////////////////////////////////////
165
void
TravelSolutionStruct::
166
addClassAvailabilityMap
(
const
ClassAvailabilityMap_T
& iClassAvlMap) {
167
const
ClassAvailabilityStruct
lClassAvlStruct (iClassAvlMap);
168
_classAvailabilityMapHolder.push_back (lClassAvlStruct);
169
}
170
171
// ////////////////////////////////////////////////////////////////////
172
void
TravelSolutionStruct::
173
addClassObjectIDMap
(
const
ClassObjectIDMap_T
& iMap) {
174
_classObjectIDMapHolder.push_back (iMap);
175
}
176
177
// ////////////////////////////////////////////////////////////////////
178
void
TravelSolutionStruct::
179
addClassYieldMap
(
const
ClassYieldMap_T
& iMap) {
180
_classYieldMapHolder.push_back (iMap);
181
}
182
183
// ////////////////////////////////////////////////////////////////////
184
void
TravelSolutionStruct::
185
addBidPriceVector
(
const
BidPriceVector_T
& iBpv) {
186
_bidPriceVectorHolder.push_back (iBpv);
187
}
188
189
// ////////////////////////////////////////////////////////////////////
190
void
TravelSolutionStruct::
191
addClassBpvMap
(
const
ClassBpvMap_T
& iMap) {
192
_classBpvMapHolder.push_back (iMap);
193
}
194
195
// ////////////////////////////////////////////////////////////////////
196
void
TravelSolutionStruct::
197
addFareOption
(
const
FareOptionStruct
& iFareOption) {
198
_fareOptionList.push_back (iFareOption);
199
}
200
201
}
BasConst_BookingClass.hpp
BomKeyManager.hpp
ParsedKey.hpp
TravelSolutionStruct.hpp
stdair
Handle on the StdAir library context.
Definition
BasChronometer.cpp:9
stdair::ClassAvailabilityMap_T
std::map< const ClassCode_T, Availability_T > ClassAvailabilityMap_T
Definition
ClassAvailabilityStruct.hpp:21
stdair::ClassYieldMap_T
std::map< const ClassCode_T, YieldValue_T > ClassYieldMap_T
Definition
TravelSolutionTypes.hpp:38
stdair::ClassBpvMap_T
std::map< const ClassCode_T, const BidPriceVector_T * > ClassBpvMap_T
Definition
TravelSolutionTypes.hpp:47
stdair::BidPriceVector_T
std::vector< BidPrice_T > BidPriceVector_T
Definition
stdair_inventory_types.hpp:128
stdair::ClassObjectIDMap_T
std::map< const ClassCode_T, BookingClassID_T > ClassObjectIDMap_T
Definition
TravelSolutionTypes.hpp:32
stdair::BomKeyManager::extractKeys
static ParsedKey extractKeys(const std::string &iFullKeyStr)
Definition
BomKeyManager.cpp:31
stdair::ClassAvailabilityStruct
Structure holding the elements of a travel solution.
Definition
ClassAvailabilityStruct.hpp:32
stdair::ClassAvailabilityStruct::describe
const std::string describe() const
Definition
ClassAvailabilityStruct.cpp:42
stdair::FareOptionStruct
Structure holding the elements of a fare option.
Definition
FareOptionStruct.hpp:20
stdair::FareOptionStruct::display
const std::string display() const
Definition
FareOptionStruct.cpp:73
stdair::FareOptionStruct::describe
const std::string describe() const
Definition
FareOptionStruct.cpp:51
stdair::ParsedKey
Definition
ParsedKey.hpp:22
stdair::ParsedKey::toString
const std::string toString() const
Definition
ParsedKey.cpp:139
stdair::TravelSolutionStruct::addSegment
void addSegment(const std::string &)
Definition
TravelSolutionStruct.cpp:160
stdair::TravelSolutionStruct::addClassYieldMap
void addClassYieldMap(const ClassYieldMap_T &)
Definition
TravelSolutionStruct.cpp:179
stdair::TravelSolutionStruct::addBidPriceVector
void addBidPriceVector(const BidPriceVector_T &)
Definition
TravelSolutionStruct.cpp:185
stdair::TravelSolutionStruct::toStream
void toStream(std::ostream &ioOut) const
Definition
TravelSolutionStruct.cpp:38
stdair::TravelSolutionStruct::addClassObjectIDMap
void addClassObjectIDMap(const ClassObjectIDMap_T &)
Definition
TravelSolutionStruct.cpp:173
stdair::TravelSolutionStruct::TravelSolutionStruct
TravelSolutionStruct()
Definition
TravelSolutionStruct.cpp:16
stdair::TravelSolutionStruct::addFareOption
void addFareOption(const FareOptionStruct &)
Definition
TravelSolutionStruct.cpp:197
stdair::TravelSolutionStruct::display
const std::string display() const
Definition
TravelSolutionStruct.cpp:110
stdair::TravelSolutionStruct::~TravelSolutionStruct
~TravelSolutionStruct()
Definition
TravelSolutionStruct.cpp:20
stdair::TravelSolutionStruct::describe
const std::string describe() const
Definition
TravelSolutionStruct.cpp:68
stdair::TravelSolutionStruct::addClassBpvMap
void addClassBpvMap(const ClassBpvMap_T &)
Definition
TravelSolutionStruct.cpp:191
stdair::TravelSolutionStruct::addClassAvailabilityMap
void addClassAvailabilityMap(const ClassAvailabilityMap_T &)
Definition
TravelSolutionStruct.cpp:166
stdair::TravelSolutionStruct::describeSegmentPath
const std::string describeSegmentPath() const
Definition
TravelSolutionStruct.cpp:47
stdair::TravelSolutionStruct::fromStream
void fromStream(std::istream &ioIn)
Definition
TravelSolutionStruct.cpp:43
Generated for StdAir by
1.17.0