$treeview $search $mathjax
StdAir Logo  1.00.1
$projectbrief
$projectbrief
$searchbox

stdair/bom/BookingRequestStruct.cpp

Go to the documentation of this file.
00001 // //////////////////////////////////////////////////////////////////////
00002 // Import section
00003 // //////////////////////////////////////////////////////////////////////
00004 // STL
00005 #include <cassert>
00006 #include <sstream>
00007 // Boost
00008 #include <boost/date_time/gregorian/formatters.hpp>
00009 #include <boost/date_time/posix_time/posix_time.hpp>
00010 // StdAir
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       _changeFees (false), _changeFeeDisutility (0.0),
00033       _nonRefundable (false), _nonRefundableDisutility (0.0) {
00034     assert (false);
00035   }
00036 
00037   // //////////////////////////////////////////////////////////////////////
00038   BookingRequestStruct::
00039   BookingRequestStruct (const BookingRequestStruct& iBookingRequest)
00040     : _generatorKey (iBookingRequest._generatorKey),
00041       _origin (iBookingRequest._origin),
00042       _destination (iBookingRequest._destination),
00043       _pos (iBookingRequest._pos),
00044       _preferredDepartureDate (iBookingRequest._preferredDepartureDate), 
00045       _preferredDepartureTime (iBookingRequest._preferredDepartureTime),
00046       _requestDateTime (iBookingRequest._requestDateTime),
00047       _preferredCabin (iBookingRequest._preferredCabin),
00048       _partySize (iBookingRequest._partySize),
00049       _channel (iBookingRequest._channel),
00050       _tripType (iBookingRequest._tripType),
00051       _stayDuration (iBookingRequest._stayDuration),
00052       _frequentFlyerType (iBookingRequest._frequentFlyerType),
00053       _wtp (iBookingRequest._wtp),
00054       _valueOfTime (iBookingRequest._valueOfTime),
00055       _changeFees (iBookingRequest._changeFees),
00056       _changeFeeDisutility (iBookingRequest._changeFeeDisutility),
00057       _nonRefundable (iBookingRequest._nonRefundable),
00058       _nonRefundableDisutility (iBookingRequest._nonRefundableDisutility) {
00059   }
00060   
00061   // //////////////////////////////////////////////////////////////////////
00062   BookingRequestStruct::
00063   BookingRequestStruct (const DemandGeneratorKey_T& iGeneratorKey,
00064                         const AirportCode_T& iOrigin,
00065                         const AirportCode_T& iDestination,
00066                         const CityCode_T& iPOS,
00067                         const Date_T& iDepartureDate,
00068                         const DateTime_T& iRequestDateTime,
00069                         const CabinCode_T& iPreferredCabin,
00070                         const NbOfSeats_T& iPartySize,
00071                         const ChannelLabel_T& iChannel,
00072                         const TripType_T& iTripType,
00073                         const DayDuration_T& iStayDuration,
00074                         const FrequentFlyer_T& iFrequentFlyerType,
00075                         const Duration_T& iPreferredDepartureTime,
00076                         const WTP_T& iWTP,
00077                         const PriceValue_T& iValueOfTime,
00078                         const ChangeFees_T& iChangeFees,
00079                         const Disutility_T& iChangeFeeDisutility,
00080                         const NonRefundable_T& iNonRefundable,
00081                         const Disutility_T& iNonRefundableDisutility)
00082     : _generatorKey (iGeneratorKey), _origin (iOrigin),
00083       _destination (iDestination), _pos (iPOS), 
00084       _preferredDepartureDate (iDepartureDate), 
00085       _preferredDepartureTime (iPreferredDepartureTime),
00086       _requestDateTime (iRequestDateTime),
00087       _preferredCabin (iPreferredCabin), _partySize (iPartySize),
00088       _channel (iChannel), _tripType (iTripType),
00089       _stayDuration (iStayDuration), _frequentFlyerType (iFrequentFlyerType),
00090       _wtp (iWTP), _valueOfTime (iValueOfTime),
00091       _changeFees (iChangeFees), _changeFeeDisutility (iChangeFeeDisutility),
00092       _nonRefundable (iNonRefundable),
00093       _nonRefundableDisutility (iNonRefundableDisutility) {
00094   }
00095   
00096   // //////////////////////////////////////////////////////////////////////
00097   BookingRequestStruct::
00098   BookingRequestStruct (const AirportCode_T& iOrigin,
00099                         const AirportCode_T& iDestination,
00100                         const CityCode_T& iPOS,
00101                         const Date_T& iDepartureDate,
00102                         const DateTime_T& iRequestDateTime,
00103                         const CabinCode_T& iPreferredCabin,
00104                         const NbOfSeats_T& iPartySize,
00105                         const ChannelLabel_T& iChannel,
00106                         const TripType_T& iTripType,
00107                         const DayDuration_T& iStayDuration,
00108                         const FrequentFlyer_T& iFrequentFlyerType,
00109                         const Duration_T& iPreferredDepartureTime,
00110                         const WTP_T& iWTP,
00111                         const PriceValue_T& iValueOfTime,
00112                         const ChangeFees_T& iChangeFees,
00113                         const Disutility_T& iChangeFeeDisutility,
00114                         const NonRefundable_T& iNonRefundable,
00115                         const Disutility_T& iNonRefundableDisutility)
00116     : _generatorKey (""), _origin (iOrigin),
00117       _destination (iDestination), _pos (iPOS), 
00118       _preferredDepartureDate (iDepartureDate), 
00119       _preferredDepartureTime (iPreferredDepartureTime),
00120       _requestDateTime (iRequestDateTime),
00121       _preferredCabin (iPreferredCabin), _partySize (iPartySize),
00122       _channel (iChannel), _tripType (iTripType),
00123       _stayDuration (iStayDuration), _frequentFlyerType (iFrequentFlyerType),
00124       _wtp (iWTP), _valueOfTime (iValueOfTime),
00125       _changeFees (iChangeFees), _changeFeeDisutility (iChangeFeeDisutility),
00126       _nonRefundable (iNonRefundable),
00127       _nonRefundableDisutility (iNonRefundableDisutility) {
00128   }
00129   
00130   // //////////////////////////////////////////////////////////////////////
00131   BookingRequestStruct::~BookingRequestStruct() {
00132   }
00133   
00134   // //////////////////////////////////////////////////////////////////////
00135   void BookingRequestStruct::toStream (std::ostream& ioOut) const {
00136     ioOut << describe();
00137   }
00138 
00139   // //////////////////////////////////////////////////////////////////////
00140   void BookingRequestStruct::fromStream (std::istream& ioIn) {
00141   }
00142   
00143   // //////////////////////////////////////////////////////////////////////
00144   const std::string BookingRequestStruct::describe() const {
00145     std::ostringstream oStr;
00146     oStr << "At " << _requestDateTime
00147          << ", for (" << _pos << ", " << _channel << ")"
00148          << " " << _origin << "-" << _destination << " (" << _tripType << ")"
00149          << " " << _preferredDepartureDate << " (" << _stayDuration << " days)"
00150          << " " << _preferredDepartureTime
00151          << " " << _preferredCabin << " " << _partySize
00152          << " " << _frequentFlyerType << " " << _wtp << " " << _valueOfTime
00153          << " " << _changeFees << " " << _changeFeeDisutility << " "
00154          << _nonRefundable << " " << _nonRefundableDisutility;
00155     return oStr.str();
00156   }
00157 
00158   // ////////////////////////////////////////////////////////////////////
00159   void intDisplay (std::ostream& oStream, const int& iInt) {
00160     const int dInt = iInt - static_cast<int> (iInt / 100) * 100;
00161     if (dInt < 10) {
00162       oStream << "0" << dInt;
00163     } else {
00164       oStream << dInt;
00165     }
00166   }
00167   
00168   // //////////////////////////////////////////////////////////////////////
00169   const std::string BookingRequestStruct::display() const {
00170     std::ostringstream oStr;
00171 
00172     // Request date and time
00173     const Date_T& lRequestDate = _requestDateTime.date();
00174     oStr << boost::gregorian::to_iso_extended_string (lRequestDate);
00175 
00176     const Duration_T& lRequestTime = _requestDateTime.time_of_day();
00177     oStr << ", " << boost::posix_time::to_simple_string (lRequestTime);
00178 
00179     // POS
00180     oStr << ", " << _pos;
00181 
00182     // Channel
00183     oStr << ", " << _channel;
00184 
00185     // Origin
00186     oStr << ", " << _origin;
00187 
00188     // Destination
00189     oStr << ", " << _destination;
00190 
00191     // Preferred departure date
00192     oStr << ", "
00193          << boost::gregorian::to_iso_extended_string (_preferredDepartureDate);
00194 
00195     // Preferred departure time
00196     oStr << ", "
00197          << boost::posix_time::to_simple_string (_preferredDepartureTime);
00198 
00199     // MIN & MAX preferred departure time (hardcode)
00200     oStr << ", " << "00:00-23:59";
00201 
00202     // Preferred arrival date (hardcode to the preferred departure date)
00203     oStr << ", "
00204          << boost::gregorian::to_iso_extended_string (_preferredDepartureDate);
00205 
00206     // Preferred arrival time (hard-coded to 23:55)
00207     oStr << ", " << "23:55";
00208 
00209     // Preferred cabin
00210     oStr << ", " << _preferredCabin;
00211 
00212     // Trip type
00213     oStr << ", " << _tripType;
00214 
00215     // Duration of stay
00216     oStr << ", ";
00217     if (_tripType == TRIP_TYPE_ONE_WAY) {
00218       oStr << "0";
00219     } else {
00220       oStr << _stayDuration;
00221     }
00222 
00223     // Frequent flyer tier
00224     oStr << ", " << _frequentFlyerType;
00225 
00226     // Willingness-to-pay
00227     oStr << ", " << _wtp;
00228 
00229     // Disutility per stop (hardcode to 100, expressed as a monetary
00230     // unit per hour)
00231     oStr << ", " << "100";
00232 
00233     // Value of time
00234     oStr << ", " << _valueOfTime;
00235 
00236     // Change fees
00237     oStr << ", " << _changeFees;
00238 
00239     // Change fee disutility
00240     oStr << ", " << _changeFeeDisutility;
00241 
00242     // Non refundable
00243     oStr << ", " << _nonRefundable;
00244 
00245     // Non refundable disutility
00246     oStr << ", " << _nonRefundableDisutility;
00247 
00248     return oStr.str();
00249   }
00250 
00251 }