7 #include <boost/make_shared.hpp>
9 #include <stdair/basic/BasChronometer.hpp>
10 #include <stdair/bom/BomDisplay.hpp>
11 #include <stdair/bom/TravelSolutionStruct.hpp>
12 #include <stdair/bom/BookingRequestStruct.hpp>
13 #include <stdair/service/Logger.hpp>
14 #include <stdair/STDAIR_Service.hpp>
26 SIMFQT_Service::SIMFQT_Service() : _simfqtServiceContext (NULL) {
31 SIMFQT_Service::SIMFQT_Service (
const SIMFQT_Service& iService) {
36 SIMFQT_Service::SIMFQT_Service (
const stdair::BasLogParams& iLogParams)
37 : _simfqtServiceContext (NULL) {
40 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
41 initStdAirService (iLogParams);
48 const bool ownStdairService =
true;
49 addStdAirService (lSTDAIR_Service_ptr, ownStdairService);
56 SIMFQT_Service::SIMFQT_Service (
const stdair::BasLogParams& iLogParams,
57 const stdair::BasDBParams& iDBParams)
58 : _simfqtServiceContext (NULL) {
61 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
62 initStdAirService (iLogParams, iDBParams);
69 const bool ownStdairService =
true;
70 addStdAirService (lSTDAIR_Service_ptr, ownStdairService);
78 SIMFQT_Service (stdair::STDAIR_ServicePtr_T ioSTDAIR_Service_ptr)
79 : _simfqtServiceContext (NULL) {
86 const bool doesNotOwnStdairService =
false;
87 addStdAirService (ioSTDAIR_Service_ptr, doesNotOwnStdairService);
100 void SIMFQT_Service::finalise() {
101 assert (_simfqtServiceContext != NULL);
103 _simfqtServiceContext->reset();
107 void SIMFQT_Service::initServiceContext() {
109 SIMFQT_ServiceContext& lSIMFQT_ServiceContext =
111 _simfqtServiceContext = &lSIMFQT_ServiceContext;
115 void SIMFQT_Service::
116 addStdAirService (stdair::STDAIR_ServicePtr_T ioSTDAIR_Service_ptr,
117 const bool iOwnStdairService) {
120 assert (_simfqtServiceContext != NULL);
121 SIMFQT_ServiceContext& lSIMFQT_ServiceContext = *_simfqtServiceContext;
124 lSIMFQT_ServiceContext.setSTDAIR_Service (ioSTDAIR_Service_ptr,
129 stdair::STDAIR_ServicePtr_T SIMFQT_Service::
130 initStdAirService (
const stdair::BasLogParams& iLogParams,
131 const stdair::BasDBParams& iDBParams) {
139 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
140 boost::make_shared<stdair::STDAIR_Service> (iLogParams, iDBParams);
141 assert (lSTDAIR_Service_ptr != NULL);
143 return lSTDAIR_Service_ptr;
147 stdair::STDAIR_ServicePtr_T SIMFQT_Service::
148 initStdAirService (
const stdair::BasLogParams& iLogParams) {
156 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
157 boost::make_shared<stdair::STDAIR_Service> (iLogParams);
158 assert (lSTDAIR_Service_ptr != NULL);
160 return lSTDAIR_Service_ptr;
164 void SIMFQT_Service::initSimfqtService() {
174 assert (_simfqtServiceContext != NULL);
176 stdair::STDAIR_Service& lSTDAIR_Service =
177 lSIMFQT_ServiceContext.getSTDAIR_Service();
178 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
188 if (_simfqtServiceContext == NULL) {
189 throw stdair::NonInitialisedServiceException (
"The SimFQT service "
190 "has not been initialised");
192 assert (_simfqtServiceContext != NULL);
197 const bool doesOwnStdairService =
198 lSIMFQT_ServiceContext.getOwnStdairServiceFlag();
201 stdair::STDAIR_Service& lSTDAIR_Service =
202 lSIMFQT_ServiceContext.getSTDAIR_Service();
208 if (doesOwnStdairService ==
true) {
210 lSTDAIR_Service.buildSampleBom();
234 if (_simfqtServiceContext == NULL) {
235 throw stdair::NonInitialisedServiceException (
"The Simfqt service has not "
238 assert (_simfqtServiceContext != NULL);
243 stdair::STDAIR_Service& lSTDAIR_Service =
244 lSIMFQT_ServiceContext.getSTDAIR_Service();
247 stdair::BookingRequestStruct oBookingRequest =
248 lSTDAIR_Service.buildSampleBookingRequest (isForCRS);
250 return oBookingRequest;
258 if (_simfqtServiceContext == NULL) {
259 throw stdair::NonInitialisedServiceException (
"The Simfqt service has not "
262 assert (_simfqtServiceContext != NULL);
267 stdair::STDAIR_Service& lSTDAIR_Service =
268 lSIMFQT_ServiceContext.getSTDAIR_Service();
271 lSTDAIR_Service.buildSampleTravelSolutionForPricing (ioTravelSolutionList);
279 if (_simfqtServiceContext == NULL) {
280 throw stdair::NonInitialisedServiceException (
"The SimFQT service "
281 "has not been initialised");
283 assert (_simfqtServiceContext != NULL);
288 stdair::STDAIR_Service& lSTDAIR_Service =
289 lSIMFQT_ServiceContext.getSTDAIR_Service();
293 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
296 std::ostringstream oCSVStr;
297 stdair::BomDisplay::csvSimFQTAirRACDisplay (oCSVStr, lBomRoot);
298 return oCSVStr.str();
303 csvDisplay (
const stdair::TravelSolutionList_T& ioTravelSolutionList)
const {
306 if (_simfqtServiceContext == NULL) {
307 throw stdair::NonInitialisedServiceException (
"The Simfqt service has not "
310 assert (_simfqtServiceContext != NULL);
316 stdair::STDAIR_Service& lSTDAIR_Service =
317 lSIMFQT_ServiceContext.getSTDAIR_Service();
320 return lSTDAIR_Service.csvDisplay (ioTravelSolutionList);
326 const stdair::AirportCode_T& iDestination,
327 const stdair::Date_T& iDepartureDate)
const {
330 if (_simfqtServiceContext == NULL) {
331 throw stdair::NonInitialisedServiceException (
"The Simfqt service "
332 "has not been initialised");
334 assert (_simfqtServiceContext != NULL);
339 stdair::STDAIR_Service& lSTDAIR_Service =
340 lSIMFQT_ServiceContext.getSTDAIR_Service();
343 return lSTDAIR_Service.csvDisplay (iOrigin, iDestination,
351 if (_simfqtServiceContext == NULL) {
352 throw stdair::NonInitialisedServiceException (
"The Simfqt service "
353 "has not been initialised");
355 assert (_simfqtServiceContext != NULL);
360 stdair::STDAIR_Service& lSTDAIR_Service =
361 lSIMFQT_ServiceContext.getSTDAIR_Service();
364 return lSTDAIR_Service.listAirportPairDateRange ();
369 check (
const stdair::AirportCode_T& iOrigin,
370 const stdair::AirportCode_T& iDestination,
371 const stdair::Date_T& iDepartureDate)
const {
372 std::ostringstream oFlightListStr;
374 if (_simfqtServiceContext == NULL) {
375 throw stdair::NonInitialisedServiceException (
"The Simfqt service "
376 "has not been initialised");
378 assert (_simfqtServiceContext != NULL);
382 stdair::STDAIR_Service& lSTDAIR_Service =
383 lSIMFQT_ServiceContext.getSTDAIR_Service();
386 return lSTDAIR_Service.check (iOrigin, iDestination, iDepartureDate);
392 stdair::TravelSolutionList_T& ioTravelSolutionList) {
395 if (_simfqtServiceContext == NULL) {
396 throw stdair::NonInitialisedServiceException (
"The SimFQT service "
397 "has not been initialised");
399 assert (_simfqtServiceContext != NULL);
404 stdair::STDAIR_Service& lSTDAIR_Service =
405 lSIMFQT_ServiceContext.getSTDAIR_Service();
409 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
412 stdair::BasChronometer lFareQuoteRetrievalChronometer;
413 lFareQuoteRetrievalChronometer.start();
414 FareQuoter::priceQuote (iBookingRequest, ioTravelSolutionList, lBomRoot);
417 const double lFareQuoteRetrievalMeasure =
418 lFareQuoteRetrievalChronometer.elapsed();
419 STDAIR_LOG_DEBUG (
"Fare Quote retrieving: " << lFareQuoteRetrievalMeasure
420 <<
" - " << lSIMFQT_ServiceContext.display());