8 #include <boost/make_shared.hpp>
10 #include <stdair/basic/BasChronometer.hpp>
11 #include <stdair/bom/BomManager.hpp>
12 #include <stdair/bom/BookingRequestStruct.hpp>
13 #include <stdair/bom/TravelSolutionStruct.hpp>
14 #include <stdair/service/Logger.hpp>
15 #include <stdair/STDAIR_Service.hpp>
31 AIRTSP_Service::AIRTSP_Service() : _airtspServiceContext (NULL) {
36 AIRTSP_Service::AIRTSP_Service (
const AIRTSP_Service& iService)
37 : _airtspServiceContext (NULL) {
42 AIRTSP_Service::AIRTSP_Service (
const stdair::BasLogParams& iLogParams)
43 : _airtspServiceContext (NULL) {
46 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
47 initStdAirService (iLogParams);
54 const bool ownStdairService =
true;
55 addStdAirService (lSTDAIR_Service_ptr, ownStdairService);
62 AIRTSP_Service::AIRTSP_Service (
const stdair::BasLogParams& iLogParams,
63 const stdair::BasDBParams& iDBParams)
64 : _airtspServiceContext (NULL) {
67 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
68 initStdAirService (iLogParams, iDBParams);
75 const bool ownStdairService =
true;
76 addStdAirService (lSTDAIR_Service_ptr, ownStdairService);
84 AIRTSP_Service (stdair::STDAIR_ServicePtr_T ioSTDAIRServicePtr)
85 : _airtspServiceContext (NULL) {
92 const bool doesNotOwnStdairService =
false;
93 addStdAirService (ioSTDAIRServicePtr, doesNotOwnStdairService);
106 void AIRTSP_Service::finalise() {
107 assert (_airtspServiceContext != NULL);
109 _airtspServiceContext->reset();
113 void AIRTSP_Service::initServiceContext() {
115 AIRTSP_ServiceContext& lAIRTSP_ServiceContext =
117 _airtspServiceContext = &lAIRTSP_ServiceContext;
121 void AIRTSP_Service::
122 addStdAirService (stdair::STDAIR_ServicePtr_T ioSTDAIR_Service_ptr,
123 const bool iOwnStdairService) {
126 assert (_airtspServiceContext != NULL);
127 AIRTSP_ServiceContext& lAIRTSP_ServiceContext =
128 *_airtspServiceContext;
131 lAIRTSP_ServiceContext.setSTDAIR_Service (ioSTDAIR_Service_ptr,
136 stdair::STDAIR_ServicePtr_T AIRTSP_Service::
137 initStdAirService (
const stdair::BasLogParams& iLogParams) {
146 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
147 boost::make_shared<stdair::STDAIR_Service> (iLogParams);
149 return lSTDAIR_Service_ptr;
153 stdair::STDAIR_ServicePtr_T AIRTSP_Service::
154 initStdAirService (
const stdair::BasLogParams& iLogParams,
155 const stdair::BasDBParams& iDBParams) {
164 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
165 boost::make_shared<stdair::STDAIR_Service> (iLogParams, iDBParams);
167 return lSTDAIR_Service_ptr;
171 void AIRTSP_Service::initAirtspService() {
178 parseAndLoad (
const stdair::ScheduleFilePath& iScheduleInputFilePath) {
181 assert (_airtspServiceContext != NULL);
183 *_airtspServiceContext;
184 const bool doesOwnStdairService =
185 lAIRTSP_ServiceContext.getOwnStdairServiceFlag();
188 stdair::STDAIR_Service& lSTDAIR_Service =
189 lAIRTSP_ServiceContext.getSTDAIR_Service();
190 stdair::BomRoot& lPersistentBomRoot =
191 lSTDAIR_Service.getPersistentBomRoot();
196 stdair::BasChronometer lINVGeneration; lINVGeneration.start();
212 const double lGenerationMeasure = lINVGeneration.elapsed();
218 if (doesOwnStdairService ==
true) {
225 STDAIR_LOG_DEBUG (
"Inventory generation time: " << lGenerationMeasure);
231 const stdair::ODFilePath& iODInputFilePath) {
237 assert (_airtspServiceContext != NULL);
239 *_airtspServiceContext;
240 const bool doesOwnStdairService =
241 lAIRTSP_ServiceContext.getOwnStdairServiceFlag();
244 stdair::STDAIR_Service& lSTDAIR_Service =
245 lAIRTSP_ServiceContext.getSTDAIR_Service();
246 stdair::BomRoot& lPersistentBomRoot =
247 lSTDAIR_Service.getPersistentBomRoot();
252 stdair::BasChronometer lOnDGeneration; lOnDGeneration.start();
254 const double lGenerationMeasure = lOnDGeneration.elapsed();
268 if (doesOwnStdairService ==
true) {
271 lSTDAIR_Service.clonePersistentBom ();
278 stdair::BomRoot& lBomRoot =
279 lSTDAIR_Service.getBomRoot();
283 STDAIR_LOG_DEBUG (
"O&D generation time: " << lGenerationMeasure);
290 if (_airtspServiceContext == NULL) {
291 throw stdair::NonInitialisedServiceException (
"The Airtsp service has "
292 "not been initialised");
294 assert (_airtspServiceContext != NULL);
299 *_airtspServiceContext;
300 const bool doesOwnStdairService =
301 lAIRTSP_ServiceContext.getOwnStdairServiceFlag();
304 stdair::STDAIR_Service& lSTDAIR_Service =
305 lAIRTSP_ServiceContext.getSTDAIR_Service();
311 if (doesOwnStdairService ==
true) {
313 lSTDAIR_Service.buildSampleBom();
328 stdair::BomRoot& lPersistentBomRoot =
329 lSTDAIR_Service.getPersistentBomRoot();
336 if (doesOwnStdairService ==
true) {
347 if (_airtspServiceContext == NULL) {
348 throw stdair::NonInitialisedServiceException (
"The Airtsp service has "
349 "not been initialised");
351 assert (_airtspServiceContext != NULL);
356 *_airtspServiceContext;
357 const bool doesOwnStdairService =
358 lAIRTSP_ServiceContext.getOwnStdairServiceFlag();
361 stdair::STDAIR_Service& lSTDAIR_Service =
362 lAIRTSP_ServiceContext.getSTDAIR_Service();
368 if (doesOwnStdairService ==
true) {
371 lSTDAIR_Service.clonePersistentBom ();
378 stdair::BomRoot& lBomRoot =
379 lSTDAIR_Service.getBomRoot();
387 if (_airtspServiceContext == NULL) {
388 throw stdair::NonInitialisedServiceException (
"The Airtsp service has "
389 "not been initialised");
391 assert (_airtspServiceContext != NULL);
402 const stdair::FlightNumber_T& iFlightNumber,
403 const stdair::Date_T& iDepartureDate)
const {
406 if (_airtspServiceContext == NULL) {
407 throw stdair::NonInitialisedServiceException (
"The Airtsp service "
408 "has not been initialised");
410 assert (_airtspServiceContext != NULL);
414 *_airtspServiceContext;
415 stdair::STDAIR_Service& lSTDAIR_Service =
416 lAIRTSP_ServiceContext.getSTDAIR_Service();
419 return lSTDAIR_Service.jsonExportFlightDateObjects (iAirlineCode,
428 if (_airtspServiceContext == NULL) {
429 throw stdair::NonInitialisedServiceException (
"The Airtsp service has "
430 "not been initialised");
432 assert (_airtspServiceContext != NULL);
436 *_airtspServiceContext;
437 stdair::STDAIR_Service& lSTDAIR_Service =
438 lAIRTSP_ServiceContext.getSTDAIR_Service();
439 const stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
442 return lSTDAIR_Service.csvDisplay(lBomRoot);
448 const stdair::FlightNumber_T& iFlightNumber,
449 const stdair::Date_T& iDepartureDate)
const {
452 if (_airtspServiceContext == NULL) {
453 throw stdair::NonInitialisedServiceException (
"The Airtsp service has "
454 "not been initialised");
456 assert (_airtspServiceContext != NULL);
460 *_airtspServiceContext;
461 stdair::STDAIR_Service& lSTDAIR_Service =
462 lAIRTSP_ServiceContext.getSTDAIR_Service();
465 return lSTDAIR_Service.csvDisplay (iAirlineCode, iFlightNumber,
473 if (_airtspServiceContext == NULL) {
474 throw stdair::NonInitialisedServiceException (
"The Airtsp service has "
475 "not been initialised");
477 assert (_airtspServiceContext != NULL);
481 *_airtspServiceContext;
482 stdair::STDAIR_Service& lSTDAIR_Service =
483 lAIRTSP_ServiceContext.getSTDAIR_Service();
484 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
487 stdair::BasChronometer lSimulateChronometer; lSimulateChronometer.start();
489 const double lSimulateMeasure = lSimulateChronometer.elapsed();
492 STDAIR_LOG_DEBUG (
"Simulation: " << lSimulateMeasure <<
" - "
493 << lAIRTSP_ServiceContext.display());
499 const stdair::BookingRequestStruct& iBookingRequest) {
501 if (_airtspServiceContext == NULL) {
502 throw stdair::NonInitialisedServiceException (
"The Airtsp service has "
503 "not been initialised");
505 assert (_airtspServiceContext != NULL);
509 *_airtspServiceContext;
510 stdair::STDAIR_Service& lSTDAIR_Service =
511 lAIRTSP_ServiceContext.getSTDAIR_Service();
512 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
515 stdair::BasChronometer lBuildChronometer; lBuildChronometer.start();
516 SegmentPathProvider::buildSegmentPathList (ioTravelSolutionList,
517 lBomRoot, iBookingRequest);
518 const double lBuildMeasure = lBuildChronometer.elapsed();
521 STDAIR_LOG_DEBUG (
"Segment-path build: " << lBuildMeasure <<
" - "
522 << lAIRTSP_ServiceContext.display());