StdAir Logo  0.45.1
C++ Standard Airline IT Object Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BookingClass.cpp
Go to the documentation of this file.
1 // //////////////////////////////////////////////////////////////////////
2 // Import section
3 // //////////////////////////////////////////////////////////////////////
4 // STL
5 #include <cassert>
6 #include <sstream>
7 // StdAir
12 
13 namespace stdair {
14 
15  // ////////////////////////////////////////////////////////////////////
16  BookingClass::BookingClass() : _key (DEFAULT_CLASS_CODE), _parent (NULL) {
17  assert (false);
18  }
19 
20  // ////////////////////////////////////////////////////////////////////
21  BookingClass::BookingClass (const BookingClass&)
22  : _key (DEFAULT_CLASS_CODE), _parent (NULL) {
23  assert (false);
24  }
25 
26  // ////////////////////////////////////////////////////////////////////
27  BookingClass::BookingClass (const Key_T& iKey)
28  : _key (iKey), _parent (NULL), _cumulatedProtection (0.0),
29  _protection (0.0), _cumulatedBookingLimit (0.0), _au (0.0), _nego (0.0),
30  _noShowPercentage (0.0), _cancellationPercentage (0.0),
31  _nbOfBookings (0.0), _groupNbOfBookings (0.0),
32  _groupPendingNbOfBookings (0.0), _staffNbOfBookings (0.0),
33  _wlNbOfBookings (0.0), _nbOfCancellations (0.), _etb (0.0),
34  _netClassAvailability (0.0), _segmentAvailability (0.0),
35  _netRevenueAvailability (0.0), _yield (0.0), _mean (0.0), _stdDev (0.0) {
36  }
37 
38  // ////////////////////////////////////////////////////////////////////
40  }
41 
42  // ////////////////////////////////////////////////////////////////////
43  std::string BookingClass::toString() const {
44  std::ostringstream oStr;
45  oStr << describeKey();
46  return oStr.str();
47  }
48 
49  // ////////////////////////////////////////////////////////////////////
50  void BookingClass::sell (const NbOfBookings_T& iNbOfBookings) {
51  _nbOfBookings += iNbOfBookings;
52  }
53 
54  // ////////////////////////////////////////////////////////////////////
55  void BookingClass::cancel (const NbOfBookings_T& iNbOfCancellations) {
56  _nbOfBookings -= iNbOfCancellations;
57  _nbOfCancellations += iNbOfCancellations;
58  }
59 
60  // ////////////////////////////////////////////////////////////////////
62  _generatedDemandVector.clear();
63  if (_stdDev > 0) {
65  for (int i = 0; i < K; ++i) {
66  RealNumber_T lDemandSample = lGenerator.generateNormal (_mean, _stdDev);
67  _generatedDemandVector.push_back (lDemandSample);
68  }
69  }
70  }
71 
72  // ////////////////////////////////////////////////////////////////////
74  const RandomSeed_T& iSeed) {
75  _generatedDemandVector.clear();
76  if (_stdDev > 0) {
77  RandomGeneration lGenerator (iSeed);
78  for (int i = 0; i < K; ++i) {
79  RealNumber_T lDemandSample = lGenerator.generateNormal (_mean, _stdDev);
80  _generatedDemandVector.push_back (lDemandSample);
81  }
82  }
83  }
84 
85 }
86