$treeview $search $mathjax
00001 // ////////////////////////////////////////////////////////////////////// 00002 // Import section 00003 // ////////////////////////////////////////////////////////////////////// 00004 // STL 00005 #include <cassert> 00006 #include <ostream> 00007 // StdAir 00008 #include <stdair/basic/BasConst_BomDisplay.hpp> 00009 #include <stdair/bom/BomManager.hpp> 00010 // SEvMgr 00011 #include <sevmgr/SEVMGR_Service.hpp> 00012 #include <sevmgr/SEVMGR_Types.hpp> 00013 // TraDemGen 00014 #include <trademgen/bom/DemandStream.hpp> 00015 #include <trademgen/bom/BomDisplay.hpp> 00016 00017 namespace TRADEMGEN { 00018 00024 struct FlagSaver { 00025 public: 00027 FlagSaver (std::ostream& oStream) 00028 : _oStream (oStream), _streamFlags (oStream.flags()) { 00029 } 00030 00032 ~FlagSaver() { 00033 // Reset formatting flags of the given output stream 00034 _oStream.flags (_streamFlags); 00035 } 00036 00037 private: 00039 std::ostream& _oStream; 00041 std::ios::fmtflags _streamFlags; 00042 }; 00043 00044 // //////////////////////////////////////////////////////////////////// 00045 std::string BomDisplay::csvDisplay (const SEVMGR::SEVMGR_ServicePtr_T iSEVMGR_ServicePtr) { 00046 std::ostringstream oStream; 00047 00048 // 00049 assert (iSEVMGR_ServicePtr != NULL); 00050 00054 oStream << std::endl; 00055 oStream << "===============================================================" 00056 << std::endl; 00057 oStream << "EventQueue: " << iSEVMGR_ServicePtr->describeKey() << std::endl; 00058 oStream << "===============================================================" 00059 << std::endl; 00060 00061 // Check whether there are DemandStream objects 00062 const bool hasEventGeneratorList = 00063 iSEVMGR_ServicePtr->hasEventGeneratorList<DemandStream>(); 00064 if (hasEventGeneratorList == false) { 00065 return oStream.str(); 00066 } 00067 00068 // Retrieve the DemandStream list 00069 const DemandStreamList_T& lDemandStreamList = 00070 iSEVMGR_ServicePtr->getEventGeneratorList<DemandStream>(); 00071 00072 // Browse the inventories 00073 for (DemandStreamList_T::const_iterator itDemandStream = 00074 lDemandStreamList.begin(); 00075 itDemandStream != lDemandStreamList.end(); ++itDemandStream) { 00076 DemandStream* lDemandStream_ptr = *itDemandStream; 00077 assert (lDemandStream_ptr != NULL); 00078 00079 // Display the demand stream 00080 csvDisplay (oStream, *lDemandStream_ptr); 00081 } 00082 00083 return oStream.str(); 00084 } 00085 00086 // //////////////////////////////////////////////////////////////////// 00087 void BomDisplay::csvDisplay (std::ostream& oStream, 00088 const DemandStream& iDemandStream) { 00089 // Save the formatting flags for the given STL output stream 00090 FlagSaver flagSaver (oStream); 00091 00095 oStream << "+++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl; 00096 oStream << iDemandStream.display(); 00097 oStream << "+++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl; 00098 } 00099 00100 }