7 #include <stdair/bom/BomManager.hpp>
8 #include <stdair/bom/BomRoot.hpp>
9 #include <stdair/factory/FacBomManager.hpp>
10 #include <stdair/service/Logger.hpp>
11 #include <stdair/bom/AirportPair.hpp>
12 #include <stdair/bom/PosChannel.hpp>
13 #include <stdair/bom/DatePeriod.hpp>
14 #include <stdair/bom/TimePeriod.hpp>
15 #include <stdair/bom/FareFeatures.hpp>
16 #include <stdair/bom/AirlineClassList.hpp>
24 void FareRuleGenerator::
25 createAirportPair (stdair::BomRoot& ioBomRoot,
26 const FareRuleStruct& iFareRuleStruct) {
29 const stdair::AirportCode_T& lBoardPoint = iFareRuleStruct.getOrigin ();
30 const stdair::AirportCode_T& lOffPoint =
31 iFareRuleStruct.getDestination ();
32 const stdair::AirportPairKey lAirportPairKey (lBoardPoint, lOffPoint);
37 stdair::AirportPair* lAirportPair_ptr = stdair::BomManager::
38 getObjectPtr<stdair::AirportPair> (ioBomRoot, lAirportPairKey.toString());
39 if (lAirportPair_ptr == NULL) {
41 &stdair::FacBom<stdair::AirportPair>::instance().
42 create (lAirportPairKey);
43 stdair::FacBomManager::addToListAndMap (ioBomRoot, *lAirportPair_ptr);
44 stdair::FacBomManager::linkWithParent (ioBomRoot, *lAirportPair_ptr);
47 assert (lAirportPair_ptr != NULL);
49 stdair::AirportPair& lAirportPair = *lAirportPair_ptr;
52 createDateRange (lAirportPair, iFareRuleStruct);
57 void FareRuleGenerator::
58 createDateRange (stdair::AirportPair& iAirportPair,
59 const FareRuleStruct& iFareRuleStruct) {
62 const stdair::Date_T& lDateRangeStart =
63 iFareRuleStruct.getDateRangeStart ();
64 const stdair::Date_T& lDateRangeEnd =
65 iFareRuleStruct.getDateRangeEnd ();
66 const stdair::DatePeriod_T lDatePeriod (lDateRangeStart, lDateRangeEnd);
67 const stdair::DatePeriodKey lFareDatePeriodKey (lDatePeriod);
72 stdair::DatePeriod* lFareDatePeriod_ptr = stdair::BomManager::
73 getObjectPtr<stdair::DatePeriod> (iAirportPair,
74 lFareDatePeriodKey.toString());
75 if (lFareDatePeriod_ptr == NULL) {
76 lFareDatePeriod_ptr = &stdair::FacBom<stdair::DatePeriod>::instance().
77 create (lFareDatePeriodKey);
78 stdair::FacBomManager::addToListAndMap (iAirportPair,
79 *lFareDatePeriod_ptr);
80 stdair::FacBomManager::linkWithParent (iAirportPair,
81 *lFareDatePeriod_ptr);
84 assert (lFareDatePeriod_ptr != NULL);
86 stdair::DatePeriod& lDateRange = *lFareDatePeriod_ptr;
89 createPOSChannel (lDateRange, iFareRuleStruct);
94 void FareRuleGenerator::
95 createPOSChannel (stdair::DatePeriod& iDatePeriod,
96 const FareRuleStruct& iFareRuleStruct) {
99 const stdair::CityCode_T& lPosition = iFareRuleStruct.getPOS ();
100 const stdair::ChannelLabel_T& lChannel =
101 iFareRuleStruct.getChannel ();
102 const stdair::PosChannelKey lFarePosChannelKey (lPosition, lChannel);
107 stdair::PosChannel* lFarePosChannel_ptr = stdair::BomManager::
108 getObjectPtr<stdair::PosChannel> (iDatePeriod,
109 lFarePosChannelKey.toString());
110 if (lFarePosChannel_ptr == NULL) {
111 lFarePosChannel_ptr = &stdair::FacBom<stdair::PosChannel>::instance().
112 create (lFarePosChannelKey);
113 stdair::FacBomManager::addToListAndMap (iDatePeriod,
114 *lFarePosChannel_ptr);
115 stdair::FacBomManager::linkWithParent (iDatePeriod,
116 *lFarePosChannel_ptr);
119 assert (lFarePosChannel_ptr != NULL);
121 stdair::PosChannel& lPosChannel = *lFarePosChannel_ptr;
124 createTimeRange (lPosChannel, iFareRuleStruct);
130 void FareRuleGenerator::
131 createTimeRange (stdair::PosChannel& iPosChannel,
132 const FareRuleStruct& iFareRuleStruct) {
135 const stdair::Time_T& lTimeRangeStart =
136 iFareRuleStruct.getTimeRangeStart ();
137 const stdair::Time_T& lTimeRangeEnd =
138 iFareRuleStruct.getTimeRangeEnd ();
139 const stdair::TimePeriodKey lFareTimePeriodKey (lTimeRangeStart,
145 stdair::TimePeriod* lFareTimePeriod_ptr = stdair::BomManager::
146 getObjectPtr<stdair::TimePeriod> (iPosChannel,
147 lFareTimePeriodKey.toString());
148 if (lFareTimePeriod_ptr == NULL) {
149 lFareTimePeriod_ptr = &stdair::FacBom<stdair::TimePeriod>::instance().
150 create (lFareTimePeriodKey);
151 stdair::FacBomManager::addToListAndMap (iPosChannel,
152 *lFareTimePeriod_ptr);
153 stdair::FacBomManager::linkWithParent (iPosChannel,
154 *lFareTimePeriod_ptr);
157 assert (lFareTimePeriod_ptr != NULL);
159 stdair::TimePeriod& lTimeRange = *lFareTimePeriod_ptr;
162 createFareFeatures (lTimeRange, iFareRuleStruct);
167 void FareRuleGenerator::
168 createFareFeatures (stdair::TimePeriod& iTimePeriod,
169 const FareRuleStruct& iFareRuleStruct) {
172 const stdair::TripType_T& lTripType =
173 iFareRuleStruct.getTripType ();
174 const stdair::DayDuration_T& lAdvancePurchase =
175 iFareRuleStruct.getAdvancePurchase ();
176 const stdair::SaturdayStay_T& lSaturdayStay =
177 iFareRuleStruct.getSaturdayStay ();
178 const stdair::ChangeFees_T& lChangeFees =
179 iFareRuleStruct.getChangeFees ();
180 const stdair::NonRefundable_T& lNonRefundable =
181 iFareRuleStruct.getNonRefundable ();
182 const stdair::DayDuration_T& lMinimumStay =
183 iFareRuleStruct.getMinimumStay ();
184 const stdair::FareFeaturesKey
185 lFareFeaturesKey (lTripType, lAdvancePurchase, lSaturdayStay,
186 lChangeFees, lNonRefundable, lMinimumStay);
191 stdair::FareFeatures* lFareFeatures_ptr = stdair::BomManager::
192 getObjectPtr<stdair::FareFeatures> (iTimePeriod,
193 lFareFeaturesKey.toString());
194 if (lFareFeatures_ptr == NULL) {
195 lFareFeatures_ptr = &stdair::FacBom<stdair::FareFeatures>::instance().
196 create (lFareFeaturesKey);
197 assert(lFareFeatures_ptr != NULL);
198 stdair::FacBomManager::addToListAndMap (iTimePeriod,
200 stdair::FacBomManager::linkWithParent (iTimePeriod,
204 assert(lFareFeatures_ptr != NULL);
206 stdair::FareFeatures& lFareFeatures = *lFareFeatures_ptr;
209 createAirlineClassList (lFareFeatures, iFareRuleStruct);
214 void FareRuleGenerator::
215 createAirlineClassList (stdair::FareFeatures& iFareFeatures,
216 const FareRuleStruct& iFareRuleStruct) {
219 const unsigned int lAirlineListSize =
220 iFareRuleStruct.getAirlineListSize();
221 const unsigned int lClassCodeListSize =
222 iFareRuleStruct.getClassCodeListSize();
223 assert (lAirlineListSize == lClassCodeListSize);
224 const stdair::AirlineClassListKey
225 lAirlineClassListKey (iFareRuleStruct.getAirlineList(),
226 iFareRuleStruct.getClassCodeList());
227 const stdair::Fare_T& lFare = iFareRuleStruct.getFare ();
231 stdair::AirlineClassList* lAirlineClassList_ptr =
232 &stdair::FacBom<stdair::AirlineClassList>::instance().
233 create (lAirlineClassListKey);
234 lAirlineClassList_ptr->setFare(lFare);
235 stdair::FacBomManager::addToListAndMap (iFareFeatures,
236 *lAirlineClassList_ptr);
237 stdair::FacBomManager::linkWithParent(iFareFeatures,
238 *lAirlineClassList_ptr);