SimCRS Logo  0.1.1
C++ Simulated Travel-Oriented Distribution System Library
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
DistributionManager.cpp
Go to the documentation of this file.
1 // //////////////////////////////////////////////////////////////////////
2 // Import section
3 // //////////////////////////////////////////////////////////////////////
4 // STL
5 #include <cassert>
6 // StdAir
7 #include <stdair/bom/FareOptionStruct.hpp>
8 #include <stdair/bom/TravelSolutionStruct.hpp>
9 #include <stdair/bom/CancellationStruct.hpp>
10 #include <stdair/service/Logger.hpp>
11 // Airline Inventory
12 #include <airinv/AIRINV_Master_Service.hpp>
13 // SimCRS
15 
16 namespace SIMCRS {
17 
18  // ////////////////////////////////////////////////////////////////////
19  void DistributionManager::
20  calculateAvailability (AIRINV::AIRINV_Master_Service& ioAIRINV_Master_Service,
21  stdair::TravelSolutionList_T& ioTravelSolutionList,
22  const stdair::PartnershipTechnique& iPartnershipTechnique) {
23  for (stdair::TravelSolutionList_T::iterator itTS =
24  ioTravelSolutionList.begin();
25  itTS != ioTravelSolutionList.end(); ++itTS) {
26  stdair::TravelSolutionStruct& lCurrentTravelSolution = *itTS;
27 
28  // Forward the work to the dedicated service.
29  ioAIRINV_Master_Service.calculateAvailability (lCurrentTravelSolution,
30  iPartnershipTechnique);
31  }
32  }
33 
34  // ////////////////////////////////////////////////////////////////////
35  bool DistributionManager::
36  sell (AIRINV::AIRINV_Master_Service& ioAIRINV_Master_Service,
37  const stdair::TravelSolutionStruct& iTravelSolution,
38  const stdair::NbOfSeats_T& iPartySize) {
39  bool hasSaleBeenSuccessful = false;
40 
41  const stdair::KeyList_T& lSegmentDateKeyList =
42  iTravelSolution.getSegmentPath();
43  const stdair::FareOptionStruct& lChosenFareOption =
44  iTravelSolution.getChosenFareOption ();
45  const stdair::ClassList_StringList_T& lClassPath =
46  lChosenFareOption.getClassPath();
47  stdair::ClassList_StringList_T::const_iterator itClassKeyList =
48  lClassPath.begin();
49  for (stdair::KeyList_T::const_iterator itKey= lSegmentDateKeyList.begin();
50  itKey != lSegmentDateKeyList.end(); ++itKey, ++itClassKeyList) {
51  const std::string& lSegmentDateKey = *itKey;
52 
53  // TODO: Removed this hardcode.
54  std::ostringstream ostr;
55  const stdair::ClassList_String_T& lClassList = *itClassKeyList;
56  assert (lClassList.size() > 0);
57  ostr << lClassList.at(0);
58  const stdair::ClassCode_T lClassCode (ostr.str());
59 
60  hasSaleBeenSuccessful =
61  ioAIRINV_Master_Service.sell (lSegmentDateKey, lClassCode, iPartySize);
62  }
63 
64  return hasSaleBeenSuccessful;
65  }
66 
67  // ////////////////////////////////////////////////////////////////////
68  bool DistributionManager::
69  playCancellation (AIRINV::AIRINV_Master_Service& ioAIRINV_Master_Service,
70  const stdair::CancellationStruct& iCancellation) {
71  bool hasCancellationBeenSuccessful = false;
72 
73  const stdair::PartySize_T& lPartySize = iCancellation.getPartySize();
74  const stdair::KeyList_T& lSegmentDateKeyList =
75  iCancellation.getSegmentPath();
76  const stdair::ClassList_String_T& lClassList = iCancellation.getClassList();
77  stdair::ClassList_String_T::const_iterator itClass = lClassList.begin();
78  for (stdair::KeyList_T::const_iterator itKey= lSegmentDateKeyList.begin();
79  itKey != lSegmentDateKeyList.end(); ++itKey, ++itClass) {
80  const std::string& lSegmentDateKey = *itKey;
81 
82  // TODO: Removed this hardcode.
83  std::ostringstream ostr;
84  ostr << *itClass;
85  const stdair::ClassCode_T lClassCode (ostr.str());
86 
87  hasCancellationBeenSuccessful =
88  ioAIRINV_Master_Service.cancel (lSegmentDateKey, lClassCode,
89  lPartySize);
90  }
91  return hasCancellationBeenSuccessful;
92  }
93 
94 }