StdAir Logo  1.00.3
C++ Standard Airline IT Object Library
VirtualClassStruct.cpp
Go to the documentation of this file.
1 // //////////////////////////////////////////////////////////////////////
2 // Import section
3 // //////////////////////////////////////////////////////////////////////
4 // STL
5 #include <cassert>
6 #include <sstream>
7 // StdAir
10 
11 namespace stdair {
12 
13  // ////////////////////////////////////////////////////////////////////
14  VirtualClassStruct::VirtualClassStruct() {
15  assert (false);
16  }
17 
18  // ////////////////////////////////////////////////////////////////////
19  VirtualClassStruct::VirtualClassStruct (const VirtualClassStruct& iVC)
20  : _bookingClassList (iVC._bookingClassList), _yield (iVC._yield),
21  _mean (iVC._mean), _stdDev (iVC._stdDev) {
22  }
23 
24  // ////////////////////////////////////////////////////////////////////
25  VirtualClassStruct::
26  VirtualClassStruct (const BookingClassList_T& ioBookingClassList) {
27  _bookingClassList = ioBookingClassList;
28  }
29 
30  // ////////////////////////////////////////////////////////////////////
32 
33  }
34 
35  // ////////////////////////////////////////////////////////////////////
36  void VirtualClassStruct::toStream (std::ostream& ioOut) const {
37  ioOut << describe();
38  }
39 
40  // ////////////////////////////////////////////////////////////////////
41  void VirtualClassStruct::fromStream (std::istream& ioIn) {
42  }
43 
44  // ////////////////////////////////////////////////////////////////////
45  const std::string VirtualClassStruct::describe() const {
46  std::ostringstream oStr;
47  oStr << "Yield: " << _yield
48  << ", Demand N (" << _mean << ", " << _stdDev << ")";
49  return oStr.str();
50  }
51 
52  // ////////////////////////////////////////////////////////////////////
55  GeneratedDemandVector_T lDemandVector;
56  const bool isBookingClassListEmpty = _bookingClassList.empty();
57  if (isBookingClassListEmpty == false) {
58  assert (isBookingClassListEmpty == false);
59  BookingClassList_T::const_iterator itBC = _bookingClassList.begin();
60  BookingClass* lBC_ptr = *itBC;
61  const GeneratedDemandVector_T& lFirstDemandVector =
62  lBC_ptr->getGeneratedDemandVector();
63  const unsigned int lFirstDemandVectorSize = lFirstDemandVector.size();
64  for (unsigned int i = 0; i < lFirstDemandVectorSize; ++i) {
65  const double& lDemand = lFirstDemandVector[i];
66  lDemandVector.push_back(lDemand);
67  }
68  const unsigned int& lDemandVectorSize = lDemandVector.size();
69  ++itBC;
70  for (; itBC != _bookingClassList.end(); ++ itBC) {
71  lBC_ptr = *itBC;
72  assert(lBC_ptr != NULL);
73  const GeneratedDemandVector_T& lCurrentDemandVector =
74  lBC_ptr->getGeneratedDemandVector();
75  const unsigned int& lCurrentDemandVectorSize =
76  lCurrentDemandVector.size();
77  assert(lDemandVectorSize == lCurrentDemandVectorSize);
78  for (unsigned int i = 0; i < lDemandVectorSize; ++i) {
79  lDemandVector[i] += lCurrentDemandVector[i];
80  }
81  }
82  }
83  return lDemandVector;
84  }
85 }
Handle on the StdAir library context.
std::list< BookingClass * > BookingClassList_T
void fromStream(std::istream &ioIn)
const GeneratedDemandVector_T getGeneratedDemandVector() const
std::vector< double > GeneratedDemandVector_T
const std::string describe() const
void toStream(std::ostream &ioOut) const
const GeneratedDemandVector_T & getGeneratedDemandVector() const