$treeview $search $mathjax
00001 // ////////////////////////////////////////////////////////////////////// 00002 // Import section 00003 // ////////////////////////////////////////////////////////////////////// 00004 // STL 00005 #include <cassert> 00006 #include <sstream> 00007 // StdAir 00008 #include <stdair/bom/VirtualClassStruct.hpp> 00009 #include <stdair/bom/BookingClass.hpp> 00010 00011 namespace stdair { 00012 00013 // //////////////////////////////////////////////////////////////////// 00014 VirtualClassStruct::VirtualClassStruct() { 00015 assert (false); 00016 } 00017 00018 // //////////////////////////////////////////////////////////////////// 00019 VirtualClassStruct::VirtualClassStruct (const VirtualClassStruct& iVC) 00020 : _bookingClassList (iVC._bookingClassList), _yield (iVC._yield), 00021 _mean (iVC._mean), _stdDev (iVC._stdDev) { 00022 } 00023 00024 // //////////////////////////////////////////////////////////////////// 00025 VirtualClassStruct:: 00026 VirtualClassStruct (const BookingClassList_T& ioBookingClassList) { 00027 _bookingClassList = ioBookingClassList; 00028 } 00029 00030 // //////////////////////////////////////////////////////////////////// 00031 VirtualClassStruct::~VirtualClassStruct() { 00032 00033 } 00034 00035 // //////////////////////////////////////////////////////////////////// 00036 void VirtualClassStruct::toStream (std::ostream& ioOut) const { 00037 ioOut << describe(); 00038 } 00039 00040 // //////////////////////////////////////////////////////////////////// 00041 void VirtualClassStruct::fromStream (std::istream& ioIn) { 00042 } 00043 00044 // //////////////////////////////////////////////////////////////////// 00045 const std::string VirtualClassStruct::describe() const { 00046 std::ostringstream oStr; 00047 oStr << "Yield: " << _yield 00048 << ", Demand N (" << _mean << ", " << _stdDev << ")"; 00049 return oStr.str(); 00050 } 00051 00052 // //////////////////////////////////////////////////////////////////// 00053 const GeneratedDemandVector_T VirtualClassStruct:: 00054 getGeneratedDemandVector() const { 00055 GeneratedDemandVector_T lDemandVector; 00056 const bool isBookingClassListEmpty = _bookingClassList.empty(); 00057 if (isBookingClassListEmpty == false) { 00058 assert (isBookingClassListEmpty == false); 00059 BookingClassList_T::const_iterator itBC = _bookingClassList.begin(); 00060 BookingClass* lBC_ptr = *itBC; 00061 const GeneratedDemandVector_T& lFirstDemandVector = 00062 lBC_ptr->getGeneratedDemandVector(); 00063 const unsigned int lFirstDemandVectorSize = lFirstDemandVector.size(); 00064 for (unsigned int i = 0; i < lFirstDemandVectorSize; ++i) { 00065 const double& lDemand = lFirstDemandVector[i]; 00066 lDemandVector.push_back(lDemand); 00067 } 00068 const unsigned int& lDemandVectorSize = lDemandVector.size(); 00069 ++itBC; 00070 for (; itBC != _bookingClassList.end(); ++ itBC) { 00071 lBC_ptr = *itBC; 00072 assert(lBC_ptr != NULL); 00073 const GeneratedDemandVector_T& lCurrentDemandVector = 00074 lBC_ptr->getGeneratedDemandVector(); 00075 const unsigned int& lCurrentDemandVectorSize = 00076 lCurrentDemandVector.size(); 00077 assert(lDemandVectorSize == lCurrentDemandVectorSize); 00078 for (unsigned int i = 0; i < lDemandVectorSize; ++i) { 00079 lDemandVector[i] += lCurrentDemandVector[i]; 00080 } 00081 } 00082 } 00083 return lDemandVector; 00084 } 00085 }