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/examples/custom-apps/custom-app.cpp b/examples/custom-apps/custom-app.cpp
index 71ca87e..001c440 100644
--- a/examples/custom-apps/custom-app.cpp
+++ b/examples/custom-apps/custom-app.cpp
@@ -33,112 +33,110 @@
#include "ns3/ndn-fib.hpp"
#include "ns3/random-variable.h"
-NS_LOG_COMPONENT_DEFINE ("CustomApp");
+NS_LOG_COMPONENT_DEFINE("CustomApp");
namespace ns3 {
-NS_OBJECT_ENSURE_REGISTERED (CustomApp);
+NS_OBJECT_ENSURE_REGISTERED(CustomApp);
// register NS-3 type
TypeId
-CustomApp::GetTypeId ()
+CustomApp::GetTypeId()
{
- static TypeId tid = TypeId ("CustomApp")
- .SetParent<ndn::App> ()
- .AddConstructor<CustomApp> ()
- ;
+ static TypeId tid = TypeId("CustomApp").SetParent<ndn::App>().AddConstructor<CustomApp>();
return tid;
}
// Processing upon start of the application
void
-CustomApp::StartApplication ()
+CustomApp::StartApplication()
{
// initialize ndn::App
- ndn::App::StartApplication ();
+ ndn::App::StartApplication();
// Create a name components object for name ``/prefix/sub``
- Ptr<ndn::Name> prefix = Create<ndn::Name> (); // now prefix contains ``/``
- prefix->append ("prefix"); // now prefix contains ``/prefix``
- prefix->append ("sub"); // now prefix contains ``/prefix/sub``
+ Ptr<ndn::Name> prefix = Create<ndn::Name>(); // now prefix contains ``/``
+ prefix->append("prefix"); // now prefix contains ``/prefix``
+ prefix->append("sub"); // now prefix contains ``/prefix/sub``
/////////////////////////////////////////////////////////////////////////////
// Creating FIB entry that ensures that we will receive incoming Interests //
/////////////////////////////////////////////////////////////////////////////
// Get FIB object
- Ptr<ndn::Fib> fib = GetNode ()->GetObject<ndn::Fib> ();
+ Ptr<ndn::Fib> fib = GetNode()->GetObject<ndn::Fib>();
// Add entry to FIB
// Note that ``m_face`` is cretaed by ndn::App
- Ptr<ndn::fib::Entry> fibEntry = fib->Add (*prefix, m_face, 0);
+ Ptr<ndn::fib::Entry> fibEntry = fib->Add(*prefix, m_face, 0);
- Simulator::Schedule (Seconds (1.0), &CustomApp::SendInterest, this);
+ Simulator::Schedule(Seconds(1.0), &CustomApp::SendInterest, this);
}
// Processing when application is stopped
void
-CustomApp::StopApplication ()
+CustomApp::StopApplication()
{
// cleanup ndn::App
- ndn::App::StopApplication ();
+ ndn::App::StopApplication();
}
void
-CustomApp::SendInterest ()
+CustomApp::SendInterest()
{
/////////////////////////////////////
// Sending one Interest packet out //
/////////////////////////////////////
-
- Ptr<ndn::Name> prefix = Create<ndn::Name> ("/prefix/sub"); // another way to create name
+
+ Ptr<ndn::Name> prefix = Create<ndn::Name>("/prefix/sub"); // another way to create name
// Create and configure ndn::Interest
- Ptr<ndn::Interest> interest = Create<ndn::Interest> ();
- UniformVariable rand (0,std::numeric_limits<uint32_t>::max ());
- interest->SetNonce (rand.GetValue ());
- interest->SetName (prefix);
- interest->SetInterestLifetime (Seconds (1.0));
+ Ptr<ndn::Interest> interest = Create<ndn::Interest>();
+ UniformVariable rand(0, std::numeric_limits<uint32_t>::max());
+ interest->SetNonce(rand.GetValue());
+ interest->SetName(prefix);
+ interest->SetInterestLifetime(Seconds(1.0));
- NS_LOG_DEBUG ("Sending Interest packet for " << *prefix);
-
+ NS_LOG_DEBUG("Sending Interest packet for " << *prefix);
+
// Call trace (for logging purposes)
- m_transmittedInterests (interest, this, m_face);
+ m_transmittedInterests(interest, this, m_face);
- m_face->ReceiveInterest (interest);
+ m_face->ReceiveInterest(interest);
}
// Callback that will be called when Interest arrives
void
-CustomApp::OnInterest (Ptr<const ndn::Interest> interest)
+CustomApp::OnInterest(Ptr<const ndn::Interest> interest)
{
- ndn::App::OnInterest (interest);
-
- NS_LOG_DEBUG ("Received Interest packet for " << interest->GetName ());
+ ndn::App::OnInterest(interest);
+
+ NS_LOG_DEBUG("Received Interest packet for " << interest->GetName());
// Create and configure ndn::Data and ndn::DataTail
// (header is added in front of the packet, tail is added at the end of the packet)
// Note that Interests send out by the app will not be sent back to the app !
-
- Ptr<ndn::Data> data = Create<ndn::Data> (Create<Packet> (1024));
- data->SetName (Create<ndn::Name> (interest->GetName ())); // data will have the same name as Interests
- NS_LOG_DEBUG ("Sending Data packet for " << data->GetName ());
+ Ptr<ndn::Data> data = Create<ndn::Data>(Create<Packet>(1024));
+ data->SetName(
+ Create<ndn::Name>(interest->GetName())); // data will have the same name as Interests
+
+ NS_LOG_DEBUG("Sending Data packet for " << data->GetName());
// Call trace (for logging purposes)
- m_transmittedDatas (data, this, m_face);
+ m_transmittedDatas(data, this, m_face);
- m_face->ReceiveData (data);
+ m_face->ReceiveData(data);
}
// Callback that will be called when Data arrives
void
-CustomApp::OnData (Ptr<const ndn::Data> contentObject)
+CustomApp::OnData(Ptr<const ndn::Data> contentObject)
{
- NS_LOG_DEBUG ("Receiving Data packet for " << contentObject->GetName ());
+ NS_LOG_DEBUG("Receiving Data packet for " << contentObject->GetName());
- std::cout << "DATA received for name " << contentObject->GetName () << std::endl;
+ std::cout << "DATA received for name " << contentObject->GetName() << std::endl;
}
} // namespace ns3
diff --git a/examples/custom-apps/custom-app.hpp b/examples/custom-apps/custom-app.hpp
index 86f7bb4..5d05e99 100644
--- a/examples/custom-apps/custom-app.hpp
+++ b/examples/custom-apps/custom-app.hpp
@@ -37,32 +37,31 @@
*
* When an Interest is received, it is replied with a Data with 1024-byte fake payload
*/
-class CustomApp : public ndn::App
-{
+class CustomApp : public ndn::App {
public:
// register NS-3 type "CustomApp"
static TypeId
- GetTypeId ();
-
+ GetTypeId();
+
// (overridden from ndn::App) Processing upon start of the application
virtual void
- StartApplication ();
+ StartApplication();
// (overridden from ndn::App) Processing when application is stopped
virtual void
- StopApplication ();
+ StopApplication();
// (overridden from ndn::App) Callback that will be called when Interest arrives
virtual void
- OnInterest (Ptr<const ndn::Interest> interest);
+ OnInterest(Ptr<const ndn::Interest> interest);
// (overridden from ndn::App) Callback that will be called when Data arrives
virtual void
- OnData (Ptr<const ndn::Data> contentObject);
+ OnData(Ptr<const ndn::Data> contentObject);
private:
void
- SendInterest ();
+ SendInterest();
};
} // namespace ns3
diff --git a/examples/custom-apps/dumb-requester.cpp b/examples/custom-apps/dumb-requester.cpp
index eca1cf2..f81548f 100644
--- a/examples/custom-apps/dumb-requester.cpp
+++ b/examples/custom-apps/dumb-requester.cpp
@@ -32,88 +32,85 @@
#include "ns3/ndn-interest.hpp"
#include "ns3/ndn-data.hpp"
-NS_LOG_COMPONENT_DEFINE ("DumbRequester");
+NS_LOG_COMPONENT_DEFINE("DumbRequester");
namespace ns3 {
-NS_OBJECT_ENSURE_REGISTERED (DumbRequester);
+NS_OBJECT_ENSURE_REGISTERED(DumbRequester);
// register NS-3 type
TypeId
-DumbRequester::GetTypeId ()
+DumbRequester::GetTypeId()
{
- static TypeId tid = TypeId ("DumbRequester")
- .SetParent<ndn::App> ()
- .AddConstructor<DumbRequester> ()
+ static TypeId tid =
+ TypeId("DumbRequester")
+ .SetParent<ndn::App>()
+ .AddConstructor<DumbRequester>()
- .AddAttribute ("Prefix", "Requested name",
- StringValue ("/dumb-interest"),
- ndn::MakeNameAccessor (&DumbRequester::m_name),
- ndn::MakeNameChecker ())
- ;
+ .AddAttribute("Prefix", "Requested name", StringValue("/dumb-interest"),
+ ndn::MakeNameAccessor(&DumbRequester::m_name), ndn::MakeNameChecker());
return tid;
}
-DumbRequester::DumbRequester ()
- : m_isRunning (false)
+DumbRequester::DumbRequester()
+ : m_isRunning(false)
{
}
// Processing upon start of the application
void
-DumbRequester::StartApplication ()
+DumbRequester::StartApplication()
{
// initialize ndn::App
- ndn::App::StartApplication ();
+ ndn::App::StartApplication();
m_isRunning = true;
- Simulator::ScheduleNow (&DumbRequester::SendInterest, this);
+ Simulator::ScheduleNow(&DumbRequester::SendInterest, this);
}
// Processing when application is stopped
void
-DumbRequester::StopApplication ()
+DumbRequester::StopApplication()
{
m_isRunning = false;
// cleanup ndn::App
- ndn::App::StopApplication ();
+ ndn::App::StopApplication();
}
void
-DumbRequester::SendInterest ()
+DumbRequester::SendInterest()
{
- if (!m_isRunning) return;
-
+ if (!m_isRunning)
+ return;
+
/////////////////////////////////////
// Sending one Interest packet out //
/////////////////////////////////////
-
- Ptr<ndn::Name> prefix = Create<ndn::Name> (m_name); // another way to create name
+
+ Ptr<ndn::Name> prefix = Create<ndn::Name>(m_name); // another way to create name
// Create and configure ndn::Interest
- Ptr<ndn::Interest> interest = Create<ndn::Interest> ();
- UniformVariable rand (0,std::numeric_limits<uint32_t>::max ());
- interest->SetNonce (rand.GetValue ());
- interest->SetName (prefix);
- interest->SetInterestLifetime (Seconds (1.0));
+ Ptr<ndn::Interest> interest = Create<ndn::Interest>();
+ UniformVariable rand(0, std::numeric_limits<uint32_t>::max());
+ interest->SetNonce(rand.GetValue());
+ interest->SetName(prefix);
+ interest->SetInterestLifetime(Seconds(1.0));
- NS_LOG_DEBUG ("Sending Interest packet for " << *prefix);
-
+ NS_LOG_DEBUG("Sending Interest packet for " << *prefix);
// Call trace (for logging purposes)
- m_transmittedInterests (interest, this, m_face);
+ m_transmittedInterests(interest, this, m_face);
// Forward packet to lower (network) layer
- m_face->ReceiveInterest (interest);
+ m_face->ReceiveInterest(interest);
- Simulator::Schedule (Seconds (1.0), &DumbRequester::SendInterest, this);
+ Simulator::Schedule(Seconds(1.0), &DumbRequester::SendInterest, this);
}
void
-DumbRequester::OnData (Ptr<const ndn::Data> contentObject)
+DumbRequester::OnData(Ptr<const ndn::Data> contentObject)
{
- NS_LOG_DEBUG ("Receiving Data packet for " << contentObject->GetName ());
+ NS_LOG_DEBUG("Receiving Data packet for " << contentObject->GetName());
}
-
} // namespace ns3
diff --git a/examples/custom-apps/dumb-requester.hpp b/examples/custom-apps/dumb-requester.hpp
index 7a1272d..55bdace 100644
--- a/examples/custom-apps/dumb-requester.hpp
+++ b/examples/custom-apps/dumb-requester.hpp
@@ -31,32 +31,31 @@
/**
* @brief A dumb requester application
*
- * This app keeps requesting every second the same content object
+ * This app keeps requesting every second the same content object
*/
-class DumbRequester : public ndn::App
-{
+class DumbRequester : public ndn::App {
public:
// register NS-3 type "DumbRequester"
static TypeId
- GetTypeId ();
+ GetTypeId();
- DumbRequester ();
-
+ DumbRequester();
+
// (overridden from ndn::App) Processing upon start of the application
virtual void
- StartApplication ();
+ StartApplication();
// (overridden from ndn::App) Processing when application is stopped
virtual void
- StopApplication ();
+ StopApplication();
// (overridden from ndn::App) Callback that will be called when Data arrives
virtual void
- OnData (Ptr<const ndn::Data> contentObject);
-
+ OnData(Ptr<const ndn::Data> contentObject);
+
private:
void
- SendInterest ();
+ SendInterest();
private:
bool m_isRunning;
diff --git a/examples/custom-apps/hijacker.cpp b/examples/custom-apps/hijacker.cpp
index f1852d4..bcff26a 100644
--- a/examples/custom-apps/hijacker.cpp
+++ b/examples/custom-apps/hijacker.cpp
@@ -23,53 +23,49 @@
#include "hijacker.hpp"
#include "ns3/ndn-name.hpp"
-NS_LOG_COMPONENT_DEFINE ("Hijacker");
+NS_LOG_COMPONENT_DEFINE("Hijacker");
namespace ns3 {
// Necessary if you are planning to use ndn::AppHelper
-NS_OBJECT_ENSURE_REGISTERED (Hijacker);
+NS_OBJECT_ENSURE_REGISTERED(Hijacker);
TypeId
-Hijacker::GetTypeId ()
+Hijacker::GetTypeId()
{
- static TypeId tid = TypeId ("Hijacker")
- .SetParent<ndn::App> ()
- .AddConstructor<Hijacker> ()
- ;
+ static TypeId tid = TypeId("Hijacker").SetParent<ndn::App>().AddConstructor<Hijacker>();
return tid;
}
-Hijacker::Hijacker ()
+Hijacker::Hijacker()
{
}
void
-Hijacker::OnInterest (Ptr<const ndn::Interest> interest)
+Hijacker::OnInterest(Ptr<const ndn::Interest> interest)
{
- ndn::App::OnInterest (interest); // forward call to perform app-level tracing
+ ndn::App::OnInterest(interest); // forward call to perform app-level tracing
// do nothing else (hijack interest)
- NS_LOG_DEBUG ("Do nothing for incoming interest for" << interest->GetName ());
+ NS_LOG_DEBUG("Do nothing for incoming interest for" << interest->GetName());
}
void
-Hijacker::StartApplication ()
+Hijacker::StartApplication()
{
- App::StartApplication ();
+ App::StartApplication();
// equivalent to setting interest filter for "/" prefix
- Ptr<ndn::Fib> fib = GetNode ()->GetObject<ndn::Fib> ();
- Ptr<ndn::fib::Entry> fibEntry = fib->Add (ndn::Name ("/"), m_face, 0);
- fibEntry->UpdateStatus (m_face, ndn::fib::FaceMetric::NDN_FIB_GREEN);
+ Ptr<ndn::Fib> fib = GetNode()->GetObject<ndn::Fib>();
+ Ptr<ndn::fib::Entry> fibEntry = fib->Add(ndn::Name("/"), m_face, 0);
+ fibEntry->UpdateStatus(m_face, ndn::fib::FaceMetric::NDN_FIB_GREEN);
}
void
-Hijacker::StopApplication ()
+Hijacker::StopApplication()
{
- App::StopApplication ();
+ App::StopApplication();
}
} // namespace ns3
-
diff --git a/examples/custom-apps/hijacker.hpp b/examples/custom-apps/hijacker.hpp
index a90166d..a794f12 100644
--- a/examples/custom-apps/hijacker.hpp
+++ b/examples/custom-apps/hijacker.hpp
@@ -29,25 +29,24 @@
namespace ns3 {
-class Hijacker : public ndn::App
-{
+class Hijacker : public ndn::App {
public:
static TypeId
- GetTypeId ();
+ GetTypeId();
- Hijacker ();
+ Hijacker();
// Receive all Interests but do nothing in response
void
- OnInterest (Ptr<const ndn::Interest> interest);
+ OnInterest(Ptr<const ndn::Interest> interest);
protected:
// inherited from Application base class.
virtual void
- StartApplication ();
+ StartApplication();
virtual void
- StopApplication ();
+ StopApplication();
};
} // namespace ns3