SimCRS Logo  0.1.1
C++ Simulated Travel-Oriented Distribution System Library
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
SIMCRS_Service.cpp
Go to the documentation of this file.
1 // //////////////////////////////////////////////////////////////////////
2 // Import section
3 // //////////////////////////////////////////////////////////////////////
4 // STL
5 #include <cassert>
6 #include <sstream>
7 // Boost
8 #include <boost/make_shared.hpp>
9 // Standard Airline Object Model
10 #include <stdair/stdair_exceptions.hpp>
11 #include <stdair/stdair_basic_types.hpp>
12 #include <stdair/basic/BasChronometer.hpp>
13 #include <stdair/basic/BasFileMgr.hpp>
14 #include <stdair/bom/BomManager.hpp>
15 #include <stdair/bom/BookingRequestStruct.hpp>
16 #include <stdair/bom/TravelSolutionStruct.hpp>
17 #include <stdair/bom/CancellationStruct.hpp>
18 #include <stdair/bom/BomRoot.hpp>
19 #include <stdair/bom/Inventory.hpp>
20 #include <stdair/service/Logger.hpp>
21 #include <stdair/STDAIR_Service.hpp>
22 // Airline Inventory
23 #include <airinv/AIRINV_Master_Service.hpp>
24 // Airline Schedule
25 #include <airsched/AIRSCHED_Service.hpp>
26 // Fare Quote
27 #include <simfqt/SIMFQT_Service.hpp>
28 // SimCRS
34 
35 namespace SIMCRS {
36 
37  // ////////////////////////////////////////////////////////////////////
38  SIMCRS_Service::SIMCRS_Service() : _simcrsServiceContext (NULL) {
39  assert (false);
40  }
41 
42  // ////////////////////////////////////////////////////////////////////
43  SIMCRS_Service::SIMCRS_Service (const SIMCRS_Service& iService) {
44  assert (false);
45  }
46 
47  // ////////////////////////////////////////////////////////////////////
48  SIMCRS_Service::SIMCRS_Service (const stdair::BasLogParams& iLogParams,
49  const CRSCode_T& iCRSCode)
50  : _simcrsServiceContext (NULL) {
51 
52  // Initialise the StdAir service handler
53  stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
54  initStdAirService (iLogParams);
55 
56  // Initialise the service context
57  initServiceContext (iCRSCode);
58 
59  // Add the StdAir service context to the SimCRS service context
60  // \note SIMCRS owns the STDAIR service resources here.
61  const bool ownStdairService = true;
62  addStdAirService (lSTDAIR_Service_ptr, ownStdairService);
63 
64  // Initalise the SimFQT service.
65  initSIMFQTService();
66 
67  // Initalise the AirSched service.
68  initAIRSCHEDService();
69 
70  // Initalise the AirInv service.
71  initAIRINVService();
72 
73  // Initialise the (remaining of the) context
74  initSimcrsService();
75  }
76 
77  // ////////////////////////////////////////////////////////////////////
78  SIMCRS_Service::SIMCRS_Service (const stdair::BasLogParams& iLogParams,
79  const stdair::BasDBParams& iDBParams,
80  const CRSCode_T& iCRSCode)
81  : _simcrsServiceContext (NULL) {
82 
83  // Initialise the STDAIR service handler
84  stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
85  initStdAirService (iLogParams, iDBParams);
86 
87  // Initialise the service context
88  initServiceContext (iCRSCode);
89 
90  // Add the StdAir service context to the SIMCRS service context
91  // \note SIMCRS owns the STDAIR service resources here.
92  const bool ownStdairService = true;
93  addStdAirService (lSTDAIR_Service_ptr, ownStdairService);
94 
95  // Initalise the SIMFQT service.
96  initSIMFQTService();
97 
98  // Initalise the AIRSCHED service.
99  initAIRSCHEDService();
100 
101  // Initalise the AIRINV service.
102  initAIRINVService();
103 
104  // Initialise the (remaining of the) context
105  initSimcrsService();
106  }
107 
108  // ////////////////////////////////////////////////////////////////////
109  SIMCRS_Service::
110  SIMCRS_Service (stdair::STDAIR_ServicePtr_T ioSTDAIR_Service_ptr,
111  const CRSCode_T& iCRSCode)
112  : _simcrsServiceContext (NULL) {
113 
114  // Initialise the service context
115  initServiceContext (iCRSCode);
116 
117  // Store the STDAIR service object within the (AIRINV) service context
118  // \note AirInv does not own the STDAIR service resources here.
119  const bool doesNotOwnStdairService = false;
120  addStdAirService (ioSTDAIR_Service_ptr, doesNotOwnStdairService);
121 
122  // Initalise the SIMFQT service.
123  initSIMFQTService();
124 
125  // Initalise the AIRSCHED service.
126  initAIRSCHEDService();
127 
128  // Initalise the AIRINV service.
129  initAIRINVService();
130 
131  // Initialise the (remaining of the) context
132  initSimcrsService();
133  }
134 
135  // ////////////////////////////////////////////////////////////////////
137  // Delete/Clean all the objects from memory
138  finalise();
139  }
140 
141  // ////////////////////////////////////////////////////////////////////
142  void SIMCRS_Service::finalise() {
143  assert (_simcrsServiceContext != NULL);
144  // Reset the (Boost.)Smart pointer pointing on the STDAIR_Service object.
145  _simcrsServiceContext->reset();
146  }
147 
148  // ////////////////////////////////////////////////////////////////////
149  void SIMCRS_Service::initServiceContext (const CRSCode_T& iCRSCode) {
150  // Initialise the service context
151  SIMCRS_ServiceContext& lSIMCRS_ServiceContext =
153  _simcrsServiceContext = &lSIMCRS_ServiceContext;
154  }
155 
156  // ////////////////////////////////////////////////////////////////////
157  void SIMCRS_Service::
158  addStdAirService (stdair::STDAIR_ServicePtr_T ioSTDAIR_Service_ptr,
159  const bool iOwnStdairService) {
160 
161  // Retrieve the SimCRS service context
162  assert (_simcrsServiceContext != NULL);
163  SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
164 
165  // Store the StdAir service object within the (SimCRS) service context
166  lSIMCRS_ServiceContext.setSTDAIR_Service (ioSTDAIR_Service_ptr,
167  iOwnStdairService);
168  }
169 
170  // ////////////////////////////////////////////////////////////////////
171  stdair::STDAIR_ServicePtr_T SIMCRS_Service::
172  initStdAirService (const stdair::BasLogParams& iLogParams) {
173 
181  stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
182  boost::make_shared<stdair::STDAIR_Service> (iLogParams);
183 
184  return lSTDAIR_Service_ptr;
185  }
186 
187  // ////////////////////////////////////////////////////////////////////
188  stdair::STDAIR_ServicePtr_T SIMCRS_Service::
189  initStdAirService (const stdair::BasLogParams& iLogParams,
190  const stdair::BasDBParams& iDBParams) {
191 
199  stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
200  boost::make_shared<stdair::STDAIR_Service> (iLogParams, iDBParams);
201 
202  return lSTDAIR_Service_ptr;
203  }
204 
205  // ////////////////////////////////////////////////////////////////////
206  void SIMCRS_Service::initAIRSCHEDService() {
207 
208  // Retrieve the SimCRS service context
209  assert (_simcrsServiceContext != NULL);
210  SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
211 
212  // Retrieve the StdAir service context
213  stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
214  lSIMCRS_ServiceContext.getSTDAIR_ServicePtr();
215 
223  AIRSCHED::AIRSCHED_ServicePtr_T lAIRSCHED_Service_ptr =
224  boost::make_shared<AIRSCHED::AIRSCHED_Service> (lSTDAIR_Service_ptr);
225 
226  // Store the AIRSCHED service object within the (SimCRS) service context
227  lSIMCRS_ServiceContext.setAIRSCHED_Service (lAIRSCHED_Service_ptr);
228  }
229 
230  // ////////////////////////////////////////////////////////////////////
231  void SIMCRS_Service::initSIMFQTService() {
232 
233  // Retrieve the SimCRS service context
234  assert (_simcrsServiceContext != NULL);
235  SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
236 
237  // Retrieve the StdAir service context
238  stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
239  lSIMCRS_ServiceContext.getSTDAIR_ServicePtr();
240 
248  SIMFQT::SIMFQT_ServicePtr_T lSIMFQT_Service_ptr =
249  boost::make_shared<SIMFQT::SIMFQT_Service> (lSTDAIR_Service_ptr);
250 
251  // Store the SIMFQT service object within the (SimCRS) service context
252  lSIMCRS_ServiceContext.setSIMFQT_Service (lSIMFQT_Service_ptr);
253  }
254 
255  // ////////////////////////////////////////////////////////////////////
256  void SIMCRS_Service::initAIRINVService() {
257 
258  // Retrieve the SimCRS service context
259  assert (_simcrsServiceContext != NULL);
260  SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
261 
262  // Retrieve the StdAir service context
263  stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
264  lSIMCRS_ServiceContext.getSTDAIR_ServicePtr();
265 
273  AIRINV::AIRINV_Master_ServicePtr_T lAIRINV_Service_ptr =
274  boost::make_shared<AIRINV::AIRINV_Master_Service> (lSTDAIR_Service_ptr);
275 
276  // Store the AIRINV service object within the (SimCRS) service context
277  lSIMCRS_ServiceContext.setAIRINV_Service (lAIRINV_Service_ptr);
278  }
279 
280  // ////////////////////////////////////////////////////////////////////
281  void SIMCRS_Service::initSimcrsService() {
282  // Do nothing at this stage. A sample BOM tree may be built by
283  // calling the buildSampleBom() method
284  }
285 
286  // ////////////////////////////////////////////////////////////////////
287  void SIMCRS_Service::
288  parseAndLoad (const stdair::Filename_T& iScheduleInputFilename,
289  const stdair::Filename_T& iODInputFilename,
290  const AIRRAC::YieldFilePath& iYieldInputFilepath,
291  const SIMFQT::FareFilePath& iFareInputFilepath) {
292 
293  // Retrieve the SimCRS service context
294  assert (_simcrsServiceContext != NULL);
295  SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
296 
302  AIRSCHED::AIRSCHED_Service& lAIRSCHED_Service =
303  lSIMCRS_ServiceContext.getAIRSCHED_Service();
304  lAIRSCHED_Service.parseAndLoad (iScheduleInputFilename);
305 
312  AIRINV::AIRINV_Master_Service& lAIRINV_Service =
313  lSIMCRS_ServiceContext.getAIRINV_Service();
314  lAIRINV_Service.parseAndLoad (iScheduleInputFilename, iODInputFilename,
315  iYieldInputFilepath);
316 
320  SIMFQT::SIMFQT_Service& lSIMFQT_Service =
321  lSIMCRS_ServiceContext.getSIMFQT_Service();
322  lSIMFQT_Service.parseAndLoad (iFareInputFilepath);
323  }
324 
325  // ////////////////////////////////////////////////////////////////////
327 
328  // Retrieve the SimCRS service context
329  if (_simcrsServiceContext == NULL) {
330  throw stdair::NonInitialisedServiceException ("The SimCRS service "
331  "has not been initialised");
332  }
333  assert (_simcrsServiceContext != NULL);
334 
335  // Retrieve the SimCRS service context and whether it owns the Stdair
336  // service
337  SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
338  const bool doesOwnStdairService =
339  lSIMCRS_ServiceContext.getOwnStdairServiceFlag();
340 
341  // Retrieve the StdAir service object from the (SimCRS) service context
342  stdair::STDAIR_Service& lSTDAIR_Service =
343  lSIMCRS_ServiceContext.getSTDAIR_Service();
344 
349  if (doesOwnStdairService == true) {
350  //
351  lSTDAIR_Service.buildSampleBom();
352  }
353 
363  AIRSCHED::AIRSCHED_Service& lAIRSCHED_Service =
364  lSIMCRS_ServiceContext.getAIRSCHED_Service();
365  lAIRSCHED_Service.buildSampleBom();
366 
373  AIRINV::AIRINV_Master_Service& lAIRINV_Service =
374  lSIMCRS_ServiceContext.getAIRINV_Service();
375  lAIRINV_Service.buildSampleBom();
376 
380  SIMFQT::SIMFQT_Service& lSIMFQT_Service =
381  lSIMCRS_ServiceContext.getSIMFQT_Service();
382  lSIMFQT_Service.buildSampleBom();
383 
390  }
391 
392  // //////////////////////////////////////////////////////////////////////
393  void SIMCRS_Service::
394  buildSampleTravelSolutions(stdair::TravelSolutionList_T& ioTravelSolutionList){
395 
396  // Retrieve the SimCRS service context
397  if (_simcrsServiceContext == NULL) {
398  throw stdair::NonInitialisedServiceException ("The SimCRS service "
399  "has not been initialised");
400  }
401  assert (_simcrsServiceContext != NULL);
402 
403  // Retrieve the StdAir service object from the (SimCRS) service context
404  SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
405  stdair::STDAIR_Service& lSTDAIR_Service =
406  lSIMCRS_ServiceContext.getSTDAIR_Service();
407 
408  // Delegate the BOM building to the dedicated service
409  lSTDAIR_Service.buildSampleTravelSolutions (ioTravelSolutionList);
410  }
411 
412  // //////////////////////////////////////////////////////////////////////
413  stdair::BookingRequestStruct SIMCRS_Service::
414  buildSampleBookingRequest (const bool isForCRS) {
415 
416  // Retrieve the SimCRS service context
417  if (_simcrsServiceContext == NULL) {
418  throw stdair::NonInitialisedServiceException ("The SimCRS service "
419  "has not been initialised");
420  }
421  assert (_simcrsServiceContext != NULL);
422 
423  // Retrieve the StdAir service object from the (SimCRS) service context
424  SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
425  stdair::STDAIR_Service& lSTDAIR_Service =
426  lSIMCRS_ServiceContext.getSTDAIR_Service();
427 
428  // Delegate the BOM building to the dedicated service
429  return lSTDAIR_Service.buildSampleBookingRequest (isForCRS);
430  }
431 
432  // ////////////////////////////////////////////////////////////////////
433  std::string SIMCRS_Service::
434  jsonExport (const stdair::AirlineCode_T& iAirlineCode,
435  const stdair::FlightNumber_T& iFlightNumber,
436  const stdair::Date_T& iDepartureDate) const {
437 
438  // Retrieve the SimCRS service context
439  if (_simcrsServiceContext == NULL) {
440  throw stdair::NonInitialisedServiceException ("The SimCRS service "
441  "has not been initialised");
442  }
443  assert (_simcrsServiceContext != NULL);
444 
445  // Retrieve the StdAir service object from the (SimCRS) service context
446  SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
447  stdair::STDAIR_Service& lSTDAIR_Service =
448  lSIMCRS_ServiceContext.getSTDAIR_Service();
449 
450  // Delegate the JSON export to the dedicated service
451  return lSTDAIR_Service.jsonExport (iAirlineCode, iFlightNumber,
452  iDepartureDate);
453  }
454 
455  // ////////////////////////////////////////////////////////////////////
456  void SIMCRS_Service::
457  initSnapshotAndRMEvents (const stdair::Date_T& iStartDate,
458  const stdair::Date_T& iEndDate) {
459 
460  // Retrieve the SimCRS service context
461  if (_simcrsServiceContext == NULL) {
462  throw stdair::NonInitialisedServiceException ("The SimCRS service has "
463  "not been initialised");
464  }
465  assert (_simcrsServiceContext != NULL);
466  SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
467 
468  // Retrieve the AIRINV Master service.
469  AIRINV::AIRINV_Master_Service& lAIRINV_Master_Service =
470  lSIMCRS_ServiceContext.getAIRINV_Service();
471 
472  lAIRINV_Master_Service.initSnapshotAndRMEvents (iStartDate, iEndDate);
473  }
474 
475  // //////////////////////////////////////////////////////////////////////
476  std::string SIMCRS_Service::csvDisplay() const {
477 
478  // Retrieve the SimCRS service context
479  if (_simcrsServiceContext == NULL) {
480  throw stdair::NonInitialisedServiceException ("The SimCRS service "
481  "has not been initialised");
482  }
483  assert (_simcrsServiceContext != NULL);
484 
485  // Retrieve the StdAir service object from the (SimCRS) service context
486  SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
487  stdair::STDAIR_Service& lSTDAIR_Service =
488  lSIMCRS_ServiceContext.getSTDAIR_Service();
489 
490  // Delegate the BOM building to the dedicated service
491  return lSTDAIR_Service.csvDisplay();
492  }
493 
494  // //////////////////////////////////////////////////////////////////////
495  std::string SIMCRS_Service::
496  csvDisplay (const stdair::TravelSolutionList_T& ioTravelSolutionList) const {
497 
498  // Retrieve the SimCRS service context
499  if (_simcrsServiceContext == NULL) {
500  throw stdair::NonInitialisedServiceException ("The SimCRS service "
501  "has not been initialised");
502  }
503  assert (_simcrsServiceContext != NULL);
504 
505  // Retrieve the StdAir service object from the (SimCRS) service context
506  SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
507  stdair::STDAIR_Service& lSTDAIR_Service =
508  lSIMCRS_ServiceContext.getSTDAIR_Service();
509 
510  // Delegate the BOM building to the dedicated service
511  return lSTDAIR_Service.csvDisplay (ioTravelSolutionList);
512  }
513 
514  // ////////////////////////////////////////////////////////////////////
515  stdair::TravelSolutionList_T SIMCRS_Service::
516  calculateSegmentPathList(const stdair::BookingRequestStruct& iBookingRequest){
517 
518  // Retrieve the SimCRS service context
519  if (_simcrsServiceContext == NULL) {
520  throw stdair::NonInitialisedServiceException ("The SimCRS service "
521  "has not been initialised");
522  }
523  assert (_simcrsServiceContext != NULL);
524 
525  SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
526 
527  stdair::TravelSolutionList_T oTravelSolutionList;
528 
529  // Get a reference on the AIRSCHED service handler
530  AIRSCHED::AIRSCHED_Service& lAIRSCHED_Service =
531  lSIMCRS_ServiceContext.getAIRSCHED_Service();
532 
533  // Delegate the booking to the dedicated service
534  stdair::BasChronometer lTravelSolutionRetrievingChronometer;
535  lTravelSolutionRetrievingChronometer.start();
536 
537  lAIRSCHED_Service.buildSegmentPathList (oTravelSolutionList,
538  iBookingRequest);
539 
540  // DEBUG
541  const double lSegmentPathRetrievingMeasure =
542  lTravelSolutionRetrievingChronometer.elapsed();
543  STDAIR_LOG_DEBUG ("Travel solution retrieving: "
544  << lSegmentPathRetrievingMeasure << " - "
545  << lSIMCRS_ServiceContext.display());
546 
547  return oTravelSolutionList;
548  }
549 
550  // ////////////////////////////////////////////////////////////////////
551  void SIMCRS_Service::
552  fareQuote (const stdair::BookingRequestStruct& iBookingRequest,
553  stdair::TravelSolutionList_T& ioTravelSolutionList) {
554 
555  // Retrieve the SimCRS service context
556  if (_simcrsServiceContext == NULL) {
557  throw stdair::NonInitialisedServiceException ("The SimCRS service has "
558  "not been initialised");
559  }
560  assert (_simcrsServiceContext != NULL);
561 
562  SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
563 
564  // Get a reference on the SIMFQT service handler
565  SIMFQT::SIMFQT_Service& lSIMFQT_Service =
566  lSIMCRS_ServiceContext.getSIMFQT_Service();
567 
568  // Delegate the action to the dedicated command
569  stdair::BasChronometer lFareQuoteRetrievalChronometer;
570  lFareQuoteRetrievalChronometer.start();
571 
572  lSIMFQT_Service.quotePrices (iBookingRequest, ioTravelSolutionList);
573 
574  // DEBUG
575  const double lFareQuoteRetrievalMeasure =
576  lFareQuoteRetrievalChronometer.elapsed();
577  STDAIR_LOG_DEBUG ("Fare Quote retrieving: " << lFareQuoteRetrievalMeasure
578  << " - " << lSIMCRS_ServiceContext.display());
579  }
580 
581  // ////////////////////////////////////////////////////////////////////
582  void SIMCRS_Service::
583  calculateAvailability (stdair::TravelSolutionList_T& ioTravelSolutionList,
584  const stdair::PartnershipTechnique& iPartnershipTechnique) {
585 
586  // Retrieve the SimCRS service context
587  if (_simcrsServiceContext == NULL) {
588  throw stdair::NonInitialisedServiceException ("The SimCRS service has "
589  "not been initialised");
590  }
591  assert (_simcrsServiceContext != NULL);
592 
593  SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
594 
595  // Retrieve the CRS code
596  //const CRSCode_T& lCRSCode = lSIMCRS_ServiceContext.getCRSCode();
597 
598  // Retrieve the AIRINV Master service.
599  AIRINV::AIRINV_Master_Service& lAIRINV_Master_Service =
600  lSIMCRS_ServiceContext.getAIRINV_Service();
601 
602  // Delegate the availability retrieval to the dedicated command
603  stdair::BasChronometer lAvlChronometer;
604  lAvlChronometer.start();
605 
606  DistributionManager::calculateAvailability (lAIRINV_Master_Service,
607  ioTravelSolutionList,
608  iPartnershipTechnique);
609 
610  // DEBUG
611  const double lAvlMeasure = lAvlChronometer.elapsed();
612  STDAIR_LOG_DEBUG ("Availability retrieval: " << lAvlMeasure << " - "
613  << lSIMCRS_ServiceContext.display());
614  }
615 
616  // ////////////////////////////////////////////////////////////////////
617  bool SIMCRS_Service::
618  sell (const stdair::TravelSolutionStruct& iTravelSolution,
619  const stdair::PartySize_T& iPartySize) {
620  bool hasSaleBeenSuccessful = false;
621 
622  // Retrieve the SimCRS service context
623  if (_simcrsServiceContext == NULL) {
624  throw stdair::NonInitialisedServiceException ("The SimCRS service has "
625  "not been initialised");
626  }
627  assert (_simcrsServiceContext != NULL);
628 
629  SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
630 
631  // Retrieve the CRS code
632  //const CRSCode_T& lCRSCode = lSIMCRS_ServiceContext.getCRSCode();
633 
634  // Retrieve the AIRINV Master service.
635  AIRINV::AIRINV_Master_Service& lAIRINV_Master_Service =
636  lSIMCRS_ServiceContext.getAIRINV_Service();
637 
638  // Delegate the booking to the dedicated command
639  stdair::BasChronometer lSellChronometer;
640  lSellChronometer.start();
641 
642  hasSaleBeenSuccessful = DistributionManager::sell (lAIRINV_Master_Service,
643  iTravelSolution,
644  iPartySize);
645 
646  // DEBUG
647  STDAIR_LOG_DEBUG ("Made a sell of " << iPartySize
648  << " persons on the following travel solution: "
649  << iTravelSolution.describe()
650  << " with the chosen fare option: "
651  << iTravelSolution.getChosenFareOption().describe()
652  << ". Successful? " << hasSaleBeenSuccessful);
653 
654  // DEBUG
655  const double lSellMeasure = lSellChronometer.elapsed();
656  STDAIR_LOG_DEBUG ("Booking sell: " << lSellMeasure << " - "
657  << lSIMCRS_ServiceContext.display());
658 
659  return hasSaleBeenSuccessful;
660  }
661 
662 
663  // ////////////////////////////////////////////////////////////////////
664  bool SIMCRS_Service::
665  playCancellation (const stdair::CancellationStruct& iCancellation) {
666  bool hasCancellationBeenSuccessful = false;
667 
668  // Retrieve the SimCRS service context
669  if (_simcrsServiceContext == NULL) {
670  throw stdair::NonInitialisedServiceException ("The SimCRS service has "
671  "not been initialised");
672  }
673  assert (_simcrsServiceContext != NULL);
674 
675  SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
676 
677  // Retrieve the CRS code
678  //const CRSCode_T& lCRSCode = lSIMCRS_ServiceContext.getCRSCode();
679 
680  // Retrieve the AIRINV Master service.
681  AIRINV::AIRINV_Master_Service& lAIRINV_Master_Service =
682  lSIMCRS_ServiceContext.getAIRINV_Service();
683 
684  // Delegate the booking to the dedicated command
685  stdair::BasChronometer lCancellationChronometer;
686  lCancellationChronometer.start();
687 
688  hasCancellationBeenSuccessful =
689  DistributionManager::playCancellation (lAIRINV_Master_Service,
690  iCancellation);
691 
692  // DEBUG
693  STDAIR_LOG_DEBUG ("Made a cancellation of " << iCancellation.describe());
694 
695  // DEBUG
696  const double lCancellationMeasure = lCancellationChronometer.elapsed();
697  STDAIR_LOG_DEBUG ("Booking cancellation: " << lCancellationMeasure << " - "
698  << lSIMCRS_ServiceContext.display());
699 
700  return hasCancellationBeenSuccessful;
701  }
702 
703  // ////////////////////////////////////////////////////////////////////
704  void SIMCRS_Service::takeSnapshots (const stdair::SnapshotStruct& iSnapshot) {
705 
706  // Retrieve the SimCRS service context
707  if (_simcrsServiceContext == NULL) {
708  throw stdair::NonInitialisedServiceException ("The SimCRS service has "
709  "not been initialised");
710  }
711  assert (_simcrsServiceContext != NULL);
712  SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
713 
714  // Retrieve the AIRINV Master service.
715  AIRINV::AIRINV_Master_Service& lAIRINV_Master_Service =
716  lSIMCRS_ServiceContext.getAIRINV_Service();
717 
718  lAIRINV_Master_Service.takeSnapshots (iSnapshot);
719  }
720 
721  // ////////////////////////////////////////////////////////////////////
722  void SIMCRS_Service::
723  optimise (const stdair::RMEventStruct& iRMEvent,
724  const stdair::ForecastingMethod& iForecastingMethod,
725  const stdair::PartnershipTechnique& iPartnershipTechnique) {
726 
727  // Retrieve the SimCRS service context
728  if (_simcrsServiceContext == NULL) {
729  throw stdair::NonInitialisedServiceException ("The SimCRS service has "
730  "not been initialised");
731  }
732  assert (_simcrsServiceContext != NULL);
733  SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
734 
735  // Retrieve the AIRINV Master service.
736  AIRINV::AIRINV_Master_Service& lAIRINV_Master_Service =
737  lSIMCRS_ServiceContext.getAIRINV_Service();
738 
739  lAIRINV_Master_Service.optimise (iRMEvent, iForecastingMethod, iPartnershipTechnique);
740  }
741 }