StdAir Logo  1.00.3
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 
const AirportCode_T DEFAULT_ORIGIN
std::string toString() const
Definition: SegmentDate.cpp:48
Handle on the StdAir library context.
boost::posix_time::time_duration Duration_T
const DateOffset_T getDateOffset() const
const Duration_T getTimeOffset() const
Definition: SegmentDate.cpp:55
const AirportCode_T DEFAULT_DESTINATION
Duration_T _elapsedTime
const std::string describeKey() const
virtual ~SegmentDate()
Definition: SegmentDate.cpp:44
Duration_T _boardingTime
boost::gregorian::date_duration DateOffset_T
Key of a given segment-date, made of an origin and a destination airports.