From ee35fc8de228f9114055c8c0ff02172a741e4829 Mon Sep 17 00:00:00 2001 From: Tommaso Pecorella Date: Sat, 12 Nov 2016 01:25:34 +0100 Subject: [PATCH] flow-monitor: (fixes #2545) Optimized build fails for flow-monitor (2) --- src/flow-monitor/model/flow-monitor.cc | 16 ++++++---------- src/flow-monitor/model/flow-probe.cc | 22 +++++++++++++--------- src/flow-monitor/model/flow-probe.h | 2 +- src/flow-monitor/model/histogram.cc | 19 +++++++++++-------- src/flow-monitor/model/histogram.h | 2 +- 5 files changed, 32 insertions(+), 29 deletions(-) diff --git a/src/flow-monitor/model/flow-monitor.cc b/src/flow-monitor/model/flow-monitor.cc index 9df581742..9d53eba7b 100644 --- a/src/flow-monitor/model/flow-monitor.cc +++ b/src/flow-monitor/model/flow-monitor.cc @@ -25,8 +25,6 @@ #include #include -#define INDENT(level) for (int __xpto = 0; __xpto < level; __xpto++) os << ' '; - #define PERIODIC_CHECK_INTERVAL (Seconds (1)) namespace ns3 { @@ -35,14 +33,6 @@ NS_LOG_COMPONENT_DEFINE ("FlowMonitor"); NS_OBJECT_ENSURE_REGISTERED (FlowMonitor); - -inline static void -Indent (std::ostream &os, uint16_t level) -{ - for (uint16_t __xpto = 0; __xpto < level; __xpto++) os << ' '; -} - - TypeId FlowMonitor::GetTypeId (void) { @@ -407,6 +397,12 @@ FlowMonitor::AddFlowClassifier (Ptr classifier) m_classifiers.push_back (classifier); } +inline static void +Indent (std::ostream &os, uint16_t level) +{ + for (uint16_t __xpto = 0; __xpto < level; __xpto++) os << ' '; +} + void FlowMonitor::SerializeToXmlStream (std::ostream &os, uint16_t indent, bool enableHistograms, bool enableProbes) { diff --git a/src/flow-monitor/model/flow-probe.cc b/src/flow-monitor/model/flow-probe.cc index 5b0763246..98d81338c 100644 --- a/src/flow-monitor/model/flow-probe.cc +++ b/src/flow-monitor/model/flow-probe.cc @@ -82,18 +82,22 @@ FlowProbe::GetStats () const return m_stats; } -void -FlowProbe::SerializeToXmlStream (std::ostream &os, int indent, uint32_t index) const +inline static void +Indent (std::ostream &os, uint16_t level) { - #define INDENT(level) for (int __xpto = 0; __xpto < level; __xpto++) os << ' '; + for (uint16_t __xpto = 0; __xpto < level; __xpto++) os << ' '; +} - INDENT (indent); os << "\n"; +void +FlowProbe::SerializeToXmlStream (std::ostream &os, uint16_t indent, uint32_t index) const +{ + Indent (os, indent); os << "\n"; indent += 2; for (Stats::const_iterator iter = m_stats.begin (); iter != m_stats.end (); iter++) { - INDENT (indent); + Indent (os, indent); os << "first << "\"" << " packets=\"" << iter->second.packets << "\"" @@ -103,23 +107,23 @@ FlowProbe::SerializeToXmlStream (std::ostream &os, int indent, uint32_t index) c indent += 2; for (uint32_t reasonCode = 0; reasonCode < iter->second.packetsDropped.size (); reasonCode++) { - INDENT (indent); + Indent (os, indent); os << "second.packetsDropped[reasonCode] << "\" />\n"; } for (uint32_t reasonCode = 0; reasonCode < iter->second.bytesDropped.size (); reasonCode++) { - INDENT (indent); + Indent (os, indent); os << "second.bytesDropped[reasonCode] << "\" />\n"; } indent -= 2; - INDENT (indent); os << "\n"; + Indent (os, indent); os << "\n"; } indent -= 2; - INDENT (indent); os << "\n"; + Indent (os, indent); os << "\n"; } diff --git a/src/flow-monitor/model/flow-probe.h b/src/flow-monitor/model/flow-probe.h index 65e3cfd5f..72cc43ef3 100644 --- a/src/flow-monitor/model/flow-probe.h +++ b/src/flow-monitor/model/flow-probe.h @@ -100,7 +100,7 @@ public: /// \param os the output stream /// \param indent number of spaces to use as base indentation level /// \param index FlowProbe index - void SerializeToXmlStream (std::ostream &os, int indent, uint32_t index) const; + void SerializeToXmlStream (std::ostream &os, uint16_t indent, uint32_t index) const; protected: Ptr m_flowMonitor; //!< the FlowMonitor instance diff --git a/src/flow-monitor/model/histogram.cc b/src/flow-monitor/model/histogram.cc index 9cc2d76c1..5ff1b5edb 100644 --- a/src/flow-monitor/model/histogram.cc +++ b/src/flow-monitor/model/histogram.cc @@ -102,12 +102,16 @@ Histogram::Histogram () } -void -Histogram::SerializeToXmlStream (std::ostream &os, int indent, std::string elementName) const +inline static void +Indent (std::ostream &os, uint16_t level) { -#define INDENT(level) for (int __xpto = 0; __xpto < level; __xpto++) os << ' '; + for (uint16_t __xpto = 0; __xpto < level; __xpto++) os << ' '; +} - INDENT (indent); os << "<" << elementName // << " binWidth=\"" << m_binWidth << "\"" +void +Histogram::SerializeToXmlStream (std::ostream &os, uint16_t indent, std::string elementName) const +{ + Indent (os, indent); os << "<" << elementName // << " binWidth=\"" << m_binWidth << "\"" << " nBins=\"" << m_histogram.size () << "\"" << " >\n"; indent += 2; @@ -117,7 +121,7 @@ Histogram::SerializeToXmlStream (std::ostream &os, int indent, std::string eleme { if (m_histogram[index]) { - INDENT (indent); + Indent (os, indent); os << " 0) @@ -139,8 +143,7 @@ Histogram::SerializeToXmlStream (std::ostream &os, int indent, std::string eleme os << "\n"; #endif indent -= 2; - INDENT (indent); os << "\n"; -#undef INDENT + Indent (os, indent); os << "\n"; } diff --git a/src/flow-monitor/model/histogram.h b/src/flow-monitor/model/histogram.h index fe3d57d56..f3f858563 100644 --- a/src/flow-monitor/model/histogram.h +++ b/src/flow-monitor/model/histogram.h @@ -109,7 +109,7 @@ public: * \param indent number of spaces to use as base indentation level * \param elementName name of the element to serialize. */ - void SerializeToXmlStream (std::ostream &os, int indent, std::string elementName) const; + void SerializeToXmlStream (std::ostream &os, uint16_t indent, std::string elementName) const; private: