StdAir Logo  1.00.10
C++ Standard Airline IT Object Library
SegmentDate.cpp
Go to the documentation of this file.
1 // //////////////////////////////////////////////////////////////////////
2 // Import section
3 // //////////////////////////////////////////////////////////////////////
4 // STL
5 #include <cassert>
6 #include <sstream>
7 // StdAir
13 
14 namespace stdair {
15 
16  // ////////////////////////////////////////////////////////////////////
17  SegmentDate::SegmentDate()
18  : _key (DEFAULT_ORIGIN, DEFAULT_DESTINATION), _parent (NULL),
19  _operatingSegmentDate (NULL) {
20  assert (false);
21  }
22 
23  // ////////////////////////////////////////////////////////////////////
24  SegmentDate::SegmentDate (const SegmentDate& iSegmentDate)
25  : _key (iSegmentDate._key),
26  _parent (NULL),
27  _operatingSegmentDate (NULL),
28  _boardingDate (iSegmentDate._boardingDate),
29  _boardingTime (iSegmentDate._boardingTime),
30  _offDate (iSegmentDate._offDate),
31  _offTime (iSegmentDate._offTime),
32  _elapsedTime (iSegmentDate._elapsedTime),
33  _distance (iSegmentDate._distance),
34  _routingLegKeyList (iSegmentDate._routingLegKeyList) {
35  }
36 
37  // ////////////////////////////////////////////////////////////////////
38  SegmentDate::SegmentDate (const Key_T& iKey)
39  : _key (iKey), _parent (NULL) ,
40  _operatingSegmentDate (NULL) {
41  }
42 
43  // ////////////////////////////////////////////////////////////////////
45  }
46 
47  // ////////////////////////////////////////////////////////////////////
48  std::string SegmentDate::toString() const {
49  std::ostringstream oStr;
50  oStr << describeKey();
51  return oStr.str();
52  }
53 
54  // ////////////////////////////////////////////////////////////////////
56  // TimeOffset = (OffTime - BoardingTime) + (OffDate - BoardingDate) * 24
57  // - ElapsedTime
58  Duration_T oTimeOffset = (_offTime - _boardingTime);
59  const DateOffset_T& lDateOffset = getDateOffset();
60  const Duration_T lDateOffsetInHours (lDateOffset.days() * 24, 0, 0);
61  oTimeOffset += lDateOffsetInHours - _elapsedTime;
62  return oTimeOffset;
63  }
64 }
65 
stdair::SegmentDateKey
Key of a given segment-date, made of an origin and a destination airports.
Definition: SegmentDateKey.hpp:24
stdair::SegmentDate::_boardingTime
Duration_T _boardingTime
Definition: SegmentDate.hpp:350
stdair::SegmentDate::getDateOffset
const DateOffset_T getDateOffset() const
Definition: SegmentDate.hpp:139
stdair::DEFAULT_ORIGIN
const AirportCode_T DEFAULT_ORIGIN
stdair::SegmentDate::_offTime
Duration_T _offTime
Definition: SegmentDate.hpp:360
stdair
Handle on the StdAir library context.
Definition: BasChronometer.cpp:9
stdair::DEFAULT_DESTINATION
const AirportCode_T DEFAULT_DESTINATION
stdair::SegmentDate::describeKey
const std::string describeKey() const
Definition: SegmentDate.hpp:260
BasConst_Inventory.hpp
stdair::SegmentDate::toString
std::string toString() const
Definition: SegmentDate.cpp:48
BasConst_BookingClass.hpp
stdair::SegmentDate::getTimeOffset
const Duration_T getTimeOffset() const
Definition: SegmentDate.cpp:55
stdair::DateOffset_T
boost::gregorian::date_duration DateOffset_T
Definition: stdair_date_time_types.hpp:35
SegmentCabin.hpp
stdair::SegmentDate::_elapsedTime
Duration_T _elapsedTime
Definition: SegmentDate.hpp:365
SegmentDate.hpp
BomManager.hpp
stdair::SegmentDate::~SegmentDate
virtual ~SegmentDate()
Definition: SegmentDate.cpp:44
stdair::Duration_T
boost::posix_time::time_duration Duration_T
Definition: stdair_date_time_types.hpp:17