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() == false); 00049 const 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() == false); 00056 const 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() == false); 00063 const 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::serialisationImplementationExport() const { 00088 std::ostringstream oStr; 00089 boost::archive::text_oarchive oa (oStr); 00090 oa << *this; 00091 } 00092 00093 // //////////////////////////////////////////////////////////////////// 00094 void OnDDateKey::serialisationImplementationImport() { 00095 std::istringstream iStr; 00096 boost::archive::text_iarchive ia (iStr); 00097 ia >> *this; 00098 } 00099 00100 // //////////////////////////////////////////////////////////////////// 00101 template<class Archive> 00102 void OnDDateKey::serialize (Archive& ioArchive, 00103 const unsigned int iFileVersion) { 00109 } 00110 00111 // //////////////////////////////////////////////////////////////////// 00112 // Explicit template instantiation 00113 namespace ba = boost::archive; 00114 template void OnDDateKey::serialize<ba::text_oarchive> (ba::text_oarchive&, 00115 unsigned int); 00116 template void OnDDateKey::serialize<ba::text_iarchive> (ba::text_iarchive&, 00117 unsigned int); 00118 // //////////////////////////////////////////////////////////////////// 00119 00120 }