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