StdAir Logo  1.00.10
C++ Standard Airline IT Object Library
FareOptionStruct.cpp
Go to the documentation of this file.
1 // //////////////////////////////////////////////////////////////////////
2 // Import section
3 // //////////////////////////////////////////////////////////////////////
4 // STL
5 #include <cassert>
6 #include <sstream>
7 // StdAir
10 
11 namespace stdair {
12 
13  // ////////////////////////////////////////////////////////////////////
15  : _fare (DEFAULT_FARE_VALUE), _avl (DEFAULT_AVAILABILITY) {
16  }
17 
18  // ////////////////////////////////////////////////////////////////////
20  : _classPath (iFO._classPath),
21  _fare (iFO._fare), _avl (iFO._avl), _changeFee (iFO._changeFee),
22  _nonRefundable (iFO._nonRefundable), _saturdayStay (iFO._saturdayStay) {
23  }
24 
25  // ////////////////////////////////////////////////////////////////////
26  FareOptionStruct::FareOptionStruct (const std::string& iClassPath,
27  const Fare_T& iFare,
28  const ChangeFees_T& iChangeFee,
29  const NonRefundable_T& iNonRefundable,
30  const SaturdayStay_T& iSaturdayNightStay)
31  : _fare (iFare), _avl (DEFAULT_AVAILABILITY),
32  _changeFee (iChangeFee), _nonRefundable (iNonRefundable),
33  _saturdayStay (iSaturdayNightStay) {
34  _classPath.push_back (iClassPath);
35  }
36 
37  // ////////////////////////////////////////////////////////////////////
39  }
40 
41  // ////////////////////////////////////////////////////////////////////
42  void FareOptionStruct::toStream (std::ostream& ioOut) const {
43  ioOut << describe();
44  }
45 
46  // ////////////////////////////////////////////////////////////////////
47  void FareOptionStruct::fromStream (std::istream& ioIn) {
48  }
49 
50  // ////////////////////////////////////////////////////////////////////
51  const std::string FareOptionStruct::describe() const {
52  std::ostringstream oStr;
53 
54  oStr << "Class path: ";
55  unsigned short idx = 0;
56  for (ClassList_StringList_T::const_iterator itClassPath =
57  _classPath.begin(); itClassPath != _classPath.end();
58  ++itClassPath, ++idx) {
59  if (idx != 0) {
60  oStr << "-";
61  }
62  const std::string& lClassPath = *itClassPath;
63  oStr << lClassPath;
64  }
65 
66  oStr << "; " << _fare << " EUR";
67  oStr << "; conditions: " << _changeFee << " " << _nonRefundable
68  << " " << _saturdayStay;
69  return oStr.str();
70  }
71 
72  // ////////////////////////////////////////////////////////////////////
73  const std::string FareOptionStruct::display() const {
74  std::ostringstream oStr;
75 
76  unsigned short idx = 0;
77  for (ClassList_StringList_T::const_iterator itClassPath =
78  _classPath.begin(); itClassPath != _classPath.end();
79  ++itClassPath, ++idx) {
80  if (idx != 0) {
81  oStr << "-";
82  }
83  const std::string& lClassPath = *itClassPath;
84  oStr << lClassPath;
85  }
86 
87  oStr << ", " << _fare << ", " << _changeFee << " " << _nonRefundable
88  << " " << _saturdayStay;
89  return oStr.str();
90  }
91 
92  // ////////////////////////////////////////////////////////////////////
93  void FareOptionStruct::addClassList (const std::string iClassCodeList) {
94  _classPath.push_back (iClassCodeList);
95  }
96 
97  // ////////////////////////////////////////////////////////////////////
99  _classPath.clear();
100  }
101 
102 }
stdair::SaturdayStay_T
bool SaturdayStay_T
Definition: stdair_date_time_types.hpp:41
FareOptionStruct.hpp
stdair::FareOptionStruct::emptyClassList
void emptyClassList()
Definition: FareOptionStruct.cpp:98
stdair::DEFAULT_FARE_VALUE
const Fare_T DEFAULT_FARE_VALUE
Definition: BasConst_General.hpp:36
stdair::FareOptionStruct::addClassList
void addClassList(const std::string)
Definition: FareOptionStruct.cpp:93
stdair::FareOptionStruct
Structure holding the elements of a fare option.
Definition: FareOptionStruct.hpp:20
stdair::Fare_T
double Fare_T
Definition: stdair_basic_types.hpp:126
stdair::FareOptionStruct::toStream
void toStream(std::ostream &ioOut) const
Definition: FareOptionStruct.cpp:42
stdair
Handle on the StdAir library context.
Definition: BasChronometer.cpp:9
stdair::FareOptionStruct::display
const std::string display() const
Definition: FareOptionStruct.cpp:73
stdair::FareOptionStruct::FareOptionStruct
FareOptionStruct()
Definition: FareOptionStruct.cpp:14
BasConst_BookingClass.hpp
stdair::NonRefundable_T
bool NonRefundable_T
Definition: stdair_demand_types.hpp:27
stdair::FareOptionStruct::~FareOptionStruct
~FareOptionStruct()
Definition: FareOptionStruct.cpp:38
stdair::FareOptionStruct::fromStream
void fromStream(std::istream &ioIn)
Definition: FareOptionStruct.cpp:47
stdair::DEFAULT_AVAILABILITY
const Availability_T DEFAULT_AVAILABILITY
stdair::ChangeFees_T
bool ChangeFees_T
Definition: stdair_demand_types.hpp:24
stdair::FareOptionStruct::describe
const std::string describe() const
Definition: FareOptionStruct.cpp:51