$treeview $search $mathjax
00001 // ////////////////////////////////////////////////////////////////////// 00002 // Import section 00003 // ////////////////////////////////////////////////////////////////////// 00004 // STL 00005 #include <cassert> 00006 #include <sstream> 00007 #include <map> 00008 // StdAir 00009 #include <stdair/service/Logger.hpp> 00010 // TravelCCM 00011 #include <travelccm/bom/CustomerChoiceModel.hpp> 00012 #include <travelccm/TRAVELCCM_Types.hpp> 00013 00014 namespace TRAVELCCM { 00015 00016 // //////////////////////////////////////////////////////////////////// 00017 CustomerChoiceModel::CustomerChoiceModel () { 00018 } 00019 00020 // //////////////////////////////////////////////////////////////////// 00021 CustomerChoiceModel::CustomerChoiceModel 00022 (const stdair::PassengerChoiceModel::EN_PassengerChoiceModel& iPassengerChoiceModel) { 00023 CustomerChoiceModelMap_T& lCustomerChoiceModelMap = getMap(); 00024 const bool hasInsertionBeenSuccessful = 00025 lCustomerChoiceModelMap.insert (CustomerChoiceModelMap_T::value_type 00026 (iPassengerChoiceModel, this)).second; 00027 assert (hasInsertionBeenSuccessful == true); 00028 } 00029 00030 // //////////////////////////////////////////////////////////////////// 00031 CustomerChoiceModel::~CustomerChoiceModel() { 00032 } 00033 00034 // //////////////////////////////////////////////////////////////////// 00035 const CustomerChoiceModel* CustomerChoiceModel::create 00036 (const stdair::PassengerChoiceModel::EN_PassengerChoiceModel& iPassengerChoiceModel) { 00037 00038 const CustomerChoiceModel* lCustomerChoiceModel_ptr = NULL; 00039 00040 // Try to retrieve the object corresponding to the enum type in the 00041 // dedicated map. 00042 const CustomerChoiceModelMap_T& lCustomerChoiceModelMap = getMap(); 00043 CustomerChoiceModelMap_T::const_iterator itModel = 00044 lCustomerChoiceModelMap.find (iPassengerChoiceModel); 00045 00046 // If no object is retrieved, then the algorithm corresponding to the given 00047 // enum type has not been implemented yet. 00048 if (itModel == lCustomerChoiceModelMap.end()) { 00049 std::ostringstream oMessage; 00050 oMessage << "The passenger choice model '" 00051 << stdair::PassengerChoiceModel::getLabel (iPassengerChoiceModel) 00052 << "' has not been implemented yet." << std::endl; 00053 STDAIR_LOG_ERROR(oMessage.str()); 00054 throw MissingCustomerChoiceModelException (oMessage.str()); 00055 } else { 00056 lCustomerChoiceModel_ptr = itModel->second; 00057 } 00058 assert (lCustomerChoiceModel_ptr != NULL); 00059 return lCustomerChoiceModel_ptr; 00060 } 00061 00062 }