$treeview $search $mathjax
00001 // ////////////////////////////////////////////////////////////////////// 00002 // Import section 00003 // ////////////////////////////////////////////////////////////////////// 00004 // STL 00005 #include <cassert> 00006 // StdAir 00007 #include <stdair/bom/FareOptionStruct.hpp> 00008 #include <stdair/bom/TravelSolutionStruct.hpp> 00009 #include <stdair/bom/CancellationStruct.hpp> 00010 #include <stdair/service/Logger.hpp> 00011 // Airline Inventory 00012 #include <airinv/AIRINV_Master_Service.hpp> 00013 // SimCRS 00014 #include <simcrs/command/DistributionManager.hpp> 00015 00016 namespace SIMCRS { 00017 00018 // //////////////////////////////////////////////////////////////////// 00019 void DistributionManager:: 00020 calculateAvailability (AIRINV::AIRINV_Master_Service& ioAIRINV_Master_Service, 00021 stdair::TravelSolutionList_T& ioTravelSolutionList) { 00022 for (stdair::TravelSolutionList_T::iterator itTS = 00023 ioTravelSolutionList.begin(); 00024 itTS != ioTravelSolutionList.end(); ++itTS) { 00025 stdair::TravelSolutionStruct& lCurrentTravelSolution = *itTS; 00026 00027 // Forward the work to the dedicated service. 00028 ioAIRINV_Master_Service.calculateAvailability (lCurrentTravelSolution); 00029 } 00030 } 00031 00032 // //////////////////////////////////////////////////////////////////// 00033 bool DistributionManager:: 00034 sell (AIRINV::AIRINV_Master_Service& ioAIRINV_Master_Service, 00035 const stdair::TravelSolutionStruct& iTravelSolution, 00036 const stdair::NbOfSeats_T& iPartySize) { 00037 bool hasSaleBeenSuccessful = false; 00038 00039 const stdair::ClassObjectIDMapHolder_T& lClassObjectIDMapHolder = 00040 iTravelSolution.getClassObjectIDMapHolder(); 00041 if (lClassObjectIDMapHolder.size() > 0) { 00042 const stdair::FareOptionStruct& lChosenFareOption = 00043 iTravelSolution.getChosenFareOption (); 00044 const stdair::ClassList_StringList_T& lClassPath = 00045 lChosenFareOption.getClassPath(); 00046 stdair::ClassList_StringList_T::const_iterator itClassKeyList = 00047 lClassPath.begin(); 00048 for (stdair::ClassObjectIDMapHolder_T::const_iterator itClassObjectIDMap = 00049 lClassObjectIDMapHolder.begin(); 00050 itClassObjectIDMap != lClassObjectIDMapHolder.end(); 00051 ++itClassObjectIDMap, ++itClassKeyList) { 00052 const stdair::ClassObjectIDMap_T& lClassObjectIDMap = 00053 *itClassObjectIDMap; 00054 00055 // TODO: Removed this hardcode. 00056 std::ostringstream ostr; 00057 const stdair::ClassList_String_T& lClassList = *itClassKeyList; 00058 assert (lClassList.size() > 0); 00059 ostr << lClassList.at(0); 00060 const stdair::ClassCode_T lClassCode (ostr.str()); 00061 stdair::ClassObjectIDMap_T::const_iterator itClassID = 00062 lClassObjectIDMap.find (lClassCode); 00063 assert (itClassID != lClassObjectIDMap.end()); 00064 const stdair::BookingClassID_T& lClassID = itClassID->second; 00065 00066 hasSaleBeenSuccessful = 00067 ioAIRINV_Master_Service.sell (lClassID, iPartySize); 00068 } 00069 } else { 00070 const stdair::KeyList_T& lSegmentDateKeyList = 00071 iTravelSolution.getSegmentPath(); 00072 const stdair::FareOptionStruct& lChosenFareOption = 00073 iTravelSolution.getChosenFareOption (); 00074 const stdair::ClassList_StringList_T& lClassPath = 00075 lChosenFareOption.getClassPath(); 00076 stdair::ClassList_StringList_T::const_iterator itClassKeyList = 00077 lClassPath.begin(); 00078 for (stdair::KeyList_T::const_iterator itKey= lSegmentDateKeyList.begin(); 00079 itKey != lSegmentDateKeyList.end(); ++itKey, ++itClassKeyList) { 00080 const std::string& lSegmentDateKey = *itKey; 00081 00082 // TODO: Removed this hardcode. 00083 std::ostringstream ostr; 00084 const stdair::ClassList_String_T& lClassList = *itClassKeyList; 00085 assert (lClassList.size() > 0); 00086 ostr << lClassList.at(0); 00087 const stdair::ClassCode_T lClassCode (ostr.str()); 00088 00089 hasSaleBeenSuccessful = 00090 ioAIRINV_Master_Service.sell (lSegmentDateKey, lClassCode, 00091 iPartySize); 00092 } 00093 } 00094 00095 return hasSaleBeenSuccessful; 00096 } 00097 00098 // //////////////////////////////////////////////////////////////////// 00099 bool DistributionManager:: 00100 playCancellation (AIRINV::AIRINV_Master_Service& ioAIRINV_Master_Service, 00101 const stdair::CancellationStruct& iCancellation) { 00102 bool hasCancellationBeenSuccessful = false; 00103 00104 const stdair::PartySize_T& lPartySize = iCancellation.getPartySize(); 00105 const stdair::BookingClassIDList_T& lClassIDList = 00106 iCancellation.getClassIDList(); 00107 00108 for (stdair::BookingClassIDList_T::const_iterator itClassID = 00109 lClassIDList.begin(); itClassID != lClassIDList.end(); ++itClassID) { 00110 const stdair::BookingClassID_T& lClassID = *itClassID; 00111 00112 hasCancellationBeenSuccessful = 00113 ioAIRINV_Master_Service.cancel (lClassID, lPartySize); 00114 } 00115 return hasCancellationBeenSuccessful; 00116 } 00117 00118 }