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 AIRSCHED_Service::AIRSCHED_Service() : _airschedServiceContext (NULL) {
36 AIRSCHED_Service::AIRSCHED_Service (
const AIRSCHED_Service& iService)
37 : _airschedServiceContext (NULL) {
42 AIRSCHED_Service::AIRSCHED_Service (
const stdair::BasLogParams& iLogParams)
43 : _airschedServiceContext (NULL) {
46 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
47 initStdAirService (iLogParams);
54 const bool ownStdairService =
true;
55 addStdAirService (lSTDAIR_Service_ptr, ownStdairService);
58 initAirschedService();
62 AIRSCHED_Service::AIRSCHED_Service (
const stdair::BasLogParams& iLogParams,
63 const stdair::BasDBParams& iDBParams)
64 : _airschedServiceContext (NULL) {
67 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
68 initStdAirService (iLogParams, iDBParams);
75 const bool ownStdairService =
true;
76 addStdAirService (lSTDAIR_Service_ptr, ownStdairService);
79 initAirschedService();
84 AIRSCHED_Service (stdair::STDAIR_ServicePtr_T ioSTDAIRServicePtr)
85 : _airschedServiceContext (NULL) {
92 const bool doesNotOwnStdairService =
false;
93 addStdAirService (ioSTDAIRServicePtr, doesNotOwnStdairService);
96 initAirschedService();
106 void AIRSCHED_Service::finalise() {
107 assert (_airschedServiceContext != NULL);
109 _airschedServiceContext->reset();
113 void AIRSCHED_Service::initServiceContext() {
115 AIRSCHED_ServiceContext& lAIRSCHED_ServiceContext =
117 _airschedServiceContext = &lAIRSCHED_ServiceContext;
121 void AIRSCHED_Service::
122 addStdAirService (stdair::STDAIR_ServicePtr_T ioSTDAIR_Service_ptr,
123 const bool iOwnStdairService) {
126 assert (_airschedServiceContext != NULL);
127 AIRSCHED_ServiceContext& lAIRSCHED_ServiceContext =
128 *_airschedServiceContext;
131 lAIRSCHED_ServiceContext.setSTDAIR_Service (ioSTDAIR_Service_ptr,
136 stdair::STDAIR_ServicePtr_T AIRSCHED_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 AIRSCHED_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 AIRSCHED_Service::initAirschedService() {
181 assert (_airschedServiceContext != NULL);
183 *_airschedServiceContext;
184 stdair::STDAIR_Service& lSTDAIR_Service =
185 lAIRSCHED_ServiceContext.getSTDAIR_Service();
186 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
189 stdair::BasChronometer lINVGeneration; lINVGeneration.start();
191 const double lGenerationMeasure = lINVGeneration.elapsed();
194 STDAIR_LOG_DEBUG (
"Inventory generation time: " << lGenerationMeasure);
200 const stdair::Filename_T& iODInputFilename) {
206 assert (_airschedServiceContext != NULL);
208 *_airschedServiceContext;
209 stdair::STDAIR_Service& lSTDAIR_Service =
210 lAIRSCHED_ServiceContext.getSTDAIR_Service();
211 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
214 stdair::BasChronometer lOnDGeneration; lOnDGeneration.start();
216 const double lGenerationMeasure = lOnDGeneration.elapsed();
219 STDAIR_LOG_DEBUG (
"O&D generation time: " << lGenerationMeasure);
226 if (_airschedServiceContext == NULL) {
227 throw stdair::NonInitialisedServiceException (
"The AirSched service has "
228 "not been initialised");
230 assert (_airschedServiceContext != NULL);
235 *_airschedServiceContext;
236 const bool doesOwnStdairService =
237 lAIRSCHED_ServiceContext.getOwnStdairServiceFlag();
240 stdair::STDAIR_Service& lSTDAIR_Service =
241 lAIRSCHED_ServiceContext.getSTDAIR_Service();
247 if (doesOwnStdairService ==
true) {
249 lSTDAIR_Service.buildSampleBom();
268 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
275 const stdair::FlightNumber_T& iFlightNumber,
276 const stdair::Date_T& iDepartureDate)
const {
279 if (_airschedServiceContext == NULL) {
280 throw stdair::NonInitialisedServiceException (
"The AirSched service "
281 "has not been initialised");
283 assert (_airschedServiceContext != NULL);
287 *_airschedServiceContext;
288 stdair::STDAIR_Service& lSTDAIR_Service =
289 lAIRSCHED_ServiceContext.getSTDAIR_Service();
292 return lSTDAIR_Service.jsonExport (iAirlineCode, iFlightNumber,
300 if (_airschedServiceContext == NULL) {
301 throw stdair::NonInitialisedServiceException (
"The AirSched service has "
302 "not been initialised");
304 assert (_airschedServiceContext != NULL);
308 *_airschedServiceContext;
309 stdair::STDAIR_Service& lSTDAIR_Service =
310 lAIRSCHED_ServiceContext.getSTDAIR_Service();
313 return lSTDAIR_Service.csvDisplay();
319 const stdair::FlightNumber_T& iFlightNumber,
320 const stdair::Date_T& iDepartureDate)
const {
323 if (_airschedServiceContext == NULL) {
324 throw stdair::NonInitialisedServiceException (
"The AirSched service has "
325 "not been initialised");
327 assert (_airschedServiceContext != NULL);
331 *_airschedServiceContext;
332 stdair::STDAIR_Service& lSTDAIR_Service =
333 lAIRSCHED_ServiceContext.getSTDAIR_Service();
336 return lSTDAIR_Service.csvDisplay (iAirlineCode, iFlightNumber,
344 if (_airschedServiceContext == NULL) {
345 throw stdair::NonInitialisedServiceException (
"The AirSched service has "
346 "not been initialised");
348 assert (_airschedServiceContext != NULL);
352 *_airschedServiceContext;
353 stdair::STDAIR_Service& lSTDAIR_Service =
354 lAIRSCHED_ServiceContext.getSTDAIR_Service();
355 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
358 stdair::BasChronometer lSimulateChronometer; lSimulateChronometer.start();
360 const double lSimulateMeasure = lSimulateChronometer.elapsed();
363 STDAIR_LOG_DEBUG (
"Simulation: " << lSimulateMeasure <<
" - "
364 << lAIRSCHED_ServiceContext.display());
370 const stdair::BookingRequestStruct& iBookingRequest) {
372 if (_airschedServiceContext == NULL) {
373 throw stdair::NonInitialisedServiceException (
"The AirSched service has "
374 "not been initialised");
376 assert (_airschedServiceContext != NULL);
380 *_airschedServiceContext;
381 stdair::STDAIR_Service& lSTDAIR_Service =
382 lAIRSCHED_ServiceContext.getSTDAIR_Service();
383 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
386 stdair::BasChronometer lBuildChronometer; lBuildChronometer.start();
388 lBomRoot, iBookingRequest);
389 const double lBuildMeasure = lBuildChronometer.elapsed();
392 STDAIR_LOG_DEBUG (
"Segment-path build: " << lBuildMeasure <<
" - "
393 << lAIRSCHED_ServiceContext.display());