7 #include <stdair/bom/BomManager.hpp>
8 #include <stdair/bom/BomRoot.hpp>
9 #include <stdair/bom/AirportPair.hpp>
10 #include <stdair/bom/PosChannel.hpp>
11 #include <stdair/bom/DatePeriod.hpp>
12 #include <stdair/bom/TimePeriod.hpp>
13 #include <stdair/bom/YieldFeatures.hpp>
14 #include <stdair/bom/AirlineClassList.hpp>
15 #include <stdair/factory/FacBomManager.hpp>
16 #include <stdair/service/Logger.hpp>
24 void YieldRuleGenerator::
25 createAirportPair (stdair::BomRoot& ioBomRoot,
26 const YieldRuleStruct& iYieldRuleStruct) {
29 const stdair::AirportCode_T& lBoardPoint = iYieldRuleStruct.getOrigin ();
30 const stdair::AirportCode_T& lOffPoint = iYieldRuleStruct.getDestination ();
31 const stdair::AirportPairKey lAirportPairKey (lBoardPoint, lOffPoint);
36 stdair::AirportPair* lAirportPair_ptr = stdair::BomManager::
37 getObjectPtr<stdair::AirportPair> (ioBomRoot, lAirportPairKey.toString());
38 if (lAirportPair_ptr == NULL) {
39 lAirportPair_ptr = &stdair::FacBom<stdair::AirportPair>::
40 instance().create (lAirportPairKey);
41 stdair::FacBomManager::addToListAndMap (ioBomRoot, *lAirportPair_ptr);
42 stdair::FacBomManager::linkWithParent (ioBomRoot, *lAirportPair_ptr);
45 assert (lAirportPair_ptr != NULL);
47 stdair::AirportPair& lAirportPair = *lAirportPair_ptr;
50 createDateRange (lAirportPair, iYieldRuleStruct);
56 void YieldRuleGenerator::
57 createDateRange (stdair::AirportPair& iAirportPair,
58 const YieldRuleStruct& iYieldRuleStruct) {
61 const stdair::Date_T& lDateRangeStart =
62 iYieldRuleStruct.getDateRangeStart ();
63 const stdair::Date_T& lDateRangeEnd =
64 iYieldRuleStruct.getDateRangeEnd ();
65 const stdair::DatePeriod_T lDatePeriod (lDateRangeStart, lDateRangeEnd);
66 const stdair::DatePeriodKey lYieldDatePeriodKey (lDatePeriod);
71 stdair::DatePeriod* lYieldDatePeriod_ptr = stdair::BomManager::
72 getObjectPtr<stdair::DatePeriod> (iAirportPair,
73 lYieldDatePeriodKey.toString());
74 if (lYieldDatePeriod_ptr == NULL) {
75 lYieldDatePeriod_ptr = &stdair::FacBom<stdair::DatePeriod>::
76 instance().create (lYieldDatePeriodKey);
77 stdair::FacBomManager::
78 addToListAndMap (iAirportPair, *lYieldDatePeriod_ptr);
79 stdair::FacBomManager::
80 linkWithParent (iAirportPair, *lYieldDatePeriod_ptr);
83 assert (lYieldDatePeriod_ptr != NULL);
85 stdair::DatePeriod& lDateRange = *lYieldDatePeriod_ptr;
88 createPOSChannel (lDateRange, iYieldRuleStruct);
93 void YieldRuleGenerator::
94 createPOSChannel (stdair::DatePeriod& iDatePeriod,
95 const YieldRuleStruct& iYieldRuleStruct) {
98 const stdair::CityCode_T& lPoS = iYieldRuleStruct.getPOS ();
99 const stdair::ChannelLabel_T& lChannel = iYieldRuleStruct.getChannel ();
100 const stdair::PosChannelKey lYieldPosChannelKey (lPoS, lChannel);
105 stdair::PosChannel* lYieldPosChannel_ptr = stdair::BomManager::
106 getObjectPtr<stdair::PosChannel> (iDatePeriod,
107 lYieldPosChannelKey.toString());
108 if (lYieldPosChannel_ptr == NULL) {
109 lYieldPosChannel_ptr = &stdair::FacBom<stdair::PosChannel>::
110 instance().create (lYieldPosChannelKey);
111 stdair::FacBomManager::
112 addToListAndMap (iDatePeriod, *lYieldPosChannel_ptr);
113 stdair::FacBomManager::
114 linkWithParent (iDatePeriod, *lYieldPosChannel_ptr);
117 assert (lYieldPosChannel_ptr != NULL);
119 stdair::PosChannel& lPosChannel = *lYieldPosChannel_ptr;
122 createTimeRange (lPosChannel, iYieldRuleStruct);
127 void YieldRuleGenerator::
128 createTimeRange (stdair::PosChannel& iPosChannel,
129 const YieldRuleStruct& iYieldRuleStruct) {
132 const stdair::Time_T& lTimeRangeStart
133 = iYieldRuleStruct.getTimeRangeStart ();
134 const stdair::Time_T& lTimeRangeEnd
135 = iYieldRuleStruct.getTimeRangeEnd ();
136 const stdair::TimePeriodKey lYieldTimePeriodKey (lTimeRangeStart,
142 stdair::TimePeriod* lYieldTimePeriod_ptr = stdair::BomManager::
143 getObjectPtr<stdair::TimePeriod> (iPosChannel,
144 lYieldTimePeriodKey.toString());
145 if (lYieldTimePeriod_ptr == NULL) {
146 lYieldTimePeriod_ptr = &stdair::FacBom<stdair::TimePeriod>::
147 instance().create (lYieldTimePeriodKey);
148 stdair::FacBomManager::
149 addToListAndMap (iPosChannel, *lYieldTimePeriod_ptr);
150 stdair::FacBomManager::
151 linkWithParent (iPosChannel, *lYieldTimePeriod_ptr);
154 assert (lYieldTimePeriod_ptr != NULL);
156 stdair::TimePeriod& lTimeRange = *lYieldTimePeriod_ptr;
159 createYieldFeatures (lTimeRange, iYieldRuleStruct);
164 void YieldRuleGenerator::
165 createYieldFeatures (stdair::TimePeriod& iTimePeriod,
166 const YieldRuleStruct& iYieldRuleStruct) {
169 const stdair::TripType_T& lTripType = iYieldRuleStruct.getTripType ();
170 stdair::CabinCode_T lCabinCode = iYieldRuleStruct.getCabinCode ();
171 const stdair::YieldFeaturesKey lYieldFeaturesKey (lTripType, lCabinCode);
176 stdair::YieldFeatures* lYieldFeatures_ptr = stdair::BomManager::
177 getObjectPtr<stdair::YieldFeatures > (iTimePeriod,
178 lYieldFeaturesKey.toString());
179 if (lYieldFeatures_ptr == NULL) {
180 lYieldFeatures_ptr = &stdair::FacBom<stdair::YieldFeatures>::
181 instance().create (lYieldFeaturesKey);
182 stdair::FacBomManager::
183 addToListAndMap (iTimePeriod, *lYieldFeatures_ptr);
184 stdair::FacBomManager::
185 linkWithParent (iTimePeriod, *lYieldFeatures_ptr);
188 assert (lYieldFeatures_ptr != NULL);
190 stdair::YieldFeatures& lYieldFeatures = *lYieldFeatures_ptr;
193 createAirlineClassList (lYieldFeatures, iYieldRuleStruct);
198 void YieldRuleGenerator::
199 createAirlineClassList (stdair::YieldFeatures& iYieldFeatures,
200 const YieldRuleStruct& iYieldRuleStruct) {
203 const unsigned int lAirlineListSize =
204 iYieldRuleStruct.getAirlineListSize();
205 const unsigned int lClassCodeListSize =
206 iYieldRuleStruct.getClassCodeListSize();
207 assert (lAirlineListSize == lClassCodeListSize);
208 const stdair::AirlineClassListKey
209 lAirlineClassListKey (iYieldRuleStruct.getAirlineList() ,
210 iYieldRuleStruct.getClassCodeList());
211 const stdair::Yield_T& lYield = iYieldRuleStruct.getYield ();
215 stdair::AirlineClassList* lAirlineClassList_ptr =
216 &stdair::FacBom<stdair::AirlineClassList>::instance().
217 create(lAirlineClassListKey);
218 lAirlineClassList_ptr->setYield (lYield);
219 stdair::FacBomManager::addToListAndMap (iYieldFeatures,
220 *lAirlineClassList_ptr);
221 stdair::FacBomManager::linkWithParent (iYieldFeatures,
222 *lAirlineClassList_ptr);