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 if (_simfqtServiceContext == NULL) {
175 throw stdair::NonInitialisedServiceException (
"The SimFQT service "
176 "has not been initialised");
178 assert (_simfqtServiceContext != NULL);
183 const bool doesOwnStdairService =
184 lSIMFQT_ServiceContext.getOwnStdairServiceFlag();
187 stdair::STDAIR_Service& lSTDAIR_Service =
188 lSIMFQT_ServiceContext.getSTDAIR_Service();
191 stdair::BomRoot& lPersistentBomRoot =
192 lSTDAIR_Service.getPersistentBomRoot();
216 if (doesOwnStdairService ==
true) {
226 if (_simfqtServiceContext == NULL) {
227 throw stdair::NonInitialisedServiceException (
"The SimFQT service "
228 "has not been initialised");
230 assert (_simfqtServiceContext != NULL);
235 const bool doesOwnStdairService =
236 lSIMFQT_ServiceContext.getOwnStdairServiceFlag();
239 stdair::STDAIR_Service& lSTDAIR_Service =
240 lSIMFQT_ServiceContext.getSTDAIR_Service();
243 stdair::BomRoot& lPersistentBomRoot =
244 lSTDAIR_Service.getPersistentBomRoot();
250 if (doesOwnStdairService ==
true) {
252 lSTDAIR_Service.buildSampleBom();
272 if (doesOwnStdairService ==
true) {
282 if (_simfqtServiceContext == NULL) {
283 throw stdair::NonInitialisedServiceException (
"The SimFQT service "
284 "has not been initialised");
286 assert (_simfqtServiceContext != NULL);
291 const bool doesOwnStdairService =
292 lSIMFQT_ServiceContext.getOwnStdairServiceFlag();
295 stdair::STDAIR_Service& lSTDAIR_Service =
296 lSIMFQT_ServiceContext.getSTDAIR_Service();
302 if (doesOwnStdairService ==
true) {
304 lSTDAIR_Service.clonePersistentBom ();
310 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
323 if (_simfqtServiceContext == NULL) {
324 throw stdair::NonInitialisedServiceException (
"The Simfqt service has not "
327 assert (_simfqtServiceContext != NULL);
332 stdair::STDAIR_Service& lSTDAIR_Service =
333 lSIMFQT_ServiceContext.getSTDAIR_Service();
336 stdair::BookingRequestStruct oBookingRequest =
337 lSTDAIR_Service.buildSampleBookingRequest (isForCRS);
339 return oBookingRequest;
347 if (_simfqtServiceContext == NULL) {
348 throw stdair::NonInitialisedServiceException (
"The Simfqt service has not "
351 assert (_simfqtServiceContext != NULL);
356 stdair::STDAIR_Service& lSTDAIR_Service =
357 lSIMFQT_ServiceContext.getSTDAIR_Service();
360 lSTDAIR_Service.buildSampleTravelSolutionForPricing (ioTravelSolutionList);
368 if (_simfqtServiceContext == NULL) {
369 throw stdair::NonInitialisedServiceException (
"The SimFQT service "
370 "has not been initialised");
372 assert (_simfqtServiceContext != NULL);
377 stdair::STDAIR_Service& lSTDAIR_Service =
378 lSIMFQT_ServiceContext.getSTDAIR_Service();
382 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
385 std::ostringstream oCSVStr;
386 stdair::BomDisplay::csvSimFQTAirRACDisplay (oCSVStr, lBomRoot);
387 return oCSVStr.str();
392 csvDisplay (
const stdair::TravelSolutionList_T& ioTravelSolutionList)
const {
395 if (_simfqtServiceContext == NULL) {
396 throw stdair::NonInitialisedServiceException (
"The Simfqt service has not "
399 assert (_simfqtServiceContext != NULL);
405 stdair::STDAIR_Service& lSTDAIR_Service =
406 lSIMFQT_ServiceContext.getSTDAIR_Service();
409 return lSTDAIR_Service.csvDisplay (ioTravelSolutionList);
415 const stdair::AirportCode_T& iDestination,
416 const stdair::Date_T& iDepartureDate)
const {
419 if (_simfqtServiceContext == NULL) {
420 throw stdair::NonInitialisedServiceException (
"The Simfqt service "
421 "has not been initialised");
423 assert (_simfqtServiceContext != NULL);
428 stdair::STDAIR_Service& lSTDAIR_Service =
429 lSIMFQT_ServiceContext.getSTDAIR_Service();
432 return lSTDAIR_Service.csvDisplay (iOrigin, iDestination,
440 if (_simfqtServiceContext == NULL) {
441 throw stdair::NonInitialisedServiceException (
"The Simfqt service "
442 "has not been initialised");
444 assert (_simfqtServiceContext != NULL);
449 stdair::STDAIR_Service& lSTDAIR_Service =
450 lSIMFQT_ServiceContext.getSTDAIR_Service();
453 return lSTDAIR_Service.listAirportPairDateRange ();
458 check (
const stdair::AirportCode_T& iOrigin,
459 const stdair::AirportCode_T& iDestination,
460 const stdair::Date_T& iDepartureDate)
const {
461 std::ostringstream oFlightListStr;
463 if (_simfqtServiceContext == NULL) {
464 throw stdair::NonInitialisedServiceException (
"The Simfqt service "
465 "has not been initialised");
467 assert (_simfqtServiceContext != NULL);
471 stdair::STDAIR_Service& lSTDAIR_Service =
472 lSIMFQT_ServiceContext.getSTDAIR_Service();
475 return lSTDAIR_Service.check (iOrigin, iDestination, iDepartureDate);
481 stdair::TravelSolutionList_T& ioTravelSolutionList) {
484 if (_simfqtServiceContext == NULL) {
485 throw stdair::NonInitialisedServiceException (
"The SimFQT service "
486 "has not been initialised");
488 assert (_simfqtServiceContext != NULL);
493 stdair::STDAIR_Service& lSTDAIR_Service =
494 lSIMFQT_ServiceContext.getSTDAIR_Service();
498 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
501 stdair::BasChronometer lFareQuoteRetrievalChronometer;
502 lFareQuoteRetrievalChronometer.start();
503 FareQuoter::priceQuote (iBookingRequest, ioTravelSolutionList, lBomRoot);
506 const double lFareQuoteRetrievalMeasure =
507 lFareQuoteRetrievalChronometer.elapsed();
508 STDAIR_LOG_DEBUG (
"Fare Quote retrieving: " << lFareQuoteRetrievalMeasure
509 <<
" - " << lSIMFQT_ServiceContext.display());