StdAir Logo  0.43.0
C++ Standard Airline IT Library
OnDDateKey.cpp
Go to the documentation of this file.
00001 // //////////////////////////////////////////////////////////////////////
00002 // Import section
00003 // //////////////////////////////////////////////////////////////////////
00004 // STL
00005 #include <cassert>
00006 #include <sstream>
00007 // Boost Date-Time
00008 #include <boost/date_time/gregorian/formatters.hpp>
00009 // Boost.Serialization
00010 #include <boost/archive/text_iarchive.hpp>
00011 #include <boost/archive/text_oarchive.hpp>
00012 #include <boost/serialization/access.hpp>
00013 // StdAir
00014 #include <stdair/basic/BasConst_Inventory.hpp>
00015 #include <stdair/basic/BasConst_BomDisplay.hpp>
00016 #include <stdair/basic/BasConst_General.hpp>
00017 #include <stdair/bom/OnDDateKey.hpp>
00018 #include <stdair/bom/BomKeyManager.hpp>
00019 #include <stdair/bom/Inventory.hpp>
00020 #include <stdair/bom/FlightDate.hpp>
00021 #include <stdair/bom/SegmentDate.hpp>
00022 #include <stdair/bom/BomDisplay.hpp>
00023 
00024 namespace stdair {
00025 
00026   // ////////////////////////////////////////////////////////////////////
00027   OnDDateKey::OnDDateKey()
00028     : _OnDStringList (DEFAULT_OND_STRING_LIST) {
00029     assert (false);
00030   }
00031 
00032   // ////////////////////////////////////////////////////////////////////
00033   OnDDateKey::OnDDateKey (const OnDStringList_T& iOnDStringList)
00034     : _OnDStringList (iOnDStringList) {
00035   }
00036 
00037   // ////////////////////////////////////////////////////////////////////
00038   OnDDateKey::OnDDateKey (const OnDDateKey& iKey)
00039     : _OnDStringList (iKey._OnDStringList) {
00040   }
00041 
00042   // ////////////////////////////////////////////////////////////////////
00043   OnDDateKey::~OnDDateKey() {
00044   }
00045 
00046   // ////////////////////////////////////////////////////////////////////
00047   const Date_T OnDDateKey::getDate() const {
00048     assert(!_OnDStringList.empty());
00049     OnDString_T lFrontOnDString = _OnDStringList.front();
00050     return BomKeyManager::extractFlightDateKey (lFrontOnDString).getDepartureDate();
00051   }
00052   
00053   // ////////////////////////////////////////////////////////////////////
00054   const AirportCode_T OnDDateKey::getOrigin() const {
00055     assert(!_OnDStringList.empty());
00056     OnDString_T lFrontOnDString = _OnDStringList.front();
00057     return BomKeyManager::extractSegmentDateKey (lFrontOnDString).getBoardingPoint();
00058   }
00059 
00060   // ////////////////////////////////////////////////////////////////////
00061   const AirportCode_T OnDDateKey::getDestination() const {
00062     assert(!_OnDStringList.empty());
00063     OnDString_T lLastOnDString = _OnDStringList.back();
00064     return BomKeyManager::extractSegmentDateKey (lLastOnDString).getOffPoint();
00065   }
00066   
00067   // ////////////////////////////////////////////////////////////////////
00068   void OnDDateKey::toStream (std::ostream& ioOut) const {
00069     ioOut << "OnDDateKey: " << toString();
00070   }
00071 
00072   // ////////////////////////////////////////////////////////////////////
00073   void OnDDateKey::fromStream (std::istream& ioIn) {
00074   }
00075 
00076   // ////////////////////////////////////////////////////////////////////
00077   const std::string OnDDateKey::toString() const {
00078     std::ostringstream oStr;
00079     for (OnDStringList_T::const_iterator itOnDString = _OnDStringList.begin();
00080          itOnDString != _OnDStringList.end(); ++itOnDString){
00081       oStr << *itOnDString << " ";
00082     }
00083     return oStr.str();
00084   }
00085 
00086   // ////////////////////////////////////////////////////////////////////
00087   void OnDDateKey::serialisationImplementation() {
00088     std::ostringstream oStr;
00089     boost::archive::text_oarchive oa (oStr);
00090     oa << *this;
00091 
00092     std::istringstream iStr;
00093     boost::archive::text_iarchive ia (iStr);
00094     ia >> *this;
00095   }
00096 
00097   // ////////////////////////////////////////////////////////////////////
00098   template<class Archive>
00099   void OnDDateKey::serialize (Archive& ioArchive,
00100                               const unsigned int iFileVersion) {
00106   }
00107 
00108   // ////////////////////////////////////////////////////////////////////
00109   // Explicit template instantiation
00110   namespace ba = boost::archive;
00111   template void OnDDateKey::serialize<ba::text_oarchive> (ba::text_oarchive&,
00112                                                              unsigned int);
00113   template void OnDDateKey::serialize<ba::text_iarchive> (ba::text_iarchive&,
00114                                                              unsigned int);
00115   // ////////////////////////////////////////////////////////////////////
00116   
00117 }