TraDemGen Logo  1.00.0
C++ Simulated Travel Demand Generation Library
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
BomDisplay.cpp
Go to the documentation of this file.
1 // //////////////////////////////////////////////////////////////////////
2 // Import section
3 // //////////////////////////////////////////////////////////////////////
4 // STL
5 #include <cassert>
6 #include <ostream>
7 // StdAir
8 #include <stdair/basic/BasConst_BomDisplay.hpp>
9 #include <stdair/bom/BomManager.hpp>
10 // SEvMgr
11 #include <sevmgr/SEVMGR_Service.hpp>
12 #include <sevmgr/SEVMGR_Types.hpp>
13 // TraDemGen
16 
17 namespace TRADEMGEN {
18 
24  struct FlagSaver {
25  public:
27  FlagSaver (std::ostream& oStream)
28  : _oStream (oStream), _streamFlags (oStream.flags()) {
29  }
30 
33  // Reset formatting flags of the given output stream
34  _oStream.flags (_streamFlags);
35  }
36 
37  private:
39  std::ostream& _oStream;
41  std::ios::fmtflags _streamFlags;
42  };
43 
44  // ////////////////////////////////////////////////////////////////////
45  std::string BomDisplay::csvDisplay (const SEVMGR::SEVMGR_ServicePtr_T iSEVMGR_ServicePtr) {
46  std::ostringstream oStream;
47 
48  //
49  assert (iSEVMGR_ServicePtr != NULL);
50 
54  oStream << std::endl;
55  oStream << "==============================================================="
56  << std::endl;
57  oStream << "EventQueue: " << iSEVMGR_ServicePtr->describeKey() << std::endl;
58  oStream << "==============================================================="
59  << std::endl;
60 
61  // Check whether there are DemandStream objects
62  const bool hasEventGeneratorList =
63  iSEVMGR_ServicePtr->hasEventGeneratorList<DemandStream>();
64  if (hasEventGeneratorList == false) {
65  return oStream.str();
66  }
67 
68  // Retrieve the DemandStream list
69  const DemandStreamList_T& lDemandStreamList =
70  iSEVMGR_ServicePtr->getEventGeneratorList<DemandStream>();
71 
72  // Browse the inventories
73  for (DemandStreamList_T::const_iterator itDemandStream =
74  lDemandStreamList.begin();
75  itDemandStream != lDemandStreamList.end(); ++itDemandStream) {
76  DemandStream* lDemandStream_ptr = *itDemandStream;
77  assert (lDemandStream_ptr != NULL);
78 
79  // Display the demand stream
80  csvDisplay (oStream, *lDemandStream_ptr);
81  }
82 
83  return oStream.str();
84  }
85 
86  // ////////////////////////////////////////////////////////////////////
87  void BomDisplay::csvDisplay (std::ostream& oStream,
88  const DemandStream& iDemandStream) {
89  // Save the formatting flags for the given STL output stream
90  FlagSaver flagSaver (oStream);
91 
95  oStream << "+++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;
96  oStream << iDemandStream.display();
97  oStream << "+++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;
98  }
99 
100 }