$treeview $search $mathjax
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/stdair_json.hpp> 00011 #include <stdair/basic/BasChronometer.hpp> 00012 #include <stdair/basic/EventType.hpp> 00013 #include <stdair/bom/BomKeyManager.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 // SEvMgr 00019 #include <sevmgr/SEVMGR_Service.hpp> 00020 // AirInv 00021 #include <airinv/basic/BasConst_AIRINV_Service.hpp> 00022 #include <airinv/factory/FacAirinvMasterServiceContext.hpp> 00023 #include <airinv/command/InventoryParser.hpp> 00024 #include <airinv/command/InventoryManager.hpp> 00025 #include <airinv/service/AIRINV_Master_ServiceContext.hpp> 00026 #include <airinv/AIRINV_Service.hpp> 00027 #include <airinv/AIRINV_Master_Service.hpp> 00028 00029 namespace AIRINV { 00030 00031 // //////////////////////////////////////////////////////////////////// 00032 AIRINV_Master_Service::AIRINV_Master_Service() 00033 : _airinvMasterServiceContext (NULL) { 00034 assert (false); 00035 } 00036 00037 // //////////////////////////////////////////////////////////////////// 00038 AIRINV_Master_Service:: 00039 AIRINV_Master_Service (const AIRINV_Master_Service& iService) 00040 : _airinvMasterServiceContext (NULL) { 00041 assert (false); 00042 } 00043 00044 // //////////////////////////////////////////////////////////////////// 00045 AIRINV_Master_Service:: 00046 AIRINV_Master_Service (const stdair::BasLogParams& iLogParams, 00047 const stdair::BasDBParams& iDBParams) 00048 : _airinvMasterServiceContext (NULL) { 00049 00050 // Initialise the STDAIR service handler 00051 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr = 00052 initStdAirService (iLogParams, iDBParams); 00053 00054 // Initialise the service context 00055 initServiceContext(); 00056 00057 // Add the StdAir service context to the AIRINV service context 00058 // \note RMOL owns the STDAIR service resources here. 00059 const bool ownStdairService = true; 00060 addStdAirService (lSTDAIR_Service_ptr, ownStdairService); 00061 00062 // Initialise the (remaining of the) context 00063 initSlaveAirinvService(); 00064 } 00065 00066 // //////////////////////////////////////////////////////////////////// 00067 AIRINV_Master_Service:: 00068 AIRINV_Master_Service (const stdair::BasLogParams& iLogParams) 00069 : _airinvMasterServiceContext (NULL) { 00070 00071 // Initialise the STDAIR service handler 00072 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr = 00073 initStdAirService (iLogParams); 00074 00075 // Initialise the service context 00076 initServiceContext(); 00077 00078 // Add the StdAir service context to the AIRINV service context 00079 // \note RMOL owns the STDAIR service resources here. 00080 const bool ownStdairService = true; 00081 addStdAirService (lSTDAIR_Service_ptr, ownStdairService); 00082 00083 // Initialise the (remaining of the) context 00084 initSlaveAirinvService(); 00085 } 00086 00087 // //////////////////////////////////////////////////////////////////// 00088 AIRINV_Master_Service:: 00089 AIRINV_Master_Service (stdair::STDAIR_ServicePtr_T ioSTDAIR_Service_ptr) 00090 : _airinvMasterServiceContext (NULL) { 00091 00092 // Initialise the service context 00093 initServiceContext(); 00094 00095 // Store the STDAIR service object within the (AIRINV) service context 00096 // \note AirInv does not own the STDAIR service resources here. 00097 const bool doesNotOwnStdairService = false; 00098 addStdAirService (ioSTDAIR_Service_ptr, doesNotOwnStdairService); 00099 00100 // Initialise the (remaining of the) context 00101 initSlaveAirinvService(); 00102 } 00103 00104 // //////////////////////////////////////////////////////////////////// 00105 AIRINV_Master_Service:: 00106 AIRINV_Master_Service (stdair::STDAIR_ServicePtr_T ioSTDAIR_Service_ptr, 00107 SEVMGR::SEVMGR_ServicePtr_T ioSEVMGR_Service_ptr) 00108 : _airinvMasterServiceContext (NULL) { 00109 00110 // Initialise the service context 00111 initServiceContext(); 00112 00113 // Store the STDAIR service object within the (AIRINV) service context 00114 // \note AirInv does not own the STDAIR service resources here. 00115 const bool doesNotOwnStdairService = false; 00116 addStdAirService (ioSTDAIR_Service_ptr, doesNotOwnStdairService); 00117 00118 //Add the SEvMgr service to the TRADEMGEN service context. 00119 const bool doesNotOwnSEVMGRService = false; 00120 addSEVMGRService (ioSEVMGR_Service_ptr, doesNotOwnSEVMGRService); 00121 00122 // Initialise the (remaining of the) context 00123 initSlaveAirinvService(); 00124 } 00125 00126 // //////////////////////////////////////////////////////////////////// 00127 AIRINV_Master_Service::~AIRINV_Master_Service() { 00128 // Delete/Clean all the objects from memory 00129 finalise(); 00130 } 00131 00132 // //////////////////////////////////////////////////////////////////// 00133 void AIRINV_Master_Service::finalise() { 00134 assert (_airinvMasterServiceContext != NULL); 00135 // Reset the (Boost.)Smart pointer pointing on the STDAIR_Service object. 00136 _airinvMasterServiceContext->reset(); 00137 } 00138 00139 // //////////////////////////////////////////////////////////////////// 00140 void AIRINV_Master_Service::initServiceContext() { 00141 // Initialise the context 00142 AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext = 00143 FacAirinvMasterServiceContext::instance().create(); 00144 _airinvMasterServiceContext = &lAIRINV_Master_ServiceContext; 00145 } 00146 00147 // //////////////////////////////////////////////////////////////////// 00148 void AIRINV_Master_Service:: 00149 addStdAirService (stdair::STDAIR_ServicePtr_T ioSTDAIR_Service_ptr, 00150 const bool iOwnStdairService) { 00151 00152 // Retrieve the AirInv Master service context 00153 assert (_airinvMasterServiceContext != NULL); 00154 AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext = 00155 *_airinvMasterServiceContext; 00156 00157 // Store the STDAIR service object within the (AIRINV) service context 00158 lAIRINV_Master_ServiceContext.setSTDAIR_Service (ioSTDAIR_Service_ptr, 00159 iOwnStdairService); 00160 } 00161 00162 // //////////////////////////////////////////////////////////////////// 00163 void AIRINV_Master_Service:: 00164 addSEVMGRService (SEVMGR::SEVMGR_ServicePtr_T ioSEVMGR_Service_ptr, 00165 const bool iOwnSEVMGRService) { 00166 00167 // Retrieve the AirInv Master service context 00168 assert (_airinvMasterServiceContext != NULL); 00169 AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext = 00170 *_airinvMasterServiceContext; 00171 00172 // Store the STDAIR service object within the (TRADEMGEN) service context 00173 lAIRINV_Master_ServiceContext.setSEVMGR_Service (ioSEVMGR_Service_ptr, 00174 iOwnSEVMGRService); 00175 } 00176 00177 // //////////////////////////////////////////////////////////////////// 00178 stdair::STDAIR_ServicePtr_T AIRINV_Master_Service:: 00179 initStdAirService (const stdair::BasLogParams& iLogParams, 00180 const stdair::BasDBParams& iDBParams) { 00181 00189 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr = 00190 boost::make_shared<stdair::STDAIR_Service> (iLogParams, iDBParams); 00191 00192 return lSTDAIR_Service_ptr; 00193 } 00194 00195 // //////////////////////////////////////////////////////////////////// 00196 stdair::STDAIR_ServicePtr_T AIRINV_Master_Service:: 00197 initStdAirService (const stdair::BasLogParams& iLogParams) { 00198 00206 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr = 00207 boost::make_shared<stdair::STDAIR_Service> (iLogParams); 00208 00209 return lSTDAIR_Service_ptr; 00210 } 00211 00212 // //////////////////////////////////////////////////////////////////// 00213 void AIRINV_Master_Service::initSlaveAirinvService() { 00214 00215 // Retrieve the AirInv Master service context 00216 assert (_airinvMasterServiceContext != NULL); 00217 AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext = 00218 *_airinvMasterServiceContext; 00219 00220 // Retrieve the StdAir service 00221 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr = 00222 lAIRINV_Master_ServiceContext.getSTDAIR_ServicePtr(); 00223 assert (lSTDAIR_Service_ptr != NULL); 00224 00234 AIRINV_ServicePtr_T lAIRINV_Service_ptr; 00235 const bool ownSEVMGRService = 00236 lAIRINV_Master_ServiceContext.getOwnSEVMGRServiceFlag(); 00237 if (ownSEVMGRService == false) { 00238 // Retrieve the SEVMGR service 00239 SEVMGR::SEVMGR_ServicePtr_T lSEVMGR_Service_ptr = 00240 lAIRINV_Master_ServiceContext.getSEVMGR_ServicePtr(); 00241 assert (lSEVMGR_Service_ptr != NULL); 00242 lAIRINV_Service_ptr = boost::make_shared<AIRINV_Service> (lSTDAIR_Service_ptr, 00243 lSEVMGR_Service_ptr); 00244 } else { 00245 lAIRINV_Service_ptr = boost::make_shared<AIRINV_Service> (lSTDAIR_Service_ptr); 00246 } 00247 assert (lAIRINV_Service_ptr != NULL); 00248 00249 // Store the AIRINV service object within the AIRINV Master service context. 00250 lAIRINV_Master_ServiceContext.setAIRINV_Service (lAIRINV_Service_ptr); 00251 } 00252 00253 // //////////////////////////////////////////////////////////////////// 00254 void AIRINV_Master_Service:: 00255 parseAndLoad (const InventoryFilePath& iInventoryInputFilename) { 00256 00257 // Retrieve the AirInv Master service context 00258 if (_airinvMasterServiceContext == NULL) { 00259 throw stdair::NonInitialisedServiceException ("The AirInvMaster service " 00260 "has not been initialised"); 00261 } 00262 assert (_airinvMasterServiceContext != NULL); 00263 00264 // Retrieve the AirInv service context and whether it owns the Stdair 00265 // service 00266 AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext = 00267 *_airinvMasterServiceContext; 00268 const bool doesOwnStdairService = 00269 lAIRINV_Master_ServiceContext.getOwnStdairServiceFlag(); 00270 00271 // Retrieve the slave AIRINV service object from the (AIRINV) 00272 // service context 00273 AIRINV_Service& lAIRINV_Service = 00274 lAIRINV_Master_ServiceContext.getAIRINV_Service(); 00275 00276 // Delegate the file parsing and BOM building to the dedicated service 00277 lAIRINV_Service.parseAndLoad (iInventoryInputFilename); 00278 00283 if (doesOwnStdairService == true) { 00284 00285 // 00286 clonePersistentBom (); 00287 } 00288 } 00289 00290 // //////////////////////////////////////////////////////////////////// 00291 void AIRINV_Master_Service::buildSampleBom() { 00292 00293 // Retrieve the AirInv Master service context 00294 if (_airinvMasterServiceContext == NULL) { 00295 throw stdair::NonInitialisedServiceException ("The AirInvMaster service " 00296 "has not been initialised"); 00297 } 00298 assert (_airinvMasterServiceContext != NULL); 00299 00300 // Retrieve the AirInv service context and whether it owns the Stdair 00301 // service 00302 AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext = 00303 *_airinvMasterServiceContext; 00304 const bool doesOwnStdairService = 00305 lAIRINV_Master_ServiceContext.getOwnStdairServiceFlag(); 00306 00307 // Retrieve the StdAir service object from the (AirInv) service context 00308 stdair::STDAIR_Service& lSTDAIR_Service = 00309 lAIRINV_Master_ServiceContext.getSTDAIR_Service(); 00310 stdair::BomRoot& lPersistentBomRoot = 00311 lSTDAIR_Service.getPersistentBomRoot(); 00312 00317 if (doesOwnStdairService == true) { 00318 // 00319 lSTDAIR_Service.buildSampleBom(); 00320 } 00321 00330 AIRINV_Service& lAIRINV_Service = 00331 lAIRINV_Master_ServiceContext.getAIRINV_Service(); 00332 lAIRINV_Service.buildSampleBom(); 00333 00338 buildComplementaryLinks (lPersistentBomRoot); 00339 00344 if (doesOwnStdairService == true) { 00345 00346 // 00347 clonePersistentBom (); 00348 } 00349 } 00350 00351 // //////////////////////////////////////////////////////////////////// 00352 void AIRINV_Master_Service:: 00353 parseAndLoad (const stdair::ScheduleFilePath& iScheduleInputFilename, 00354 const stdair::ODFilePath& iODInputFilename, 00355 const stdair::FRAT5FilePath& iFRAT5InputFilename, 00356 const stdair::FFDisutilityFilePath& iFFDisutilityInputFilename, 00357 const AIRRAC::YieldFilePath& iYieldFilename) { 00358 00359 // Retrieve the AirInv Master service context 00360 if (_airinvMasterServiceContext == NULL) { 00361 throw stdair::NonInitialisedServiceException ("The AirInvMaster service " 00362 "has not been initialised"); 00363 } 00364 assert (_airinvMasterServiceContext != NULL); 00365 00366 // Retrieve the AirInv service context and whether it owns the Stdair 00367 // service 00368 AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext = 00369 *_airinvMasterServiceContext; 00370 const bool doesOwnStdairService = 00371 lAIRINV_Master_ServiceContext.getOwnStdairServiceFlag(); 00372 00373 // Retrieve the slave AirInv service object from the (AirInv) 00374 // service context 00375 AIRINV_Service& lAIRINV_Service = 00376 lAIRINV_Master_ServiceContext.getAIRINV_Service(); 00377 00378 // Retrieve the StdAir service object from the (AirInv) service context 00379 stdair::STDAIR_Service& lSTDAIR_Service = 00380 lAIRINV_Master_ServiceContext.getSTDAIR_Service(); 00381 stdair::BomRoot& lPersistentBomRoot = 00382 lSTDAIR_Service.getPersistentBomRoot(); 00383 00387 lAIRINV_Service.parseAndLoad (iScheduleInputFilename, iODInputFilename, 00388 iFRAT5InputFilename, 00389 iFFDisutilityInputFilename, iYieldFilename); 00390 00401 buildComplementaryLinks (lPersistentBomRoot); 00402 00407 if (doesOwnStdairService == true) { 00408 00409 // 00410 clonePersistentBom (); 00411 } 00412 } 00413 00414 // //////////////////////////////////////////////////////////////////// 00415 void AIRINV_Master_Service::clonePersistentBom () { 00416 00417 // Retrieve the AirInv Master service context 00418 if (_airinvMasterServiceContext == NULL) { 00419 throw stdair::NonInitialisedServiceException ("The AirInvMaster service " 00420 "has not been initialised"); 00421 } 00422 assert (_airinvMasterServiceContext != NULL); 00423 00424 // Retrieve the AirInv service context and whether it owns the Stdair 00425 // service 00426 AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext = 00427 *_airinvMasterServiceContext; 00428 const bool doesOwnStdairService = 00429 lAIRINV_Master_ServiceContext.getOwnStdairServiceFlag(); 00430 00431 // Retrieve the slave AIRINV service object from the (AIRINV) 00432 // service context 00433 AIRINV_Service& lAIRINV_Service = 00434 lAIRINV_Master_ServiceContext.getAIRINV_Service(); 00435 00436 // Retrieve the StdAir service object from the (AIRINV) service context 00437 stdair::STDAIR_Service& lSTDAIR_Service = 00438 lAIRINV_Master_ServiceContext.getSTDAIR_Service(); 00439 00444 if (doesOwnStdairService == true) { 00445 00446 // 00447 lSTDAIR_Service.clonePersistentBom (); 00448 } 00449 00454 lAIRINV_Service.clonePersistentBom (); 00455 00460 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot(); 00461 buildComplementaryLinks (lBomRoot); 00462 } 00463 00464 // //////////////////////////////////////////////////////////////////// 00465 void AIRINV_Master_Service:: 00466 buildComplementaryLinks (stdair::BomRoot& ioBomRoot) { 00467 // Currently, no more things to do by AIRINV_Master at that stage. 00468 } 00469 00470 // //////////////////////////////////////////////////////////////////// 00471 std::string AIRINV_Master_Service:: 00472 jsonHandler (const stdair::JSONString& lJSONString) const { 00473 00474 // Retrieve the AirInv Master service context 00475 if (_airinvMasterServiceContext == NULL) { 00476 throw stdair::NonInitialisedServiceException ("The AirInvMaster service " 00477 "has not been initialised"); 00478 } 00479 assert (_airinvMasterServiceContext != NULL); 00480 00481 AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext = 00482 *_airinvMasterServiceContext; 00483 00484 // Retrieve the slave AirInv (slave) service object from 00485 // the (AirInv master) service context 00486 AIRINV_Service& lAIRINV_Service = 00487 lAIRINV_Master_ServiceContext.getAIRINV_Service(); 00488 00489 // Delegate the BOM dump to the dedicated service 00490 return lAIRINV_Service.jsonHandler (lJSONString); 00491 00492 } 00493 00494 // //////////////////////////////////////////////////////////////////// 00495 std::string AIRINV_Master_Service:: 00496 jsonExportFlightDateList (const stdair::AirlineCode_T& iAirlineCode, 00497 const stdair::FlightNumber_T& iFlightNumber) const { 00498 00499 // Retrieve the AirInv Master service context 00500 if (_airinvMasterServiceContext == NULL) { 00501 throw stdair::NonInitialisedServiceException ("The AirInvMaster service " 00502 "has not been initialised"); 00503 } 00504 assert (_airinvMasterServiceContext != NULL); 00505 00506 AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext = 00507 *_airinvMasterServiceContext; 00508 00509 // Retrieve the slave AirInv (slave) service object from 00510 // the (AirInv master) service context 00511 AIRINV_Service& lAIRINV_Service = 00512 lAIRINV_Master_ServiceContext.getAIRINV_Service(); 00513 00514 // Delegate the JSON export to the dedicated service 00515 return lAIRINV_Service.jsonExportFlightDateList (iAirlineCode, 00516 iFlightNumber); 00517 } 00518 00519 // //////////////////////////////////////////////////////////////////// 00520 std::string AIRINV_Master_Service:: 00521 jsonExportFlightDateObjects (const stdair::AirlineCode_T& iAirlineCode, 00522 const stdair::FlightNumber_T& iFlightNumber, 00523 const stdair::Date_T& iDepartureDate) const { 00524 00525 // Retrieve the AirInv Master service context 00526 if (_airinvMasterServiceContext == NULL) { 00527 throw stdair::NonInitialisedServiceException ("The AirInvMaster service " 00528 "has not been initialised"); 00529 } 00530 assert (_airinvMasterServiceContext != NULL); 00531 00532 AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext = 00533 *_airinvMasterServiceContext; 00534 00535 // Retrieve the slave AirInv (slave) service object from 00536 // the (AirInv master) service context 00537 AIRINV_Service& lAIRINV_Service = 00538 lAIRINV_Master_ServiceContext.getAIRINV_Service(); 00539 00540 // Delegate the BOM dump to the dedicated service 00541 return lAIRINV_Service.jsonExportFlightDateObjects (iAirlineCode, 00542 iFlightNumber, 00543 iDepartureDate); 00544 } 00545 00546 // //////////////////////////////////////////////////////////////////// 00547 std::string AIRINV_Master_Service:: 00548 list (const stdair::AirlineCode_T& iAirlineCode, 00549 const stdair::FlightNumber_T& iFlightNumber) const { 00550 std::ostringstream oFlightListStr; 00551 00552 // Retrieve the AirInv Master service context 00553 if (_airinvMasterServiceContext == NULL) { 00554 throw stdair::NonInitialisedServiceException ("The AirInvMaster service " 00555 "has not been initialised"); 00556 } 00557 assert (_airinvMasterServiceContext != NULL); 00558 00559 AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext = 00560 *_airinvMasterServiceContext; 00561 00562 // Retrieve the slave AirInv (slave) service object from 00563 // the (AirInv master) service context 00564 AIRINV_Service& lAIRINV_Service = 00565 lAIRINV_Master_ServiceContext.getAIRINV_Service(); 00566 00567 // Delegate the BOM display to the dedicated service 00568 return lAIRINV_Service.list (iAirlineCode, iFlightNumber); 00569 } 00570 00571 // //////////////////////////////////////////////////////////////////// 00572 bool AIRINV_Master_Service:: 00573 check (const stdair::AirlineCode_T& iAirlineCode, 00574 const stdair::FlightNumber_T& iFlightNumber, 00575 const stdair::Date_T& iDepartureDate) const { 00576 std::ostringstream oFlightListStr; 00577 00578 // Retrieve the AirInv Master service context 00579 if (_airinvMasterServiceContext == NULL) { 00580 throw stdair::NonInitialisedServiceException ("The AirInvMaster service " 00581 "has not been initialised"); 00582 } 00583 assert (_airinvMasterServiceContext != NULL); 00584 00585 AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext = 00586 *_airinvMasterServiceContext; 00587 00588 // Retrieve the slave AirInv (slave) service object from 00589 // the (AirInv master) service context 00590 AIRINV_Service& lAIRINV_Service = 00591 lAIRINV_Master_ServiceContext.getAIRINV_Service(); 00592 00593 // Delegate the BOM display to the dedicated service 00594 return lAIRINV_Service.check (iAirlineCode, iFlightNumber, iDepartureDate); 00595 } 00596 00597 // //////////////////////////////////////////////////////////////////// 00598 std::string AIRINV_Master_Service::csvDisplay() const { 00599 00600 // Retrieve the AirInv Master service context 00601 if (_airinvMasterServiceContext == NULL) { 00602 throw stdair::NonInitialisedServiceException ("The AirInvMaster service " 00603 "has not been initialised"); 00604 } 00605 assert (_airinvMasterServiceContext != NULL); 00606 00607 AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext = 00608 *_airinvMasterServiceContext; 00609 00610 // Retrieve the slave AIRINV service object from 00611 // the (AIRINV) service context 00612 AIRINV_Service& lAIRINV_Service = 00613 lAIRINV_Master_ServiceContext.getAIRINV_Service(); 00614 00615 // Delegate the BOM display to the dedicated service 00616 return lAIRINV_Service.csvDisplay(); 00617 } 00618 00619 // //////////////////////////////////////////////////////////////////// 00620 std::string AIRINV_Master_Service:: 00621 csvDisplay (const stdair::AirlineCode_T& iAirlineCode, 00622 const stdair::FlightNumber_T& iFlightNumber, 00623 const stdair::Date_T& iDepartureDate) const { 00624 00625 // Retrieve the AirInv Master service context 00626 if (_airinvMasterServiceContext == NULL) { 00627 throw stdair::NonInitialisedServiceException ("The AirInvMaster service " 00628 "has not been initialised"); 00629 } 00630 assert (_airinvMasterServiceContext != NULL); 00631 00632 AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext = 00633 *_airinvMasterServiceContext; 00634 00635 // Retrieve the slave AIRINV service object from 00636 // the (AIRINV) service context 00637 AIRINV_Service& lAIRINV_Service = 00638 lAIRINV_Master_ServiceContext.getAIRINV_Service(); 00639 00640 // Delegate the BOM display to the dedicated service 00641 return lAIRINV_Service.csvDisplay (iAirlineCode, iFlightNumber, 00642 iDepartureDate); 00643 } 00644 00645 // //////////////////////////////////////////////////////////////////// 00646 void AIRINV_Master_Service:: 00647 initSnapshotAndRMEvents (const stdair::Date_T& iStartDate, 00648 const stdair::Date_T& iEndDate) { 00649 00650 // Retrieve the AirInv Master service context 00651 if (_airinvMasterServiceContext == NULL) { 00652 throw stdair::NonInitialisedServiceException ("The AirInvMaster service " 00653 "has not been initialised"); 00654 } 00655 assert (_airinvMasterServiceContext != NULL); 00656 00657 AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext = 00658 *_airinvMasterServiceContext; 00659 00660 // Retrieve the pointer on the SEvMgr service context 00661 SEVMGR::SEVMGR_ServicePtr_T lSEVMGR_Service_ptr = 00662 lAIRINV_Master_ServiceContext.getSEVMGR_ServicePtr(); 00663 assert (lSEVMGR_Service_ptr != NULL); 00664 00665 // Initialise the snapshot events 00666 InventoryManager::initSnapshotEvents (lSEVMGR_Service_ptr, iStartDate, iEndDate); 00667 00668 // \todo Browse the list of inventories and itinialise the RM events of 00669 // each inventory. 00670 00671 // Retrieve the slave AIRINV service object from the (AIRINV) 00672 // service context 00673 AIRINV_Service& lAIRINV_Service = 00674 lAIRINV_Master_ServiceContext.getAIRINV_Service(); 00675 lSEVMGR_Service_ptr->addStatus (stdair::EventType::RM, 0); 00676 stdair::RMEventList_T lRMEventList = 00677 lAIRINV_Service.initRMEvents (iStartDate, iEndDate); 00678 assert (lRMEventList.empty() == false); 00679 InventoryManager::addRMEventsToEventQueue (lSEVMGR_Service_ptr, lRMEventList); 00680 } 00681 00682 // //////////////////////////////////////////////////////////////////// 00683 void AIRINV_Master_Service:: 00684 calculateAvailability (stdair::TravelSolutionStruct& ioTravelSolution) { 00685 00686 // Retrieve the AirInv Master service context 00687 if (_airinvMasterServiceContext == NULL) { 00688 throw stdair::NonInitialisedServiceException ("The AirInvMaster service " 00689 "has not been initialised"); 00690 } 00691 assert (_airinvMasterServiceContext != NULL); 00692 00693 AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext = 00694 *_airinvMasterServiceContext; 00695 00696 // Retrieve the slave AIRINV service object from the (AIRINV) 00697 // service context 00698 AIRINV_Service& lAIRINV_Service = 00699 lAIRINV_Master_ServiceContext.getAIRINV_Service(); 00700 00701 // Delegate the availability retrieval to the dedicated service 00702 stdair::BasChronometer lAvlChronometer; 00703 lAvlChronometer.start(); 00704 00705 lAIRINV_Service.calculateAvailability (ioTravelSolution); 00706 00707 // DEBUG 00708 // const double lAvlMeasure = lAvlChronometer.elapsed(); 00709 // STDAIR_LOG_DEBUG ("Availability retrieval: " << lAvlMeasure << " - " 00710 // << lAIRINV_Master_ServiceContext.display()); 00711 } 00712 00713 // //////////////////////////////////////////////////////////////////// 00714 bool AIRINV_Master_Service::sell (const std::string& iSegmentDateKey, 00715 const stdair::ClassCode_T& iClassCode, 00716 const stdair::PartySize_T& iPartySize) { 00717 00718 // Retrieve the AirInv Master service context 00719 if (_airinvMasterServiceContext == NULL) { 00720 throw stdair::NonInitialisedServiceException ("The AirInvMaster service " 00721 "has not been initialised"); 00722 } 00723 assert (_airinvMasterServiceContext != NULL); 00724 00725 AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext = 00726 *_airinvMasterServiceContext; 00727 00728 // Retrieve the corresponding inventory key 00729 // const stdair::InventoryKey& lInventoryKey = 00730 // stdair::BomKeyManager::extractInventoryKey (iSegmentDateKey); 00731 00732 // Retrieve the slave AirInv service object from the (AirInv Master) 00733 // service context 00734 AIRINV_Service& lAIRINV_Service = 00735 lAIRINV_Master_ServiceContext.getAIRINV_Service(); 00736 00737 // Delegate the booking to the dedicated command 00738 stdair::BasChronometer lSellChronometer; 00739 lSellChronometer.start(); 00740 00741 // Delegate the BOM building to the dedicated service 00742 const bool hasBeenSaleSuccessful = 00743 lAIRINV_Service.sell (iSegmentDateKey, iClassCode, iPartySize); 00744 00745 // const double lSellMeasure = lSellChronometer.elapsed(); 00746 00747 // DEBUG 00748 // STDAIR_LOG_DEBUG ("Booking sell: " << lSellMeasure << " - " 00749 // << lAIRINV_Master_ServiceContext.display()); 00750 00751 // 00752 return hasBeenSaleSuccessful; 00753 } 00754 00755 // //////////////////////////////////////////////////////////////////// 00756 bool AIRINV_Master_Service::sell (const stdair::BookingClassID_T& iClassID, 00757 const stdair::PartySize_T& iPartySize) { 00758 00759 // Retrieve the AirInv Master service context 00760 if (_airinvMasterServiceContext == NULL) { 00761 throw stdair::NonInitialisedServiceException ("The AirInvMaster service " 00762 "has not been initialised"); 00763 } 00764 assert (_airinvMasterServiceContext != NULL); 00765 00766 AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext = 00767 *_airinvMasterServiceContext; 00768 00769 // Retrieve the corresponding inventory key 00770 // const stdair::InventoryKey& lInventoryKey = 00771 // stdair::BomKeyManager::extractInventoryKey (iSegmentDateKey); 00772 00773 // Retrieve the slave AirInv service object from the (AirInv Master) 00774 // service context 00775 AIRINV_Service& lAIRINV_Service = 00776 lAIRINV_Master_ServiceContext.getAIRINV_Service(); 00777 00778 // Delegate the booking to the dedicated command 00779 stdair::BasChronometer lSellChronometer; 00780 lSellChronometer.start(); 00781 00782 // Delegate the BOM building to the dedicated service 00783 const bool hasBeenSaleSuccessful = 00784 lAIRINV_Service.sell (iClassID, iPartySize); 00785 00786 // const double lSellMeasure = lSellChronometer.elapsed(); 00787 00788 // DEBUG 00789 // STDAIR_LOG_DEBUG ("Booking sell: " << lSellMeasure << " - " 00790 // << lAIRINV_Master_ServiceContext.display()); 00791 00792 // 00793 return hasBeenSaleSuccessful; 00794 } 00795 00796 // //////////////////////////////////////////////////////////////////// 00797 bool AIRINV_Master_Service::cancel (const std::string& iSegmentDateKey, 00798 const stdair::ClassCode_T& iClassCode, 00799 const stdair::PartySize_T& iPartySize) { 00800 00801 // Retrieve the AirInv Master service context 00802 if (_airinvMasterServiceContext == NULL) { 00803 throw stdair::NonInitialisedServiceException ("The AirInvMaster service " 00804 "has not been initialised"); 00805 } 00806 assert (_airinvMasterServiceContext != NULL); 00807 00808 AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext = 00809 *_airinvMasterServiceContext; 00810 00811 // Retrieve the corresponding inventory key 00812 // const stdair::InventoryKey& lInventoryKey = 00813 // stdair::BomKeyManager::extractInventoryKey (iSegmentDateKey); 00814 00815 // Retrieve the slave AirInv service object from the (AirInv Master) 00816 // service context 00817 AIRINV_Service& lAIRINV_Service = 00818 lAIRINV_Master_ServiceContext.getAIRINV_Service(); 00819 00820 // Delegate the booking to the dedicated command 00821 stdair::BasChronometer lCancelChronometer; 00822 lCancelChronometer.start(); 00823 00824 // Delegate the BOM building to the dedicated service 00825 const bool hasBeenSaleSuccessful = 00826 lAIRINV_Service.cancel (iSegmentDateKey, iClassCode, iPartySize); 00827 00828 // const double lCancelMeasure = lCancelChronometer.elapsed(); 00829 00830 // DEBUG 00831 // STDAIR_LOG_DEBUG ("Booking cancel: " << lCancelMeasure << " - " 00832 // << lAIRINV_Master_ServiceContext.display()); 00833 00834 // 00835 return hasBeenSaleSuccessful; 00836 } 00837 00838 // //////////////////////////////////////////////////////////////////// 00839 bool AIRINV_Master_Service::cancel (const stdair::BookingClassID_T& iClassID, 00840 const stdair::PartySize_T& iPartySize) { 00841 00842 // Retrieve the AirInv Master service context 00843 if (_airinvMasterServiceContext == NULL) { 00844 throw stdair::NonInitialisedServiceException ("The AirInvMaster service " 00845 "has not been initialised"); 00846 } 00847 assert (_airinvMasterServiceContext != NULL); 00848 00849 AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext = 00850 *_airinvMasterServiceContext; 00851 00852 // Retrieve the corresponding inventory key 00853 // const stdair::InventoryKey& lInventoryKey = 00854 // stdair::BomKeyManager::extractInventoryKey (iSegmentDateKey); 00855 00856 // Retrieve the slave AirInv service object from the (AirInv Master) 00857 // service context 00858 AIRINV_Service& lAIRINV_Service = 00859 lAIRINV_Master_ServiceContext.getAIRINV_Service(); 00860 00861 // Delegate the booking to the dedicated command 00862 stdair::BasChronometer lCancelChronometer; 00863 lCancelChronometer.start(); 00864 00865 // Delegate the BOM building to the dedicated service 00866 const bool hasBeenSaleSuccessful = 00867 lAIRINV_Service.cancel (iClassID, iPartySize); 00868 00869 // const double lCancelMeasure = lCancelChronometer.elapsed(); 00870 00871 // DEBUG 00872 // STDAIR_LOG_DEBUG ("Booking cancel: " << lCancelMeasure << " - " 00873 // << lAIRINV_Master_ServiceContext.display()); 00874 00875 // 00876 return hasBeenSaleSuccessful; 00877 } 00878 00879 // //////////////////////////////////////////////////////////////////// 00880 void AIRINV_Master_Service:: 00881 takeSnapshots (const stdair::SnapshotStruct& iSnapshot) { 00882 00883 // Retrieve the AirInv Master service context 00884 if (_airinvMasterServiceContext == NULL) { 00885 throw stdair::NonInitialisedServiceException ("The AirInvMaster service " 00886 "has not been initialised"); 00887 } 00888 assert (_airinvMasterServiceContext != NULL); 00889 00890 AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext = 00891 *_airinvMasterServiceContext; 00892 00893 // Retrieve the slave AIRINV service object from the (AIRINV) 00894 // service context 00895 AIRINV_Service& lAIRINV_Service = 00896 lAIRINV_Master_ServiceContext.getAIRINV_Service(); 00897 00898 // Retrieve the snapshot time and the airline code. 00899 const stdair::DateTime_T& lSnapshotTime = iSnapshot.getSnapshotTime(); 00900 const stdair::AirlineCode_T& lAirlineCode = iSnapshot.getAirlineCode(); 00901 00902 lAIRINV_Service.takeSnapshots (lAirlineCode, lSnapshotTime); 00903 } 00904 00905 // //////////////////////////////////////////////////////////////////// 00906 void AIRINV_Master_Service:: 00907 optimise (const stdair::RMEventStruct& iRMEvent) { 00908 00909 // Retrieve the AirInv Master service context 00910 if (_airinvMasterServiceContext == NULL) { 00911 throw stdair::NonInitialisedServiceException ("The AirInvMaster service " 00912 "has not been initialised"); 00913 } 00914 assert (_airinvMasterServiceContext != NULL); 00915 00916 AIRINV_Master_ServiceContext& lAIRINV_Master_ServiceContext = 00917 *_airinvMasterServiceContext; 00918 00919 // Retrieve the slave AIRINV service object from the (AIRINV) 00920 // service context 00921 AIRINV_Service& lAIRINV_Service = 00922 lAIRINV_Master_ServiceContext.getAIRINV_Service(); 00923 00924 // Retrieve the snapshot time and the airline code. 00925 const stdair::DateTime_T& lRMEventTime = iRMEvent.getRMEventTime(); 00926 const stdair::AirlineCode_T& lAirlineCode = iRMEvent.getAirlineCode(); 00927 const stdair::KeyDescription_T& lFDDescription = 00928 iRMEvent.getFlightDateDescription(); 00929 00930 lAIRINV_Service.optimise (lAirlineCode, lFDDescription, lRMEventTime); 00931 } 00932 }