AirInv Logo  0.1.2
C++ Simulated Airline Inventory Management System library
AIRINV_Master_Service.cpp
Go to the documentation of this file.
00001 // //////////////////////////////////////////////////////////////////////
00002 // Import section
00003 // //////////////////////////////////////////////////////////////////////
00004 // STL
00005 #include <cassert>
00006 #include <cmath>
00007 // Boost
00008 #include <boost/make_shared.hpp>
00009 // StdAir
00010 #include <stdair/basic/BasChronometer.hpp>
00011 #include <stdair/basic/EventType.hpp>
00012 #include <stdair/bom/BomKeyManager.hpp> 
00013 #include <stdair/bom/EventQueue.hpp>
00014 #include <stdair/bom/SnapshotStruct.hpp>
00015 #include <stdair/bom/RMEventStruct.hpp>
00016 #include <stdair/service/Logger.hpp>
00017 #include <stdair/STDAIR_Service.hpp>
00018 // AirInv
00019 #include <airinv/basic/BasConst_AIRINV_Service.hpp>
00020 #include <airinv/factory/FacAirinvMasterServiceContext.hpp>
00021 #include <airinv/command/InventoryParser.hpp>
00022 #include <airinv/command/InventoryManager.hpp>
00023 #include <airinv/service/AIRINV_Master_ServiceContext.hpp>
00024 #include <airinv/AIRINV_Service.hpp>
00025 #include <airinv/AIRINV_Master_Service.hpp>
00026 
00027 namespace AIRINV {
00028 
00029   // ////////////////////////////////////////////////////////////////////
00030   AIRINV_Master_Service::AIRINV_Master_Service() 
00031     : _airinvMasterServiceContext (NULL) {
00032     assert (false);
00033   }
00034 
00035   // ////////////////////////////////////////////////////////////////////
00036   AIRINV_Master_Service::
00037   AIRINV_Master_Service (const AIRINV_Master_Service& iService)
00038     : _airinvMasterServiceContext (NULL) {
00039     assert (false);
00040   }
00041 
00042   // ////////////////////////////////////////////////////////////////////
00043   AIRINV_Master_Service::
00044   AIRINV_Master_Service (const stdair::BasLogParams& iLogParams,
00045                          const stdair::BasDBParams& iDBParams)
00046     : _airinvMasterServiceContext (NULL) {
00047     
00048     // Initialise the STDAIR service handler
00049     stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
00050       initStdAirService (iLogParams, iDBParams);
00051     
00052     // Initialise the service context
00053     initServiceContext();
00054 
00055     // Add the StdAir service context to the AIRINV service context
00056     // \note RMOL owns the STDAIR service resources here.
00057     const bool ownStdairService = true;
00058     addStdAirService (lSTDAIR_Service_ptr, ownStdairService);
00059     
00060     // Initialise the (remaining of the) context
00061     initSlaveAirinvService();
00062   }
00063 
00064   // ////////////////////////////////////////////////////////////////////
00065   AIRINV_Master_Service::
00066   AIRINV_Master_Service (const stdair::BasLogParams& iLogParams)
00067     : _airinvMasterServiceContext (NULL) {
00068     
00069     // Initialise the STDAIR service handler
00070     stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
00071       initStdAirService (iLogParams);
00072 
00073     // Initialise the service context
00074     initServiceContext();
00075     
00076     // Add the StdAir service context to the AIRINV service context
00077     // \note RMOL owns the STDAIR service resources here.
00078     const bool ownStdairService = true;
00079     addStdAirService (lSTDAIR_Service_ptr, ownStdairService);
00080 
00081     // Initialise the (remaining of the) context
00082     initSlaveAirinvService();
00083   }
00084 
00085   // ////////////////////////////////////////////////////////////////////
00086   AIRINV_Master_Service::
00087   AIRINV_Master_Service (stdair::STDAIR_ServicePtr_T ioSTDAIR_Service_ptr)
00088     : _airinvMasterServiceContext (NULL) {
00089 
00090     // Initialise the service context
00091     initServiceContext();
00092 
00093     // Store the STDAIR service object within the (AIRINV) service context
00094     // \note AirInv does not own the STDAIR service resources here.
00095     const bool doesNotOwnStdairService = false;
00096     addStdAirService (ioSTDAIR_Service_ptr, doesNotOwnStdairService);
00097     
00098     // Initialise the (remaining of the) context
00099     initSlaveAirinvService();
00100   }
00101 
00102   // ////////////////////////////////////////////////////////////////////
00103   AIRINV_Master_Service::~AIRINV_Master_Service() {
00104     // Delete/Clean all the objects from memory
00105     finalise();
00106   }
00107 
00108   // ////////////////////////////////////////////////////////////////////
00109   void AIRINV_Master_Service::finalise() {
00110     assert (_airinvMasterServiceContext != NULL);
00111     // Reset the (Boost.)Smart pointer pointing on the STDAIR_Service object.
00112     _airinvMasterServiceContext->reset();
00113   }
00114 
00115   // ////////////////////////////////////////////////////////////////////
00116   void AIRINV_Master_Service::initServiceContext() {
00117     // Initialise the context
00118     AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext = 
00119       FacAirinvMasterServiceContext::instance().create();
00120     _airinvMasterServiceContext = &lAIRINV_Master_ServiceContext;
00121   }
00122 
00123   // ////////////////////////////////////////////////////////////////////
00124   void AIRINV_Master_Service::
00125   addStdAirService (stdair::STDAIR_ServicePtr_T ioSTDAIR_Service_ptr,
00126                     const bool iOwnStdairService) {
00127 
00128     // Retrieve the AirInv Master service context
00129     assert (_airinvMasterServiceContext != NULL);
00130     AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext =
00131       *_airinvMasterServiceContext;
00132 
00133     // Store the STDAIR service object within the (AIRINV) service context
00134     lAIRINV_Master_ServiceContext.setSTDAIR_Service (ioSTDAIR_Service_ptr,
00135                                                      iOwnStdairService);
00136   }
00137   
00138   // ////////////////////////////////////////////////////////////////////
00139   stdair::STDAIR_ServicePtr_T AIRINV_Master_Service::
00140   initStdAirService (const stdair::BasLogParams& iLogParams,
00141                      const stdair::BasDBParams& iDBParams) {
00142 
00150     stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr = 
00151       boost::make_shared<stdair::STDAIR_Service> (iLogParams, iDBParams);
00152     
00153     return lSTDAIR_Service_ptr;
00154   }
00155   
00156   // ////////////////////////////////////////////////////////////////////
00157   stdair::STDAIR_ServicePtr_T AIRINV_Master_Service::
00158   initStdAirService (const stdair::BasLogParams& iLogParams) {
00159 
00167     stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr = 
00168       boost::make_shared<stdair::STDAIR_Service> (iLogParams);
00169 
00170     return lSTDAIR_Service_ptr;
00171   }
00172   
00173   // ////////////////////////////////////////////////////////////////////
00174   void AIRINV_Master_Service::initSlaveAirinvService() {
00175 
00176     // Retrieve the AirInv Master service context
00177     assert (_airinvMasterServiceContext != NULL);
00178     AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext =
00179       *_airinvMasterServiceContext;
00180 
00181     // Retrieve the StdAir service
00182     stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
00183       lAIRINV_Master_ServiceContext.getSTDAIR_ServicePtr();
00184     assert (lSTDAIR_Service_ptr != NULL);
00185 
00195     AIRINV_ServicePtr_T lAIRINV_Service_ptr =
00196       boost::make_shared<AIRINV_Service> (lSTDAIR_Service_ptr);
00197 
00198     // Store the AIRINV service object within the AIRINV Master service context.
00199     lAIRINV_Master_ServiceContext.setAIRINV_Service (lAIRINV_Service_ptr);
00200   }
00201   
00202   // ////////////////////////////////////////////////////////////////////
00203   void AIRINV_Master_Service::
00204   parseAndLoad (const stdair::Filename_T& iInventoryInputFilename) {
00205 
00206     // Retrieve the AirInv Master service context
00207     if (_airinvMasterServiceContext == NULL) {
00208       throw stdair::NonInitialisedServiceException ("The AirInvMaster service "
00209                                                     "has not been initialised");
00210     }
00211     assert (_airinvMasterServiceContext != NULL);
00212 
00213     AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext =
00214       *_airinvMasterServiceContext;
00215   
00216     // Retrieve the slave AIRINV service object from the (AIRINV)
00217     // service context
00218     AIRINV_Service& lAIRINV_Service =
00219       lAIRINV_Master_ServiceContext.getAIRINV_Service();
00220 
00221     // Delegate the file parsing and BOM building to the dedicated service
00222     lAIRINV_Service.parseAndLoad (iInventoryInputFilename);
00223   }
00224 
00225   // ////////////////////////////////////////////////////////////////////
00226   void AIRINV_Master_Service::
00227   parseAndLoad (const stdair::Filename_T& iScheduleInputFilename,
00228                 const stdair::Filename_T& iODInputFilename,
00229                 const AIRRAC::YieldFilePath& iYieldFilename) {
00230     
00231     // Retrieve the AirInv Master service context
00232     if (_airinvMasterServiceContext == NULL) {
00233       throw stdair::NonInitialisedServiceException ("The AirInvMaster service "
00234                                                     "has not been initialised");
00235     }
00236     assert (_airinvMasterServiceContext != NULL);
00237 
00238     AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext =
00239       *_airinvMasterServiceContext;
00240   
00241     // Retrieve the slave AirInv service object from the (AirInv)
00242     // service context
00243     AIRINV_Service& lAIRINV_Service =
00244       lAIRINV_Master_ServiceContext.getAIRINV_Service();
00245 
00246     // Delegate the file parsing and BOM building to the dedicated service
00247     lAIRINV_Service.parseAndLoad (iScheduleInputFilename, iODInputFilename,
00248                                   iYieldFilename);
00249   }
00250   
00251   // ////////////////////////////////////////////////////////////////////
00252   void AIRINV_Master_Service::buildSampleBom() {
00253 
00254     // Retrieve the AirInv Master service context
00255     if (_airinvMasterServiceContext == NULL) {
00256       throw stdair::NonInitialisedServiceException ("The AirInvMaster service "
00257                                                     "has not been initialised");
00258     }
00259     assert (_airinvMasterServiceContext != NULL);
00260 
00261     // Retrieve the AirInv service context and whether it owns the Stdair
00262     // service
00263     AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext =
00264       *_airinvMasterServiceContext;
00265     const bool doesOwnStdairService =
00266       lAIRINV_Master_ServiceContext.getOwnStdairServiceFlag();
00267 
00268     // Retrieve the StdAir service object from the (AirInv) service context
00269     stdair::STDAIR_Service& lSTDAIR_Service =
00270       lAIRINV_Master_ServiceContext.getSTDAIR_Service();
00271 
00276     if (doesOwnStdairService == true) {
00277       //
00278       lSTDAIR_Service.buildSampleBom();
00279     }
00280 
00289     AIRINV_Service& lAIRINV_Service =
00290       lAIRINV_Master_ServiceContext.getAIRINV_Service();
00291     lAIRINV_Service.buildSampleBom();
00292 
00300   }
00301 
00302   // ////////////////////////////////////////////////////////////////////
00303   std::string AIRINV_Master_Service::
00304   jsonExport (const stdair::AirlineCode_T& iAirlineCode,
00305               const stdair::FlightNumber_T& iFlightNumber,
00306               const stdair::Date_T& iDepartureDate) const {
00307 
00308     // Retrieve the AirInv Master service context
00309     if (_airinvMasterServiceContext == NULL) {
00310       throw stdair::NonInitialisedServiceException ("The AirInvMaster service "
00311                                                     "has not been initialised");
00312     }
00313     assert (_airinvMasterServiceContext != NULL);
00314 
00315     AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext =
00316       *_airinvMasterServiceContext;
00317   
00318     // Retrieve the slave AirInv (slave) service object from
00319     // the (AirInv master) service context
00320     AIRINV_Service& lAIRINV_Service =
00321       lAIRINV_Master_ServiceContext.getAIRINV_Service();
00322 
00323     // Delegate the BOM dump to the dedicated service
00324     return lAIRINV_Service.jsonExport (iAirlineCode, iFlightNumber,
00325                                        iDepartureDate);
00326   }
00327 
00328   // ////////////////////////////////////////////////////////////////////
00329   std::string AIRINV_Master_Service::
00330   list (const stdair::AirlineCode_T& iAirlineCode,
00331         const stdair::FlightNumber_T& iFlightNumber) const {
00332     std::ostringstream oFlightListStr;
00333 
00334     // Retrieve the AirInv Master service context
00335     if (_airinvMasterServiceContext == NULL) {
00336       throw stdair::NonInitialisedServiceException ("The AirInvMaster service "
00337                                                     "has not been initialised");
00338     }
00339     assert (_airinvMasterServiceContext != NULL);
00340 
00341     AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext =
00342       *_airinvMasterServiceContext;
00343   
00344     // Retrieve the slave AirInv (slave) service object from
00345     // the (AirInv master) service context
00346     AIRINV_Service& lAIRINV_Service =
00347       lAIRINV_Master_ServiceContext.getAIRINV_Service();
00348 
00349     // Delegate the BOM display to the dedicated service
00350     return lAIRINV_Service.list (iAirlineCode, iFlightNumber);
00351   }
00352   
00353   // ////////////////////////////////////////////////////////////////////
00354   bool AIRINV_Master_Service::
00355   check (const stdair::AirlineCode_T& iAirlineCode,
00356          const stdair::FlightNumber_T& iFlightNumber,
00357          const stdair::Date_T& iDepartureDate) const {
00358     std::ostringstream oFlightListStr;
00359 
00360     // Retrieve the AirInv Master service context
00361     if (_airinvMasterServiceContext == NULL) {
00362       throw stdair::NonInitialisedServiceException ("The AirInvMaster service "
00363                                                     "has not been initialised");
00364     }
00365     assert (_airinvMasterServiceContext != NULL);
00366 
00367     AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext =
00368       *_airinvMasterServiceContext;
00369   
00370     // Retrieve the slave AirInv (slave) service object from
00371     // the (AirInv master) service context
00372     AIRINV_Service& lAIRINV_Service =
00373       lAIRINV_Master_ServiceContext.getAIRINV_Service();
00374 
00375     // Delegate the BOM display to the dedicated service
00376     return lAIRINV_Service.check (iAirlineCode, iFlightNumber, iDepartureDate);
00377   }
00378   
00379   // ////////////////////////////////////////////////////////////////////
00380   std::string AIRINV_Master_Service::csvDisplay() const {
00381 
00382     // Retrieve the AirInv Master service context
00383     if (_airinvMasterServiceContext == NULL) {
00384       throw stdair::NonInitialisedServiceException ("The AirInvMaster service "
00385                                                     "has not been initialised");
00386     }
00387     assert (_airinvMasterServiceContext != NULL);
00388 
00389     AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext =
00390       *_airinvMasterServiceContext;
00391   
00392     // Retrieve the slave AIRINV service object from
00393     // the (AIRINV) service context
00394     AIRINV_Service& lAIRINV_Service =
00395       lAIRINV_Master_ServiceContext.getAIRINV_Service();
00396 
00397     // Delegate the BOM display to the dedicated service
00398     return lAIRINV_Service.csvDisplay();
00399   }
00400 
00401   // ////////////////////////////////////////////////////////////////////
00402   std::string AIRINV_Master_Service::
00403   csvDisplay (const stdair::AirlineCode_T& iAirlineCode,
00404               const stdair::FlightNumber_T& iFlightNumber,
00405               const stdair::Date_T& iDepartureDate) const {
00406 
00407     // Retrieve the AirInv Master service context
00408     if (_airinvMasterServiceContext == NULL) {
00409       throw stdair::NonInitialisedServiceException ("The AirInvMaster service "
00410                                                     "has not been initialised");
00411     }
00412     assert (_airinvMasterServiceContext != NULL);
00413 
00414     AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext =
00415       *_airinvMasterServiceContext;
00416   
00417     // Retrieve the slave AIRINV service object from
00418     // the (AIRINV) service context
00419     AIRINV_Service& lAIRINV_Service =
00420       lAIRINV_Master_ServiceContext.getAIRINV_Service();
00421 
00422     // Delegate the BOM display to the dedicated service
00423     return lAIRINV_Service.csvDisplay (iAirlineCode, iFlightNumber,
00424                                        iDepartureDate);
00425   }
00426 
00427   // ////////////////////////////////////////////////////////////////////
00428   void AIRINV_Master_Service::
00429   initSnapshotAndRMEvents (const stdair::Date_T& iStartDate,
00430                            const stdair::Date_T& iEndDate) {
00431 
00432     // Retrieve the AirInv Master service context
00433     if (_airinvMasterServiceContext == NULL) {
00434       throw stdair::NonInitialisedServiceException ("The AirInvMaster service "
00435                                                     "has not been initialised");
00436     }
00437     assert (_airinvMasterServiceContext != NULL);
00438 
00439     AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext =
00440       *_airinvMasterServiceContext;
00441     
00442     // Retrieve the StdAir service context
00443     stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
00444       lAIRINV_Master_ServiceContext.getSTDAIR_ServicePtr();
00445     assert (lSTDAIR_Service_ptr != NULL);
00446 
00447     // Retrieve the event queue object instance
00448     stdair::EventQueue& lQueue = lSTDAIR_Service_ptr->getEventQueue();
00449 
00450     // Initialise the snapshot events
00451     InventoryManager::initSnapshotEvents (iStartDate, iEndDate, lQueue);
00452 
00453     // \todo Browse the list of inventories and itinialise the RM events of
00454     //       each inventory.
00455   
00456     // Retrieve the slave AIRINV service object from the (AIRINV)
00457     // service context
00458     AIRINV_Service& lAIRINV_Service =
00459       lAIRINV_Master_ServiceContext.getAIRINV_Service();
00460     lQueue.addStatus (stdair::EventType::RM, 0);
00461     stdair::RMEventList_T lRMEventList =
00462       lAIRINV_Service.initRMEvents (iStartDate, iEndDate);
00463     InventoryManager::addRMEventsToEventQueue (lQueue, lRMEventList);
00464   }
00465 
00466   // ////////////////////////////////////////////////////////////////////
00467   void AIRINV_Master_Service::
00468   calculateAvailability (stdair::TravelSolutionStruct& ioTravelSolution,
00469                          const stdair::PartnershipTechnique& iPartnershipTechnique) {
00470 
00471     // Retrieve the AirInv Master service context
00472     if (_airinvMasterServiceContext == NULL) {
00473       throw stdair::NonInitialisedServiceException ("The AirInvMaster service "
00474                                                     "has not been initialised");
00475     }
00476     assert (_airinvMasterServiceContext != NULL);
00477 
00478     AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext =
00479       *_airinvMasterServiceContext;
00480   
00481     // Retrieve the slave AIRINV service object from the (AIRINV)
00482     // service context
00483     AIRINV_Service& lAIRINV_Service =
00484       lAIRINV_Master_ServiceContext.getAIRINV_Service();
00485 
00486     // Delegate the availability retrieval to the dedicated service
00487     stdair::BasChronometer lAvlChronometer;
00488     lAvlChronometer.start();
00489 
00490     lAIRINV_Service.calculateAvailability (ioTravelSolution, iPartnershipTechnique);
00491 
00492     // DEBUG
00493     // const double lAvlMeasure = lAvlChronometer.elapsed();
00494     // STDAIR_LOG_DEBUG ("Availability retrieval: " << lAvlMeasure << " - "
00495     //                   << lAIRINV_Master_ServiceContext.display());
00496   }
00497 
00498   // ////////////////////////////////////////////////////////////////////
00499   bool AIRINV_Master_Service::sell (const std::string& iSegmentDateKey,
00500                                     const stdair::ClassCode_T& iClassCode,
00501                                     const stdair::PartySize_T& iPartySize) {
00502 
00503     // Retrieve the AirInv Master service context
00504     if (_airinvMasterServiceContext == NULL) {
00505       throw stdair::NonInitialisedServiceException ("The AirInvMaster service "
00506                                                     "has not been initialised");
00507     }
00508     assert (_airinvMasterServiceContext != NULL);
00509 
00510     AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext =
00511       *_airinvMasterServiceContext;
00512   
00513     // Retrieve the corresponding inventory key
00514     // const stdair::InventoryKey& lInventoryKey =
00515     // stdair::BomKeyManager::extractInventoryKey (iSegmentDateKey);
00516 
00517     // Retrieve the slave AirInv service object from the (AirInv Master)
00518     // service context
00519     AIRINV_Service& lAIRINV_Service =
00520       lAIRINV_Master_ServiceContext.getAIRINV_Service();
00521 
00522     // Delegate the booking to the dedicated command
00523     stdair::BasChronometer lSellChronometer;
00524     lSellChronometer.start();
00525 
00526     // Delegate the BOM building to the dedicated service
00527     const bool hasBeenSaleSuccessful =
00528       lAIRINV_Service.sell (iSegmentDateKey, iClassCode, iPartySize);
00529 
00530     // const double lSellMeasure = lSellChronometer.elapsed();
00531 
00532     // DEBUG
00533     // STDAIR_LOG_DEBUG ("Booking sell: " << lSellMeasure << " - "
00534     //                   << lAIRINV_Master_ServiceContext.display());
00535 
00536     //
00537     return hasBeenSaleSuccessful;
00538   }
00539 
00540   // ////////////////////////////////////////////////////////////////////
00541   bool AIRINV_Master_Service::cancel (const std::string& iSegmentDateKey,
00542                                       const stdair::ClassCode_T& iClassCode,
00543                                       const stdair::PartySize_T& iPartySize) {
00544 
00545     // Retrieve the AirInv Master service context
00546     if (_airinvMasterServiceContext == NULL) {
00547       throw stdair::NonInitialisedServiceException ("The AirInvMaster service "
00548                                                     "has not been initialised");
00549     }
00550     assert (_airinvMasterServiceContext != NULL);
00551 
00552     AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext =
00553       *_airinvMasterServiceContext;
00554   
00555     // Retrieve the corresponding inventory key
00556     // const stdair::InventoryKey& lInventoryKey =
00557     // stdair::BomKeyManager::extractInventoryKey (iSegmentDateKey);
00558 
00559     // Retrieve the slave AirInv service object from the (AirInv Master)
00560     // service context
00561     AIRINV_Service& lAIRINV_Service =
00562       lAIRINV_Master_ServiceContext.getAIRINV_Service();
00563 
00564     // Delegate the booking to the dedicated command
00565     stdair::BasChronometer lCancelChronometer;
00566     lCancelChronometer.start();
00567 
00568     // Delegate the BOM building to the dedicated service
00569     const bool hasBeenSaleSuccessful =
00570       lAIRINV_Service.cancel (iSegmentDateKey, iClassCode, iPartySize);
00571 
00572     // const double lCancelMeasure = lCancelChronometer.elapsed();
00573 
00574     // DEBUG
00575     // STDAIR_LOG_DEBUG ("Booking cancel: " << lCancelMeasure << " - "
00576     //                   << lAIRINV_Master_ServiceContext.display());
00577 
00578     //
00579     return hasBeenSaleSuccessful;
00580   }
00581 
00582   // ////////////////////////////////////////////////////////////////////
00583   void AIRINV_Master_Service::
00584   takeSnapshots (const stdair::SnapshotStruct& iSnapshot) {
00585 
00586     // Retrieve the AirInv Master service context
00587     if (_airinvMasterServiceContext == NULL) {
00588       throw stdair::NonInitialisedServiceException ("The AirInvMaster service "
00589                                                     "has not been initialised");
00590     }
00591     assert (_airinvMasterServiceContext != NULL);
00592 
00593     AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext =
00594       *_airinvMasterServiceContext;
00595   
00596     // Retrieve the slave AIRINV service object from the (AIRINV)
00597     // service context
00598     AIRINV_Service& lAIRINV_Service =
00599       lAIRINV_Master_ServiceContext.getAIRINV_Service();
00600 
00601     // Retrieve  the snapshot time and the airline code.
00602     const stdair::DateTime_T& lSnapshotTime = iSnapshot.getSnapshotTime();
00603     const stdair::AirlineCode_T& lAirlineCode = iSnapshot.getAirlineCode();
00604 
00605     lAIRINV_Service.takeSnapshots (lAirlineCode, lSnapshotTime);
00606   }
00607 
00608   // ////////////////////////////////////////////////////////////////////
00609   void AIRINV_Master_Service::
00610   optimise (const stdair::RMEventStruct& iRMEvent,
00611             const stdair::ForecastingMethod& iForecastingMethod,
00612             const stdair::PartnershipTechnique& iPartnershipTechnique) {
00613 
00614     // Retrieve the AirInv Master service context
00615     if (_airinvMasterServiceContext == NULL) {
00616       throw stdair::NonInitialisedServiceException ("The AirInvMaster service "
00617                                                     "has not been initialised");
00618     }
00619     assert (_airinvMasterServiceContext != NULL);
00620 
00621     AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext =
00622       *_airinvMasterServiceContext;
00623   
00624     // Retrieve the slave AIRINV service object from the (AIRINV)
00625     // service context
00626     AIRINV_Service& lAIRINV_Service =
00627       lAIRINV_Master_ServiceContext.getAIRINV_Service();
00628 
00629     // Retrieve  the snapshot time and the airline code.
00630     const stdair::DateTime_T& lRMEventTime = iRMEvent.getRMEventTime();
00631     const stdair::AirlineCode_T& lAirlineCode = iRMEvent.getAirlineCode();
00632     const stdair::KeyDescription_T& lFDDescription =
00633       iRMEvent.getFlightDateDescription();
00634 
00635     lAIRINV_Service.optimise (lAirlineCode, lFDDescription, lRMEventTime,
00636                               iForecastingMethod, iPartnershipTechnique);
00637   }
00638 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines