StdAir Logo  0.43.0
C++ Standard Airline IT Library
SegmentDate.cpp
Go to the documentation of this file.
00001 // //////////////////////////////////////////////////////////////////////
00002 // Import section
00003 // //////////////////////////////////////////////////////////////////////
00004 // STL
00005 #include <cassert>
00006 #include <sstream>
00007 // StdAir
00008 #include <stdair/basic/BasConst_BookingClass.hpp>
00009 #include <stdair/basic/BasConst_Inventory.hpp>
00010 #include <stdair/bom/BomManager.hpp>
00011 #include <stdair/bom/SegmentDate.hpp>
00012 #include <stdair/bom/SegmentCabin.hpp>
00013 
00014 namespace stdair {
00015 
00016   // ////////////////////////////////////////////////////////////////////
00017   SegmentDate::SegmentDate()
00018     : _key (DEFAULT_ORIGIN, DEFAULT_DESTINATION), _parent (NULL) {
00019     assert (false);
00020   }
00021 
00022   // ////////////////////////////////////////////////////////////////////
00023   SegmentDate::SegmentDate (const SegmentDate&)
00024     : _key (DEFAULT_ORIGIN, DEFAULT_DESTINATION), _parent (NULL) {
00025     assert (false);
00026   }
00027 
00028   // ////////////////////////////////////////////////////////////////////
00029   SegmentDate::SegmentDate (const Key_T& iKey)
00030     : _key (iKey), _parent (NULL),
00031       _isOtherAirlineOperating (false) {
00032   }
00033 
00034   // ////////////////////////////////////////////////////////////////////
00035   SegmentDate::~SegmentDate() {
00036   }
00037 
00038   // ////////////////////////////////////////////////////////////////////
00039   std::string SegmentDate::toString() const {
00040     std::ostringstream oStr;
00041     oStr << describeKey();
00042     return oStr.str();
00043   }
00044 
00045   // ////////////////////////////////////////////////////////////////////
00046   const Duration_T SegmentDate::getTimeOffset() const {
00047     // TimeOffset = (OffTime - BoardingTime) + (OffDate - BoardingDate) * 24
00048     //              - ElapsedTime
00049     Duration_T oTimeOffset = (_offTime - _boardingTime);
00050     const DateOffset_T& lDateOffset = getDateOffset();
00051     const Duration_T lDateOffsetInHours (lDateOffset.days() * 24, 0, 0);
00052     oTimeOffset += lDateOffsetInHours - _elapsedTime;
00053     return oTimeOffset;
00054   }
00055 }
00056