7 #include <stdair/basic/BasConst_Request.hpp>
8 #include <stdair/bom/BomManager.hpp>
9 #include <stdair/bom/BomRoot.hpp>
10 #include <stdair/bom/Inventory.hpp>
11 #include <stdair/bom/FlightDate.hpp>
12 #include <stdair/bom/SegmentDate.hpp>
13 #include <stdair/bom/SegmentCabin.hpp>
14 #include <stdair/bom/FareFamily.hpp>
15 #include <stdair/bom/BookingClass.hpp>
16 #include <stdair/bom/TravelSolutionStruct.hpp>
17 #include <stdair/bom/AirportPair.hpp>
18 #include <stdair/bom/PosChannel.hpp>
19 #include <stdair/bom/DatePeriod.hpp>
20 #include <stdair/bom/TimePeriod.hpp>
21 #include <stdair/bom/YieldFeatures.hpp>
22 #include <stdair/bom/AirlineClassList.hpp>
23 #include <stdair/factory/FacBomManager.hpp>
24 #include <stdair/service/Logger.hpp>
32 YieldManager::YieldManager() {
37 YieldManager::YieldManager (
const YieldManager&) {
42 YieldManager::~YieldManager() {
47 calculateYield (stdair::TravelSolutionList_T& ioTravelSolutionList,
48 const stdair::BomRoot& iBomRoot) {
51 for (stdair::TravelSolutionList_T::iterator itTravelSolution =
52 ioTravelSolutionList.begin();
53 itTravelSolution != ioTravelSolutionList.end(); ++itTravelSolution) {
54 stdair::TravelSolutionStruct& lTravelSolution = *itTravelSolution;
57 YieldManager::calculateYield (lTravelSolution, iBomRoot);
63 calculateYield (stdair::TravelSolutionStruct& ioTravelSolution,
64 const stdair::BomRoot& iBomRoot) {
73 void YieldManager::updateYields (
const stdair::BomRoot& iBomRoot) {
75 const stdair::InventoryList_T lInvList =
76 stdair::BomManager::getList<stdair::Inventory> (iBomRoot);
77 for (stdair::InventoryList_T::const_iterator itInv = lInvList.begin();
78 itInv != lInvList.end(); ++itInv) {
79 const stdair::Inventory* lInv_ptr = *itInv;
80 assert (lInv_ptr != NULL);
83 const stdair::AirlineCode_T& lAirlineCode = lInv_ptr->getAirlineCode();
86 const stdair::FlightDateList_T& lFDList =
87 stdair::BomManager::getList<stdair::FlightDate> (*lInv_ptr);
88 for (stdair::FlightDateList_T::const_iterator itFD = lFDList.begin();
89 itFD != lFDList.end(); ++itFD) {
90 const stdair::FlightDate* lFD_ptr = *itFD;
91 assert (lFD_ptr != NULL);
94 const stdair::SegmentDateList_T& lSDList =
95 stdair::BomManager::getList<stdair::SegmentDate> (*lFD_ptr);
96 for (stdair::SegmentDateList_T::const_iterator itSD = lSDList.begin();
97 itSD != lSDList.end(); ++itSD) {
98 const stdair::SegmentDate* lSD_ptr = *itSD;
99 assert (lSD_ptr != NULL);
102 const stdair::AirportCode_T& lOrigin = lSD_ptr->getBoardingPoint();
103 const stdair::AirportCode_T& lDestination = lSD_ptr->getOffPoint();
106 const stdair::AirportPairKey lAirportPairKey (lOrigin, lDestination);
107 stdair::AirportPair* lAirportPair_ptr = stdair::BomManager::
108 getObjectPtr<stdair::AirportPair> (iBomRoot,
109 lAirportPairKey.toString());
110 if (lAirportPair_ptr == NULL) {
111 STDAIR_LOG_ERROR (
"Cannot find yield corresponding to the airport "
112 <<
"pair: " << lAirportPairKey.toString());
117 const stdair::Date_T& lDate = lSD_ptr->getBoardingDate();
118 const stdair::Duration_T& lTime = lSD_ptr->getBoardingTime();
121 const stdair::DatePeriodList_T& lDatePeriodList =
122 stdair::BomManager::getList<stdair::DatePeriod> (*lAirportPair_ptr);
123 for (stdair::DatePeriodList_T::const_iterator itDatePeriod =
124 lDatePeriodList.begin();
125 itDatePeriod != lDatePeriodList.end(); ++itDatePeriod) {
126 const stdair::DatePeriod* lDatePeriod_ptr = *itDatePeriod;
127 assert (lDatePeriod_ptr != NULL);
129 const bool isDepartureDateValid =
130 lDatePeriod_ptr->isDepartureDateValid (lDate);
132 if (isDepartureDateValid ==
true) {
135 const stdair::PosChannelKey lPosChannelKey (stdair::DEFAULT_POS,
136 stdair::DEFAULT_CHANNEL);
137 stdair::PosChannel* lPosChannel_ptr = stdair::BomManager::
138 getObjectPtr<stdair::PosChannel> (*lDatePeriod_ptr,
139 lPosChannelKey.toString());
140 if (lPosChannel_ptr == NULL) {
141 STDAIR_LOG_ERROR (
"Cannot find yield corresponding to the PoS-"
142 <<
"Channel: " << lPosChannelKey.toString());
147 const stdair::TimePeriodList_T& lTimePeriodList = stdair::
148 BomManager::getList<stdair::TimePeriod> (*lPosChannel_ptr);
149 for (stdair::TimePeriodList_T::const_iterator itTimePeriod =
150 lTimePeriodList.begin();
151 itTimePeriod != lTimePeriodList.end(); ++itTimePeriod) {
152 const stdair::TimePeriod* lTimePeriod_ptr = *itTimePeriod;
153 assert (lTimePeriod_ptr != NULL);
155 const bool isDepartureTimeValid =
156 lTimePeriod_ptr->isDepartureTimeValid (lTime);
158 if (isDepartureTimeValid ==
true) {
159 updateYields (*lSD_ptr, *lTimePeriod_ptr, lAirlineCode);
170 void YieldManager::updateYields (
const stdair::SegmentDate& iSegmentDate,
171 const stdair::TimePeriod& iTimePeriod,
172 const stdair::AirlineCode_T& iAirlineCode) {
175 const stdair::SegmentCabinList_T& lSegmentCabinList =
176 stdair::BomManager::getList<stdair::SegmentCabin> (iSegmentDate);
177 for (stdair::SegmentCabinList_T::const_iterator itSC =
178 lSegmentCabinList.begin(); itSC != lSegmentCabinList.end(); ++itSC) {
179 const stdair::SegmentCabin* lSegmentCabin_ptr = *itSC;
180 assert (lSegmentCabin_ptr != NULL);
182 const stdair::CabinCode_T& lCabinCode = lSegmentCabin_ptr->getCabinCode();
183 const stdair::TripType_T lTripType (stdair::TRIP_TYPE_ONE_WAY);
184 const stdair::YieldFeaturesKey lYieldFeaturesKey (lTripType,
186 const stdair::YieldFeatures* lYieldFeatures_ptr = stdair::BomManager::
187 getObjectPtr<stdair::YieldFeatures> (iTimePeriod,
188 lYieldFeaturesKey.toString());
189 if (lYieldFeatures_ptr == NULL) {
190 STDAIR_LOG_ERROR (
"Cannot find the yield features corresponding to "
191 << iTimePeriod.describeKey() <<
", "
192 << lCabinCode <<
" and " << lTripType);
197 const stdair::FareFamilyList_T& lFFlist = stdair::BomManager::
198 getList<stdair::FareFamily> (*lSegmentCabin_ptr);
199 for (stdair::FareFamilyList_T::const_iterator itFF = lFFlist.begin();
200 itFF != lFFlist.end(); ++itFF) {
201 const stdair::FareFamily* lFF_ptr = *itFF;
202 assert (lFF_ptr != NULL);
204 const stdair::BookingClassList_T& lBCList = stdair::BomManager::
205 getList<stdair::BookingClass> (*lFF_ptr);
206 for (stdair::BookingClassList_T::const_iterator itBC = lBCList.begin();
207 itBC != lBCList.end(); ++itBC) {
208 stdair::BookingClass* lBookingClass_ptr = *itBC;
209 assert (lBookingClass_ptr != NULL);
211 const stdair::ClassCode_T& lClassCode =
212 lBookingClass_ptr->getClassCode();
213 stdair::AirlineCodeList_T lAirlineCodeList;
214 lAirlineCodeList.push_back (iAirlineCode);
215 stdair::ClassList_StringList_T lClassList;
216 lClassList.push_back (lClassCode);
217 const stdair::AirlineClassListKey lACListKey (lAirlineCodeList,
220 const stdair::AirlineClassList* lAirlineClassList_ptr = stdair::
221 BomManager::getObjectPtr<stdair::AirlineClassList> (*lYieldFeatures_ptr, lACListKey.toString());
222 if (lAirlineClassList_ptr != NULL) {
223 const stdair::Yield_T& lYield = lAirlineClassList_ptr->getYield();
224 lBookingClass_ptr->setYield (lYield);
227 STDAIR_LOG_DEBUG (
"Update yield of " << lYield <<
" for "
228 << iAirlineCode <<
", "
229 << iSegmentDate.describeKey() <<
", "
230 << lBookingClass_ptr->describeKey());