AirSched Logo  0.1.2
C++ Simulated Airline Schedule Manager Library
SegmentPathPeriodKey.cpp
Go to the documentation of this file.
00001 // //////////////////////////////////////////////////////////////////////
00002 // Import section
00003 // //////////////////////////////////////////////////////////////////////
00004 // STL
00005 #include <sstream>
00006 // Boost.Serialization
00007 #include <boost/archive/text_iarchive.hpp>
00008 #include <boost/archive/text_oarchive.hpp>
00009 #include <boost/serialization/access.hpp>
00010 // StdAir
00011 #include <stdair/basic/BasConst_General.hpp>
00012 #include <stdair/basic/BasConst_Inventory.hpp>
00013 #include <stdair/basic/BasConst_Period_BOM.hpp>
00014 #include <stdair/basic/BasConst_TravelSolution.hpp>
00015 // AirSched
00016 #include <airsched/bom/SegmentPathPeriodKey.hpp>
00017 
00018 namespace AIRSCHED {
00019 
00020   // ////////////////////////////////////////////////////////////////////
00021   SegmentPathPeriodKey::SegmentPathPeriodKey()
00022     : _period (stdair::BOOST_DEFAULT_DATE_PERIOD, stdair::DEFAULT_DOW_STRING),
00023       _boardingTime (stdair::NULL_BOOST_TIME_DURATION),
00024       _elapsed (stdair::NULL_BOOST_TIME_DURATION),
00025       _nbOfAirlines (stdair::DEFAULT_NBOFAIRLINES) {
00026   }
00027 
00028   // ////////////////////////////////////////////////////////////////////
00029   SegmentPathPeriodKey::SegmentPathPeriodKey (const SegmentPathPeriodKey& iSPPK)
00030     : _period (iSPPK._period),
00031       _boardingTime (iSPPK._boardingTime),
00032       _elapsed (iSPPK._elapsed),
00033       _boardingDateOffsetList (iSPPK._boardingDateOffsetList),
00034       _nbOfAirlines (iSPPK._nbOfAirlines) {
00035   }
00036 
00037   // ////////////////////////////////////////////////////////////////////
00038   SegmentPathPeriodKey::
00039   SegmentPathPeriodKey (const stdair::PeriodStruct& iPeriod,
00040                         const stdair::Duration_T& iBoardingTime,
00041                         const stdair::Duration_T& iElapsedTime,
00042                         const DateOffsetList_T& iBoardingDateOffsetList,
00043                         const stdair::NbOfAirlines_T& iNbOfAirlines)
00044     : _period (iPeriod),
00045       _boardingTime (iBoardingTime),
00046       _elapsed (iElapsedTime),
00047       _boardingDateOffsetList (iBoardingDateOffsetList),
00048       _nbOfAirlines (iNbOfAirlines) {
00049   }
00050   
00051   // ////////////////////////////////////////////////////////////////////
00052   SegmentPathPeriodKey::~SegmentPathPeriodKey() {
00053   }
00054 
00055   // ////////////////////////////////////////////////////////////////////
00056   void SegmentPathPeriodKey::toStream (std::ostream& ioOut) const {
00057     ioOut << "SegmentPathPeriodKey: " << toString() << std::endl;
00058   }
00059 
00060   // ////////////////////////////////////////////////////////////////////
00061   void SegmentPathPeriodKey::fromStream (std::istream& ioIn) {
00062   }
00063 
00064   // ////////////////////////////////////////////////////////////////////
00065   const std::string SegmentPathPeriodKey::toString() const {
00066     std::ostringstream oStr;
00067     oStr << _period.describeShort() << ", "
00068          << _boardingTime << ", "  << _elapsed << ", ";
00069 
00070     for (DateOffsetList_T::const_iterator itOffset =
00071            _boardingDateOffsetList.begin();
00072          itOffset != _boardingDateOffsetList.end(); ++itOffset) {
00073       const stdair::DateOffset_T& lDateOffset = *itOffset;
00074       oStr << lDateOffset.days() << ", ";
00075     }
00076 
00077     oStr << _nbOfAirlines ;
00078     return oStr.str();
00079   }
00080   
00081   // ////////////////////////////////////////////////////////////////////
00082   void SegmentPathPeriodKey::serialisationImplementation() {
00083     std::ostringstream oStr;
00084     boost::archive::text_oarchive oa (oStr);
00085     oa << *this;
00086 
00087     std::istringstream iStr;
00088     boost::archive::text_iarchive ia (iStr);
00089     ia >> *this;
00090   }
00091 
00092   // ////////////////////////////////////////////////////////////////////
00093   template<class Archive>
00094   void SegmentPathPeriodKey::serialize (Archive& ioArchive,
00095                                         const unsigned int iFileVersion) {
00100     //ioArchive & _period & _boardingTime & _elapsed & _nbOfAirlines;
00101     std::string lBTStr = boost::posix_time::to_simple_string (_boardingTime);
00102     std::string lElapsedStr = boost::posix_time::to_simple_string (_elapsed);
00103     ioArchive & lBTStr & lElapsedStr & _nbOfAirlines;
00104   }
00105 
00106 }