SimFQT Logo  1.00.6
C++ Simulated Fare Quote System Library
Loading...
Searching...
No Matches
FareRuleStruct.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// SIMFQT
13
14namespace SIMFQT {
15
16 // ////////////////////////////////////////////////////////////////////
18 :_fareId(0),
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 _fare(0),
33 _airlineCode(""),
34 _classCode("") {
35
36 }
37
38 // ////////////////////////////////////////////////////////////////////
39 stdair::Date_T FareRuleStruct::calculateDate() const {
40 _itYear.check(); _itMonth.check(); _itDay.check();
41 return stdair::Date_T (_itYear._value, _itMonth._value, _itDay._value);
42 }
43
44 // ////////////////////////////////////////////////////////////////////
45 stdair::Duration_T FareRuleStruct::calculateTime() const {
46 _itHours.check(); _itMinutes.check(); _itSeconds.check();
47 return boost::posix_time::hours (_itHours._value)
48 + boost::posix_time::minutes (_itMinutes._value)
49 + boost::posix_time::seconds (_itSeconds._value);
50 }
51
52
53 // ////////////////////////////////////////////////////////////////////
54 const std::string FareRuleStruct::describe () const {
55
56 std::ostringstream oStr;
57 oStr << "FareRule: " << _fareId << ", ";
58
59 oStr << _origin << "-" << _destination << " ("
60 << _pos << "), " << _channel << ", [";
61 oStr << _dateRangeStart << "/" << _dateRangeEnd << "] - ["
62 << boost::posix_time::to_simple_string (_timeRangeStart) << "/"
63 << boost::posix_time::to_simple_string (_timeRangeEnd) << "], ";
64
65 oStr << _cabinCode << ", " << _fare << " EUR, ";
66 oStr << _tripType << ", " << _saturdayStay << ", "
67 << _changeFees << ", " << _nonRefundable << ", "
68 << _advancePurchase << ", " << _minimumStay << ", ";
69
70 // Sanity check
71 assert (_airlineCodeList.size() == _classCodeList.size());
72
73 // Browse the airline and class pathes
74 unsigned short idx = 0;
75 stdair::ClassList_StringList_T::const_iterator itClass =
76 _classCodeList.begin();
77 for (stdair::AirlineCodeList_T::const_iterator itAirline =
78 _airlineCodeList.begin();
79 itAirline != _airlineCodeList.end(); ++itAirline, ++itClass, ++idx) {
80 if (idx != 0) {
81 oStr << " - ";
82 }
83 const stdair::AirlineCode_T lAirlineCode = *itAirline;
84 const stdair::ClassCode_T lClassCode = *itClass;
85 oStr << lAirlineCode << " / " << lClassCode;
86 }
87
88 return oStr.str();
89 }
90
91}
92
Forward declarations.
Definition: FareParser.hpp:16
const std::string describe() const
stdair::Date_T calculateDate() const
stdair::month_t _itMonth
stdair::Duration_T calculateTime() const
stdair::second_t _itSeconds
stdair::minute_t _itMinutes