StdAir Logo  0.45.1
C++ Standard Airline IT Object Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
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       _operatingSegmentDate (NULL) {
00020     assert (false);
00021   }
00022 
00023   // ////////////////////////////////////////////////////////////////////
00024   SegmentDate::SegmentDate (const SegmentDate&)
00025     : _key (DEFAULT_ORIGIN, DEFAULT_DESTINATION), _parent (NULL),
00026       _operatingSegmentDate (NULL) {
00027     assert (false);
00028   }
00029 
00030   // ////////////////////////////////////////////////////////////////////
00031   SegmentDate::SegmentDate (const Key_T& iKey)
00032     : _key (iKey), _parent (NULL) ,
00033       _operatingSegmentDate (NULL) {
00034   }
00035 
00036   // ////////////////////////////////////////////////////////////////////
00037   SegmentDate::~SegmentDate() {
00038   }
00039 
00040   // ////////////////////////////////////////////////////////////////////
00041   std::string SegmentDate::toString() const {
00042     std::ostringstream oStr;
00043     oStr << describeKey();
00044     return oStr.str();
00045   }
00046 
00047   // ////////////////////////////////////////////////////////////////////
00048   const Duration_T SegmentDate::getTimeOffset() const {
00049     // TimeOffset = (OffTime - BoardingTime) + (OffDate - BoardingDate) * 24
00050     //              - ElapsedTime
00051     Duration_T oTimeOffset = (_offTime - _boardingTime);
00052     const DateOffset_T& lDateOffset = getDateOffset();
00053     const Duration_T lDateOffsetInHours (lDateOffset.days() * 24, 0, 0);
00054     oTimeOffset += lDateOffsetInHours - _elapsedTime;
00055     return oTimeOffset;
00056   }
00057 }
00058