$treeview $search $mathjax
00001 00012 #ifndef __STDAIR_STDAIR_HPP 00013 #define __STDAIR_STDAIR_HPP 00014 00015 // ////////////////////////////////////////////////////////////////////// 00016 // Import section 00017 // ////////////////////////////////////////////////////////////////////// 00018 // STL 00019 #include <string> 00020 // StdAir 00021 #include <stdair/stdair_inventory_types.hpp> 00022 #include <stdair/stdair_service_types.hpp> 00023 #include <stdair/stdair_file.hpp> 00024 #include <stdair/basic/BasLogParams.hpp> 00025 #include <stdair/basic/BasDBParams.hpp> 00026 #include <stdair/basic/ServiceInitialisationType.hpp> 00027 #include <stdair/bom/TravelSolutionTypes.hpp> 00028 #include <stdair/bom/ConfigHolderStruct.hpp> 00029 #include <stdair/service/STDAIR_ServiceContext.hpp> 00030 00031 namespace stdair { 00032 00034 class BomRoot; 00035 struct EventStruct; 00036 struct ProgressStatusSet; 00037 struct BookingRequestStruct; 00038 class JSONString; 00039 00040 00044 class STDAIR_Service { 00045 public: 00046 // ////////// Constructors and destructors ////////// 00050 STDAIR_Service(); 00051 00063 STDAIR_Service (const BasLogParams&); 00064 00080 STDAIR_Service (const BasLogParams&, const BasDBParams&); 00081 00085 ~STDAIR_Service(); 00086 00087 00088 public: 00089 // ////////////////// Business support methods ////////////////// 00109 void buildSampleBom(); 00110 00132 void buildDummyInventory (const CabinCapacity_T& iCabinCapacity); 00133 00146 void buildDummyLegSegmentAccesses (BomRoot&); 00147 00162 void buildSampleTravelSolutionForPricing (TravelSolutionList_T&); 00163 00181 void buildSampleTravelSolutions (TravelSolutionList_T&); 00182 00211 BookingRequestStruct buildSampleBookingRequest (const bool isForCRS = false); 00212 00216 void clonePersistentBom (); 00217 00218 public: 00219 00220 // //////////////// Export support methods ///////////////// 00233 std::string jsonExportFlightDateList (const AirlineCode_T& iAirlineCode = "all", 00234 const FlightNumber_T& iFlightNumber = 0) const; 00235 00246 std::string jsonExportFlightDateObjects (const AirlineCode_T&, 00247 const FlightNumber_T&, 00248 const Date_T& iDepartureDate) const; 00249 00256 std::string jsonExportEventObject (const EventStruct&) const; 00257 00264 std::string jsonExportConfiguration () const; 00265 00266 public: 00267 00268 // //////////////// Import support methods ///////////////// 00276 bool jsonImportConfiguration (const JSONString&) const; 00277 00278 public: 00279 // //////////////// Display support methods ///////////////// 00293 std::string list (const AirlineCode_T& iAirlineCode = "all", 00294 const FlightNumber_T& iFlightNumber = 0) const; 00295 00302 std::string listAirportPairDateRange () const; 00303 00313 bool check (const AirlineCode_T&, const FlightNumber_T&, 00314 const Date_T& iDepartureDate) const; 00315 00328 bool check (const AirportCode_T&, const AirportCode_T&, 00329 const Date_T& iDepartureDate) const; 00330 00337 std::string configDisplay () const; 00338 00346 std::string csvDisplay () const; 00347 00356 std::string csvDisplay (const BomRoot&) const; 00357 00367 std::string csvDisplay (const AirlineCode_T&, const FlightNumber_T&, 00368 const Date_T& iDepartureDate) const; 00369 00377 std::string csvDisplay (const TravelSolutionList_T&) const; 00378 00389 std::string csvDisplay (const AirportCode_T&, const AirportCode_T&, 00390 const Date_T& iDepartureDate) const; 00391 00392 00393 public: 00394 // ///////////////// Getters /////////////////// 00403 BomRoot& getBomRoot() const; 00404 00413 BomRoot& getPersistentBomRoot() const; 00414 00420 BasLogParams getLogParams() const; 00421 00428 const BasDBParams& getDBParams() const; 00429 00438 const ServiceInitialisationType& getServiceInitialisationType() const; 00439 00440 00441 private: 00442 // /////// Construction and Destruction helper methods /////// 00449 STDAIR_Service (const STDAIR_Service&); 00450 00455 void initServiceContext(); 00456 00474 void logInit (const BasLogParams&); 00475 00481 void dbInit (const BasDBParams&); 00482 00498 void init(); 00499 00503 void finalise(); 00504 00505 public: 00506 00512 void importINIConfig (const ConfigINIFile&); 00513 00522 void importConfigValue (const std::string& iValue, 00523 const std::string& iPath); 00524 00533 template <typename ValueType> 00534 bool exportConfigValue (ValueType& ioValue, const std::string& iPath); 00535 00540 void updateAirlineFeatures (); 00541 00542 private: 00543 // ///////// Service Context ///////// 00547 STDAIR_ServiceContext* _stdairServiceContext; 00548 }; 00549 00550 // //////////////////////////////////////////////////////////////////// 00551 template <typename ValueType> 00552 bool STDAIR_Service::exportConfigValue (ValueType& ioValue, 00553 const std::string& iPath) { 00554 00555 // Retrieve the StdAir service context 00556 assert (_stdairServiceContext != NULL); 00557 const STDAIR_ServiceContext& lSTDAIR_ServiceContext = 00558 *_stdairServiceContext; 00559 00560 // Retrieve the BOM tree root 00561 const ConfigHolderStruct& lConfigHolder = 00562 lSTDAIR_ServiceContext.getConfigHolder(); 00563 00564 // Call the dedicated configuration holder method. 00565 return lConfigHolder.exportValue <ValueType> (ioValue, iPath); 00566 } 00567 // //////////////////////////////////////////////////////////////////// 00568 00569 } 00570 #endif // __STDAIR_STDAIR_HPP