00001
00002
00003
00004
00005 #include <cassert>
00006 #include <sstream>
00007
00008 #include <boost/date_time/gregorian/formatters.hpp>
00009 #include <boost/date_time/posix_time/posix_time.hpp>
00010
00011 #include <stdair/basic/BasConst_Inventory.hpp>
00012 #include <stdair/basic/BasConst_Request.hpp>
00013 #include <stdair/bom/BookingRequestStruct.hpp>
00014
00015 namespace stdair {
00016
00017
00018 BookingRequestStruct::BookingRequestStruct()
00019 : _origin (DEFAULT_ORIGIN), _destination (DEFAULT_DESTINATION),
00020 _pos (DEFAULT_POS),
00021 _preferredDepartureDate (DEFAULT_PREFERRED_DEPARTURE_DATE),
00022 _preferredDepartureTime (DEFAULT_PREFERRED_DEPARTURE_TIME),
00023 _requestDateTime (DEFAULT_REQUEST_DATE_TIME),
00024 _preferredCabin (DEFAULT_PREFERRED_CABIN),
00025 _partySize (DEFAULT_PARTY_SIZE),
00026 _channel (DEFAULT_CHANNEL),
00027 _tripType (TRIP_TYPE_ONE_WAY),
00028 _stayDuration (DEFAULT_STAY_DURATION),
00029 _frequentFlyerType (DEFAULT_FF_TIER),
00030 _wtp (DEFAULT_WTP),
00031 _valueOfTime (DEFAULT_VALUE_OF_TIME) {
00032 assert (false);
00033 }
00034
00035
00036 BookingRequestStruct::
00037 BookingRequestStruct (const BookingRequestStruct& iBookingRequest)
00038 : _generatorKey (iBookingRequest._generatorKey),
00039 _origin (iBookingRequest._origin),
00040 _destination (iBookingRequest._destination),
00041 _pos (iBookingRequest._pos),
00042 _preferredDepartureDate (iBookingRequest._preferredDepartureDate),
00043 _preferredDepartureTime (iBookingRequest._preferredDepartureTime),
00044 _requestDateTime (iBookingRequest._requestDateTime),
00045 _preferredCabin (iBookingRequest._preferredCabin),
00046 _partySize (iBookingRequest._partySize),
00047 _channel (iBookingRequest._channel),
00048 _tripType (iBookingRequest._tripType),
00049 _stayDuration (iBookingRequest._stayDuration),
00050 _frequentFlyerType (iBookingRequest._frequentFlyerType),
00051 _wtp (iBookingRequest._wtp),
00052 _valueOfTime (iBookingRequest._valueOfTime) {
00053 }
00054
00055
00056 BookingRequestStruct::
00057 BookingRequestStruct (const DemandGeneratorKey_T& iGeneratorKey,
00058 const AirportCode_T& iOrigin,
00059 const AirportCode_T& iDestination,
00060 const CityCode_T& iPOS,
00061 const Date_T& iDepartureDate,
00062 const DateTime_T& iRequestDateTime,
00063 const CabinCode_T& iPreferredCabin,
00064 const NbOfSeats_T& iPartySize,
00065 const ChannelLabel_T& iChannel,
00066 const TripType_T& iTripType,
00067 const DayDuration_T& iStayDuration,
00068 const FrequentFlyer_T& iFrequentFlyerType,
00069 const Duration_T& iPreferredDepartureTime,
00070 const WTP_T& iWTP,
00071 const PriceValue_T& iValueOfTime)
00072 : _generatorKey (iGeneratorKey), _origin (iOrigin),
00073 _destination (iDestination), _pos (iPOS),
00074 _preferredDepartureDate (iDepartureDate),
00075 _preferredDepartureTime (iPreferredDepartureTime),
00076 _requestDateTime (iRequestDateTime),
00077 _preferredCabin (iPreferredCabin), _partySize (iPartySize),
00078 _channel (iChannel), _tripType (iTripType),
00079 _stayDuration (iStayDuration), _frequentFlyerType (iFrequentFlyerType),
00080 _wtp (iWTP), _valueOfTime (iValueOfTime) {
00081 }
00082
00083
00084 BookingRequestStruct::
00085 BookingRequestStruct (const AirportCode_T& iOrigin,
00086 const AirportCode_T& iDestination,
00087 const CityCode_T& iPOS,
00088 const Date_T& iDepartureDate,
00089 const DateTime_T& iRequestDateTime,
00090 const CabinCode_T& iPreferredCabin,
00091 const NbOfSeats_T& iPartySize,
00092 const ChannelLabel_T& iChannel,
00093 const TripType_T& iTripType,
00094 const DayDuration_T& iStayDuration,
00095 const FrequentFlyer_T& iFrequentFlyerType,
00096 const Duration_T& iPreferredDepartureTime,
00097 const WTP_T& iWTP,
00098 const PriceValue_T& iValueOfTime)
00099 : _generatorKey (""), _origin (iOrigin),
00100 _destination (iDestination), _pos (iPOS),
00101 _preferredDepartureDate (iDepartureDate),
00102 _preferredDepartureTime (iPreferredDepartureTime),
00103 _requestDateTime (iRequestDateTime),
00104 _preferredCabin (iPreferredCabin), _partySize (iPartySize),
00105 _channel (iChannel), _tripType (iTripType),
00106 _stayDuration (iStayDuration), _frequentFlyerType (iFrequentFlyerType),
00107 _wtp (iWTP), _valueOfTime (iValueOfTime) {
00108 }
00109
00110
00111 BookingRequestStruct::~BookingRequestStruct() {
00112 }
00113
00114
00115 void BookingRequestStruct::toStream (std::ostream& ioOut) const {
00116 ioOut << describe();
00117 }
00118
00119
00120 void BookingRequestStruct::fromStream (std::istream& ioIn) {
00121 }
00122
00123
00124 const std::string BookingRequestStruct::describe() const {
00125 std::ostringstream oStr;
00126 oStr << "At " << _requestDateTime
00127 << ", for (" << _pos << ", " << _channel << ")"
00128 << " " << _origin << "-" << _destination << " (" << _tripType << ")"
00129 << " " << _preferredDepartureDate << " (" << _stayDuration << " days)"
00130 << " " << _preferredDepartureTime
00131 << " " << _preferredCabin << " " << _partySize
00132 << " " << _frequentFlyerType << " " << _wtp << " " << _valueOfTime;
00133 return oStr.str();
00134 }
00135
00136
00137 void intDisplay (std::ostream& oStream, const int& iInt) {
00138 const int dInt = iInt - static_cast<int> (iInt / 100) * 100;
00139 if (dInt < 10) {
00140 oStream << "0" << dInt;
00141 } else {
00142 oStream << dInt;
00143 }
00144 }
00145
00146
00147 const std::string BookingRequestStruct::display() const {
00148 std::ostringstream oStr;
00149
00150
00151 const Date_T& lRequestDate = _requestDateTime.date();
00152 oStr << boost::gregorian::to_iso_extended_string (lRequestDate);
00153
00154 const Duration_T& lRequestTime = _requestDateTime.time_of_day();
00155 oStr << ", " << boost::posix_time::to_simple_string (lRequestTime);
00156
00157
00158 oStr << ", " << _pos;
00159
00160
00161 oStr << ", " << _channel;
00162
00163
00164 oStr << ", " << _origin;
00165
00166
00167 oStr << ", " << _destination;
00168
00169
00170 oStr << ", "
00171 << boost::gregorian::to_iso_extended_string (_preferredDepartureDate);
00172
00173
00174 oStr << ", "
00175 << boost::posix_time::to_simple_string (_preferredDepartureTime);
00176
00177
00178 oStr << ", " << "00:00-23:59";
00179
00180
00181 oStr << ", "
00182 << boost::gregorian::to_iso_extended_string (_preferredDepartureDate);
00183
00184
00185 oStr << ", " << "23:55";
00186
00187
00188 oStr << ", " << _preferredCabin;
00189
00190
00191 oStr << ", " << _tripType;
00192
00193
00194 oStr << ", ";
00195 if (_tripType == TRIP_TYPE_ONE_WAY) {
00196 oStr << "0";
00197 } else {
00198 oStr << _stayDuration;
00199 }
00200
00201
00202 oStr << ", " << _frequentFlyerType;
00203
00204
00205 oStr << ", " << _wtp;
00206
00207
00208
00209 oStr << ", " << "100";
00210
00211
00212 oStr << ", " << _valueOfTime;
00213
00214 return oStr.str();
00215 }
00216
00217 }