AirTSP Logo  1.01.0
C++ Simulated Airline Travel Solution Provider Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 #include <stdair/bom/BomRoot.hpp>
11 // AirTSP
14 
15 namespace AIRTSP {
16 
22  struct FlagSaver {
23  public:
25  FlagSaver (std::ostream& oStream)
26  : _oStream (oStream), _streamFlags (oStream.flags()) {
27  }
28 
31  // Reset formatting flags of the given output stream
32  _oStream.flags (_streamFlags);
33  }
34 
35  private:
37  std::ostream& _oStream;
39  std::ios::fmtflags _streamFlags;
40  };
41 
42  // ////////////////////////////////////////////////////////////////////
43  std::string BomDisplay::csvDisplay (const stdair::BomRoot& iBomRoot) {
44  std::ostringstream oStream;
45 
49  oStream << std::endl;
50  oStream << "==============================================================="
51  << std::endl;
52  oStream << "BomRoot: " << iBomRoot.describeKey() << std::endl;
53  oStream << "==============================================================="
54  << std::endl;
55 
56  // Check whether there are ReachableUniverse objects
57  if (stdair::BomManager::hasList<ReachableUniverse> (iBomRoot) == false) {
58  return oStream.str();
59  }
60 
61  // Retrieve the ReachableUniverse list
62  const ReachableUniverseList_T& lReachableUniverseList =
63  stdair::BomManager::getList<ReachableUniverse> (iBomRoot);
64 
65  // Browse the networks for each departure airport
66  for (ReachableUniverseList_T::const_iterator itReachableUniverse =
67  lReachableUniverseList.begin();
68  itReachableUniverse != lReachableUniverseList.end();
69  ++itReachableUniverse) {
70  ReachableUniverse* lReachableUniverse_ptr = *itReachableUniverse;
71  assert (lReachableUniverse_ptr != NULL);
72 
73  // Display the reachable universe
74  csvDisplay (oStream, *lReachableUniverse_ptr);
75  }
76 
77  return oStream.str();
78  }
79 
80  // ////////////////////////////////////////////////////////////////////
81  void BomDisplay::csvDisplay (std::ostream& oStream,
82  const ReachableUniverse& iReachableUniverse) {
83  // Save the formatting flags for the given STL output stream
84  FlagSaver flagSaver (oStream);
85 
89  oStream << "+++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;
90  oStream << iReachableUniverse.toString();
91  oStream << "+++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;
92  }
93 
94 }