src: Updating code style to conform (more or less) to ndn-cxx style
Also, adding .clang-format that describes the applied style. Note that
this style requires a slightly customized version of clang-format.
diff --git a/utils/tracers/ndn-app-delay-tracer.cpp b/utils/tracers/ndn-app-delay-tracer.cpp
index 01a5af4..666f945 100644
--- a/utils/tracers/ndn-app-delay-tracer.cpp
+++ b/utils/tracers/ndn-app-delay-tracer.cpp
@@ -37,162 +37,143 @@
#include <fstream>
-NS_LOG_COMPONENT_DEFINE ("ndn.AppDelayTracer");
+NS_LOG_COMPONENT_DEFINE("ndn.AppDelayTracer");
using namespace std;
namespace ns3 {
namespace ndn {
-static std::list< boost::tuple< boost::shared_ptr<std::ostream>, std::list<Ptr<AppDelayTracer> > > > g_tracers;
+static std::list<boost::tuple<boost::shared_ptr<std::ostream>, std::list<Ptr<AppDelayTracer>>>>
+ g_tracers;
template<class T>
static inline void
-NullDeleter (T *ptr)
+NullDeleter(T* ptr)
{
}
void
-AppDelayTracer::Destroy ()
+AppDelayTracer::Destroy()
{
- g_tracers.clear ();
+ g_tracers.clear();
}
void
-AppDelayTracer::InstallAll (const std::string &file)
+AppDelayTracer::InstallAll(const std::string& file)
{
using namespace boost;
using namespace std;
- std::list<Ptr<AppDelayTracer> > tracers;
+ std::list<Ptr<AppDelayTracer>> tracers;
boost::shared_ptr<std::ostream> outputStream;
- if (file != "-")
- {
- boost::shared_ptr<std::ofstream> os (new std::ofstream ());
- os->open (file.c_str (), std::ios_base::out | std::ios_base::trunc);
+ if (file != "-") {
+ boost::shared_ptr<std::ofstream> os(new std::ofstream());
+ os->open(file.c_str(), std::ios_base::out | std::ios_base::trunc);
- if (!os->is_open ())
- {
- NS_LOG_ERROR ("File " << file << " cannot be opened for writing. Tracing disabled");
- return;
- }
-
- outputStream = os;
- }
- else
- {
- outputStream = boost::shared_ptr<std::ostream> (&std::cout, NullDeleter<std::ostream>);
+ if (!os->is_open()) {
+ NS_LOG_ERROR("File " << file << " cannot be opened for writing. Tracing disabled");
+ return;
}
- for (NodeList::Iterator node = NodeList::Begin ();
- node != NodeList::End ();
- node++)
- {
- Ptr<AppDelayTracer> trace = Install (*node, outputStream);
- tracers.push_back (trace);
- }
+ outputStream = os;
+ }
+ else {
+ outputStream = boost::shared_ptr<std::ostream>(&std::cout, NullDeleter<std::ostream>);
+ }
- if (tracers.size () > 0)
- {
- // *m_l3RateTrace << "# "; // not necessary for R's read.table
- tracers.front ()->PrintHeader (*outputStream);
- *outputStream << "\n";
- }
+ for (NodeList::Iterator node = NodeList::Begin(); node != NodeList::End(); node++) {
+ Ptr<AppDelayTracer> trace = Install(*node, outputStream);
+ tracers.push_back(trace);
+ }
- g_tracers.push_back (boost::make_tuple (outputStream, tracers));
+ if (tracers.size() > 0) {
+ // *m_l3RateTrace << "# "; // not necessary for R's read.table
+ tracers.front()->PrintHeader(*outputStream);
+ *outputStream << "\n";
+ }
+
+ g_tracers.push_back(boost::make_tuple(outputStream, tracers));
}
void
-AppDelayTracer::Install (const NodeContainer &nodes, const std::string &file)
+AppDelayTracer::Install(const NodeContainer& nodes, const std::string& file)
{
using namespace boost;
using namespace std;
- std::list<Ptr<AppDelayTracer> > tracers;
+ std::list<Ptr<AppDelayTracer>> tracers;
boost::shared_ptr<std::ostream> outputStream;
- if (file != "-")
- {
- boost::shared_ptr<std::ofstream> os (new std::ofstream ());
- os->open (file.c_str (), std::ios_base::out | std::ios_base::trunc);
+ if (file != "-") {
+ boost::shared_ptr<std::ofstream> os(new std::ofstream());
+ os->open(file.c_str(), std::ios_base::out | std::ios_base::trunc);
- if (!os->is_open ())
- {
- NS_LOG_ERROR ("File " << file << " cannot be opened for writing. Tracing disabled");
- return;
- }
-
- outputStream = os;
- }
- else
- {
- outputStream = boost::shared_ptr<std::ostream> (&std::cout, NullDeleter<std::ostream>);
+ if (!os->is_open()) {
+ NS_LOG_ERROR("File " << file << " cannot be opened for writing. Tracing disabled");
+ return;
}
- for (NodeContainer::Iterator node = nodes.Begin ();
- node != nodes.End ();
- node++)
- {
- Ptr<AppDelayTracer> trace = Install (*node, outputStream);
- tracers.push_back (trace);
- }
+ outputStream = os;
+ }
+ else {
+ outputStream = boost::shared_ptr<std::ostream>(&std::cout, NullDeleter<std::ostream>);
+ }
- if (tracers.size () > 0)
- {
- // *m_l3RateTrace << "# "; // not necessary for R's read.table
- tracers.front ()->PrintHeader (*outputStream);
- *outputStream << "\n";
- }
+ for (NodeContainer::Iterator node = nodes.Begin(); node != nodes.End(); node++) {
+ Ptr<AppDelayTracer> trace = Install(*node, outputStream);
+ tracers.push_back(trace);
+ }
- g_tracers.push_back (boost::make_tuple (outputStream, tracers));
+ if (tracers.size() > 0) {
+ // *m_l3RateTrace << "# "; // not necessary for R's read.table
+ tracers.front()->PrintHeader(*outputStream);
+ *outputStream << "\n";
+ }
+
+ g_tracers.push_back(boost::make_tuple(outputStream, tracers));
}
void
-AppDelayTracer::Install (Ptr<Node> node, const std::string &file)
+AppDelayTracer::Install(Ptr<Node> node, const std::string& file)
{
using namespace boost;
using namespace std;
- std::list<Ptr<AppDelayTracer> > tracers;
+ std::list<Ptr<AppDelayTracer>> tracers;
boost::shared_ptr<std::ostream> outputStream;
- if (file != "-")
- {
- boost::shared_ptr<std::ofstream> os (new std::ofstream ());
- os->open (file.c_str (), std::ios_base::out | std::ios_base::trunc);
+ if (file != "-") {
+ boost::shared_ptr<std::ofstream> os(new std::ofstream());
+ os->open(file.c_str(), std::ios_base::out | std::ios_base::trunc);
- if (!os->is_open ())
- {
- NS_LOG_ERROR ("File " << file << " cannot be opened for writing. Tracing disabled");
- return;
- }
-
- outputStream = os;
- }
- else
- {
- outputStream = boost::shared_ptr<std::ostream> (&std::cout, NullDeleter<std::ostream>);
+ if (!os->is_open()) {
+ NS_LOG_ERROR("File " << file << " cannot be opened for writing. Tracing disabled");
+ return;
}
- Ptr<AppDelayTracer> trace = Install (node, outputStream);
- tracers.push_back (trace);
+ outputStream = os;
+ }
+ else {
+ outputStream = boost::shared_ptr<std::ostream>(&std::cout, NullDeleter<std::ostream>);
+ }
- if (tracers.size () > 0)
- {
- // *m_l3RateTrace << "# "; // not necessary for R's read.table
- tracers.front ()->PrintHeader (*outputStream);
- *outputStream << "\n";
- }
+ Ptr<AppDelayTracer> trace = Install(node, outputStream);
+ tracers.push_back(trace);
- g_tracers.push_back (boost::make_tuple (outputStream, tracers));
+ if (tracers.size() > 0) {
+ // *m_l3RateTrace << "# "; // not necessary for R's read.table
+ tracers.front()->PrintHeader(*outputStream);
+ *outputStream << "\n";
+ }
+
+ g_tracers.push_back(boost::make_tuple(outputStream, tracers));
}
-
Ptr<AppDelayTracer>
-AppDelayTracer::Install (Ptr<Node> node,
- boost::shared_ptr<std::ostream> outputStream)
+AppDelayTracer::Install(Ptr<Node> node, boost::shared_ptr<std::ostream> outputStream)
{
- NS_LOG_DEBUG ("Node: " << node->GetId ());
+ NS_LOG_DEBUG("Node: " << node->GetId());
- Ptr<AppDelayTracer> trace = Create<AppDelayTracer> (outputStream, node);
+ Ptr<AppDelayTracer> trace = Create<AppDelayTracer>(outputStream, node);
return trace;
}
@@ -201,86 +182,86 @@
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
-AppDelayTracer::AppDelayTracer (boost::shared_ptr<std::ostream> os, Ptr<Node> node)
-: m_nodePtr (node)
-, m_os (os)
+AppDelayTracer::AppDelayTracer(boost::shared_ptr<std::ostream> os, Ptr<Node> node)
+ : m_nodePtr(node)
+ , m_os(os)
{
- m_node = boost::lexical_cast<string> (m_nodePtr->GetId ());
+ m_node = boost::lexical_cast<string>(m_nodePtr->GetId());
- Connect ();
+ Connect();
- string name = Names::FindName (node);
- if (!name.empty ())
- {
- m_node = name;
- }
+ string name = Names::FindName(node);
+ if (!name.empty()) {
+ m_node = name;
+ }
}
-AppDelayTracer::AppDelayTracer (boost::shared_ptr<std::ostream> os, const std::string &node)
-: m_node (node)
-, m_os (os)
+AppDelayTracer::AppDelayTracer(boost::shared_ptr<std::ostream> os, const std::string& node)
+ : m_node(node)
+ , m_os(os)
{
- Connect ();
+ Connect();
}
-AppDelayTracer::~AppDelayTracer ()
-{
-};
-
+AppDelayTracer::~AppDelayTracer(){};
void
-AppDelayTracer::Connect ()
+AppDelayTracer::Connect()
{
- Config::ConnectWithoutContext ("/NodeList/"+m_node+"/ApplicationList/*/LastRetransmittedInterestDataDelay",
- MakeCallback (&AppDelayTracer::LastRetransmittedInterestDataDelay, this));
+ Config::ConnectWithoutContext("/NodeList/" + m_node
+ + "/ApplicationList/*/LastRetransmittedInterestDataDelay",
+ MakeCallback(&AppDelayTracer::LastRetransmittedInterestDataDelay,
+ this));
- Config::ConnectWithoutContext ("/NodeList/"+m_node+"/ApplicationList/*/FirstInterestDataDelay",
- MakeCallback (&AppDelayTracer::FirstInterestDataDelay, this));
+ Config::ConnectWithoutContext("/NodeList/" + m_node + "/ApplicationList/*/FirstInterestDataDelay",
+ MakeCallback(&AppDelayTracer::FirstInterestDataDelay, this));
}
void
-AppDelayTracer::PrintHeader (std::ostream &os) const
+AppDelayTracer::PrintHeader(std::ostream& os) const
{
- os << "Time" << "\t"
- << "Node" << "\t"
- << "AppId" << "\t"
- << "SeqNo" << "\t"
+ os << "Time"
+ << "\t"
+ << "Node"
+ << "\t"
+ << "AppId"
+ << "\t"
+ << "SeqNo"
+ << "\t"
- << "Type" << "\t"
- << "DelayS" << "\t"
- << "DelayUS" << "\t"
- << "RetxCount" << "\t"
- << "HopCount" << "";
+ << "Type"
+ << "\t"
+ << "DelayS"
+ << "\t"
+ << "DelayUS"
+ << "\t"
+ << "RetxCount"
+ << "\t"
+ << "HopCount"
+ << "";
}
void
-AppDelayTracer::LastRetransmittedInterestDataDelay (Ptr<App> app, uint32_t seqno, Time delay, int32_t hopCount)
+AppDelayTracer::LastRetransmittedInterestDataDelay(Ptr<App> app, uint32_t seqno, Time delay,
+ int32_t hopCount)
{
- *m_os << Simulator::Now ().ToDouble (Time::S) << "\t"
- << m_node << "\t"
- << app->GetId () << "\t"
+ *m_os << Simulator::Now().ToDouble(Time::S) << "\t" << m_node << "\t" << app->GetId() << "\t"
<< seqno << "\t"
- << "LastDelay" << "\t"
- << delay.ToDouble (Time::S) << "\t"
- << delay.ToDouble (Time::US) << "\t"
- << 1 << "\t"
+ << "LastDelay"
+ << "\t" << delay.ToDouble(Time::S) << "\t" << delay.ToDouble(Time::US) << "\t" << 1 << "\t"
<< hopCount << "\n";
}
void
-AppDelayTracer::FirstInterestDataDelay (Ptr<App> app, uint32_t seqno, Time delay, uint32_t retxCount, int32_t hopCount)
+AppDelayTracer::FirstInterestDataDelay(Ptr<App> app, uint32_t seqno, Time delay, uint32_t retxCount,
+ int32_t hopCount)
{
- *m_os << Simulator::Now ().ToDouble (Time::S) << "\t"
- << m_node << "\t"
- << app->GetId () << "\t"
+ *m_os << Simulator::Now().ToDouble(Time::S) << "\t" << m_node << "\t" << app->GetId() << "\t"
<< seqno << "\t"
- << "FullDelay" << "\t"
- << delay.ToDouble (Time::S) << "\t"
- << delay.ToDouble (Time::US) << "\t"
- << retxCount << "\t"
- << hopCount << "\n";
+ << "FullDelay"
+ << "\t" << delay.ToDouble(Time::S) << "\t" << delay.ToDouble(Time::US) << "\t" << retxCount
+ << "\t" << hopCount << "\n";
}
-
} // namespace ndn
} // namespace ns3