TravelCCM Logo  1.00.4
C++ Travel Customer Choice Model Library
CustomerChoiceModel.cpp
Go to the documentation of this file.
1 // //////////////////////////////////////////////////////////////////////
2 // Import section
3 // //////////////////////////////////////////////////////////////////////
4 // STL
5 #include <cassert>
6 #include <sstream>
7 #include <map>
8 // StdAir
9 #include <stdair/service/Logger.hpp>
10 // TravelCCM
13 
14 namespace TRAVELCCM {
15 
16  // ////////////////////////////////////////////////////////////////////
18  }
19 
20  // ////////////////////////////////////////////////////////////////////
22  (const stdair::PassengerChoiceModel::EN_PassengerChoiceModel& iPassengerChoiceModel) {
23  CustomerChoiceModelMap_T& lCustomerChoiceModelMap = getMap();
24  const bool hasInsertionBeenSuccessful =
25  lCustomerChoiceModelMap.insert (CustomerChoiceModelMap_T::value_type
26  (iPassengerChoiceModel, this)).second;
27  assert (hasInsertionBeenSuccessful == true);
28  }
29 
30  // ////////////////////////////////////////////////////////////////////
32  }
33 
34  // ////////////////////////////////////////////////////////////////////
36  (const stdair::PassengerChoiceModel::EN_PassengerChoiceModel& iPassengerChoiceModel) {
37 
38  const CustomerChoiceModel* lCustomerChoiceModel_ptr = NULL;
39 
40  // Try to retrieve the object corresponding to the enum type in the
41  // dedicated map.
42  const CustomerChoiceModelMap_T& lCustomerChoiceModelMap = getMap();
43  CustomerChoiceModelMap_T::const_iterator itModel =
44  lCustomerChoiceModelMap.find (iPassengerChoiceModel);
45 
46  // If no object is retrieved, then the algorithm corresponding to the given
47  // enum type has not been implemented yet.
48  if (itModel == lCustomerChoiceModelMap.end()) {
49  std::ostringstream oMessage;
50  oMessage << "The passenger choice model '"
51  << stdair::PassengerChoiceModel::getLabel (iPassengerChoiceModel)
52  << "' has not been implemented yet." << std::endl;
53  STDAIR_LOG_ERROR(oMessage.str());
54  throw MissingCustomerChoiceModelException (oMessage.str());
55  } else {
56  lCustomerChoiceModel_ptr = itModel->second;
57  }
58  assert (lCustomerChoiceModel_ptr != NULL);
59  return lCustomerChoiceModel_ptr;
60  }
61 
62 }
static const CustomerChoiceModel * create(const stdair::PassengerChoiceModel::EN_PassengerChoiceModel &)