AirInv Logo  1.00.7
C++ Simulated Airline Inventory Management System Library
DCPEventStruct.cpp
Go to the documentation of this file.
1// //////////////////////////////////////////////////////////////////////
2// Import section
3// //////////////////////////////////////////////////////////////////////
4// STL
5#include <cassert>
6#include <sstream>
7#include <vector>
8// StdAir
9#include <stdair/basic/BasConst_General.hpp>
10#include <stdair/service/Logger.hpp>
11// AirInv
14
15namespace AIRINV {
16
17 // ////////////////////////////////////////////////////////////////////
19 : _origin(""),
20 _destination(""),
21 _dateRangeStart(stdair::DEFAULT_DATE),
22 _dateRangeEnd(stdair::DEFAULT_DATE),
23 _timeRangeStart(stdair::DEFAULT_EPSILON_DURATION),
24 _timeRangeEnd(stdair::DEFAULT_EPSILON_DURATION),
25 _cabinCode (""),
26 _pos (""),
27 _advancePurchase(0),
28 _saturdayStay("T"),
29 _changeFees("T"),
30 _nonRefundable("T"),
31 _minimumStay(0),
32 _DCP(0),
33 _airlineCode(""),
34 _classCode("") {
35 }
36
37 // ////////////////////////////////////////////////////////////////////
38 stdair::Date_T DCPEventStruct::getDate() const {
39 _itYear.check(); _itMonth.check(); _itDay.check();
40 return stdair::Date_T (_itYear._value, _itMonth._value, _itDay._value);
41 }
42
43 // ////////////////////////////////////////////////////////////////////
44 stdair::Duration_T DCPEventStruct::getTime() const {
45 _itHours.check(); _itMinutes.check(); _itSeconds.check();
46 return boost::posix_time::hours (_itHours._value)
47 + boost::posix_time::minutes (_itMinutes._value)
48 + boost::posix_time::seconds (_itSeconds._value);
49 }
50
51
52 // ////////////////////////////////////////////////////////////////////
53 const std::string DCPEventStruct::describe () const {
54 std::ostringstream ostr;
55 ostr << "DCPEvent: "
56 << _origin << "-" << _destination
57 << ", POS(" << _pos << "), ["
58 << _dateRangeStart << "/" << _dateRangeEnd << "] - ["
59 << boost::posix_time::to_simple_string(_timeRangeStart) << "/"
60 << boost::posix_time::to_simple_string(_timeRangeEnd) << "]\n "
61 << "-Cabin code- " << _cabinCode << "\n "
62 << "-Channel- " << _channel << "\n "
63 << "-Conditions- " << _saturdayStay << ", " << _changeFees << ", "
64 << _nonRefundable << ", " << _advancePurchase << ", "
65 << _minimumStay << "\n "
66 << "-DCP- " << _DCP << "\n ";
67 assert (_airlineCodeList.size() == _classCodeList.size());
68 stdair::ClassList_StringList_T::const_iterator lItCurrentClassCode =
69 _classCodeList.begin();
70 stdair::AirlineCode_T lAirlineCode;
71 std::string lClassCode;
72 for (stdair::AirlineCodeList_T::const_iterator lItCurrentAirlineCode =
73 _airlineCodeList.begin();
74 lItCurrentAirlineCode != _airlineCodeList.end();
75 lItCurrentAirlineCode++) {
76 lAirlineCode = *lItCurrentAirlineCode;
77 lClassCode = *lItCurrentClassCode;
78 ostr << lAirlineCode << ", " << lClassCode;
79 ostr << " ";
80 lItCurrentClassCode++;
81 }
82 ostr << std::endl;
83 return ostr.str();
84 }
85
86 // //////////////////////////////////////////////////////////////////////
87 const stdair::AirlineCode_T& DCPEventStruct::getFirstAirlineCode () const {
88 assert (_airlineCodeList.size() > 0);
89 stdair::AirlineCodeList_T::const_iterator itFirstAirlineCode =
90 _airlineCodeList.begin();
91 return *itFirstAirlineCode;
92 }
93
94 // //////////////////////////////////////////////////////////////////////
97 }
98
99 // //////////////////////////////////////////////////////////////////////
101 bool result = (_itCurrentAirlineCode != _airlineCodeList.end());
102 return result;
103 }
104
105 // //////////////////////////////////////////////////////////////////////
106 stdair::AirlineCode_T DCPEventStruct::getCurrentAirlineCode () const {
107 assert (_itCurrentAirlineCode != _airlineCodeList.end());
108 return (*_itCurrentAirlineCode);
109 }
110
111 // //////////////////////////////////////////////////////////////////////
115 }
116 }
117
118 // //////////////////////////////////////////////////////////////////////
119 const std::string& DCPEventStruct::getFirstClassCode () const {
120 assert (_classCodeList.size() > 0);
121 stdair::ClassList_StringList_T::const_iterator itFirstClassCode =
122 _classCodeList.begin();
123 return *itFirstClassCode;
124 }
125
126 // //////////////////////////////////////////////////////////////////////
129 }
130
131 // //////////////////////////////////////////////////////////////////////
133 bool result = (_itCurrentClassCode != _classCodeList.end());
134 return result;
135 }
136
137 // //////////////////////////////////////////////////////////////////////
139 assert (_itCurrentClassCode != _classCodeList.end());
140 return (*_itCurrentClassCode);
141 }
142
143
144 // //////////////////////////////////////////////////////////////////////
146 if (_itCurrentClassCode != _classCodeList.end()) {
148 }
149 }
150
151}
152
Forward declarations.
stdair::DayDuration_T _advancePurchase
stdair::Duration_T _timeRangeStart
stdair::Duration_T getTime() const
stdair::ClassList_StringList_T::iterator _itCurrentClassCode
stdair::minute_t _itMinutes
bool hasNotReachedEndAirline() const
stdair::SaturdayStay_T _saturdayStay
stdair::ChangeFees_T _changeFees
stdair::NonRefundable_T _nonRefundable
stdair::Date_T getDate() const
stdair::CityCode_T _pos
bool hasNotReachedEndClassCode() const
stdair::PriceValue_T _DCP
stdair::ChannelLabel_T _channel
stdair::AirlineCode_T getCurrentAirlineCode() const
stdair::AirportCode_T _destination
stdair::ClassList_StringList_T _classCodeList
stdair::AirlineCodeList_T _airlineCodeList
std::string getCurrentClassCode() const
stdair::Date_T _dateRangeEnd
stdair::Duration_T _timeRangeEnd
stdair::month_t _itMonth
stdair::Date_T _dateRangeStart
const stdair::AirlineCode_T & getFirstAirlineCode() const
const std::string describe() const
stdair::DayDuration_T _minimumStay
stdair::CabinCode_T _cabinCode
stdair::AirlineCodeList_T::iterator _itCurrentAirlineCode
stdair::second_t _itSeconds
const std::string & getFirstClassCode() const
stdair::AirportCode_T _origin