AirRAC Logo  1.00.8
C++ Simulated Revenue Accounting (RAC) System Library
Loading...
Searching...
No Matches
YieldRuleStruct.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_General.hpp>
9#include <stdair/service/Logger.hpp>
10// AIRRAC
13
14namespace AIRRAC {
15
16 // //////////////////////////////////////////////////////////////////////
18 : _yieldId(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 _yield(0),
26 _cabinCode(""),
27 _pos(""),
28 _channel(""),
29 _airlineCode(""),
30 _classCode("") {
31 }
32
33 // //////////////////////////////////////////////////////////////////////
36
37 // //////////////////////////////////////////////////////////////////////
38 stdair::Date_T YieldRuleStruct::calculateDate() 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 YieldRuleStruct::calculateTime() 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 const std::string YieldRuleStruct::describe() const {
53 std::ostringstream oStr;
54 oStr << "YieldRule: " << _yieldId << ", ";
55
56 oStr << _origin << "-" << _destination << " ("
57 << _pos << "), " << _channel << ", [";
58 oStr << _dateRangeStart << "/" << _dateRangeEnd << "] - ["
59 << boost::posix_time::to_simple_string (_timeRangeStart) << "/"
60 << boost::posix_time::to_simple_string (_timeRangeEnd) << "], ";
61
62 oStr << _cabinCode << ", " << _yield << " EUR, ";
63
64 // Sanity check
65 assert (_airlineCodeList.size() == _classCodeList.size());
66
67 // Browse the class-pathes
68 unsigned short idx = 0;
69 stdair::ClassList_StringList_T::const_iterator itClass =
70 _classCodeList.begin();
71 for (stdair::AirlineCodeList_T::const_iterator itAirline =
72 _airlineCodeList.begin();
73 itAirline != _airlineCodeList.end(); ++itAirline, ++itClass, ++idx) {
74 if (idx != 0) {
75 oStr << " - ";
76 }
77 const stdair::AirlineCode_T lAirlineCode = *itAirline;
78 const stdair::ClassCode_T lClassCode = *itClass;
79 oStr << lAirlineCode << " / " << lClassCode;
80 }
81
82 return oStr.str();
83 }
84}
Forward declarations.
stdair::Date_T calculateDate() const
const std::string describe() const
stdair::Duration_T calculateTime() const