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/helper/ndn-link-control-helper.cpp b/helper/ndn-link-control-helper.cpp
index 1c43666..524ba46 100644
--- a/helper/ndn-link-control-helper.cpp
+++ b/helper/ndn-link-control-helper.cpp
@@ -31,109 +31,110 @@
#include "ns3/ndn-l3-protocol.hpp"
#include "ns3/ndn-net-device-face.hpp"
-NS_LOG_COMPONENT_DEFINE ("ndn.LinkControlHelper");
+NS_LOG_COMPONENT_DEFINE("ndn.LinkControlHelper");
namespace ns3 {
namespace ndn {
void
-LinkControlHelper::FailLink (Ptr<Node> node1, Ptr<Node> node2)
+LinkControlHelper::FailLink(Ptr<Node> node1, Ptr<Node> node2)
{
- NS_LOG_FUNCTION (node1 << node2);
-
- NS_ASSERT (node1 != 0);
- NS_ASSERT (node2 != 0);
-
- Ptr<ndn::L3Protocol> ndn1 = node1->GetObject<ndn::L3Protocol> ();
- Ptr<ndn::L3Protocol> ndn2 = node2->GetObject<ndn::L3Protocol> ();
+ NS_LOG_FUNCTION(node1 << node2);
- NS_ASSERT (ndn1 != 0);
- NS_ASSERT (ndn2 != 0);
+ NS_ASSERT(node1 != 0);
+ NS_ASSERT(node2 != 0);
+
+ Ptr<ndn::L3Protocol> ndn1 = node1->GetObject<ndn::L3Protocol>();
+ Ptr<ndn::L3Protocol> ndn2 = node2->GetObject<ndn::L3Protocol>();
+
+ NS_ASSERT(ndn1 != 0);
+ NS_ASSERT(ndn2 != 0);
// iterate over all faces to find the right one
- for (uint32_t faceId = 0; faceId < ndn1->GetNFaces (); faceId++)
- {
- Ptr<ndn::NetDeviceFace> ndFace = ndn1->GetFace (faceId)->GetObject<ndn::NetDeviceFace> ();
- if (ndFace == 0) continue;
+ for (uint32_t faceId = 0; faceId < ndn1->GetNFaces(); faceId++) {
+ Ptr<ndn::NetDeviceFace> ndFace = ndn1->GetFace(faceId)->GetObject<ndn::NetDeviceFace>();
+ if (ndFace == 0)
+ continue;
- Ptr<PointToPointNetDevice> nd1 = ndFace->GetNetDevice ()->GetObject<PointToPointNetDevice> ();
- if (nd1 == 0) continue;
+ Ptr<PointToPointNetDevice> nd1 = ndFace->GetNetDevice()->GetObject<PointToPointNetDevice>();
+ if (nd1 == 0)
+ continue;
- Ptr<Channel> channel = nd1->GetChannel ();
- if (channel == 0) continue;
+ Ptr<Channel> channel = nd1->GetChannel();
+ if (channel == 0)
+ continue;
- Ptr<PointToPointChannel> ppChannel = DynamicCast<PointToPointChannel> (channel);
+ Ptr<PointToPointChannel> ppChannel = DynamicCast<PointToPointChannel>(channel);
- Ptr<NetDevice> nd2 = ppChannel->GetDevice (0);
- if (nd2->GetNode () == node1)
- nd2 = ppChannel->GetDevice (1);
+ Ptr<NetDevice> nd2 = ppChannel->GetDevice(0);
+ if (nd2->GetNode() == node1)
+ nd2 = ppChannel->GetDevice(1);
- if (nd2->GetNode () == node2)
- {
- Ptr<ndn::Face> face1 = ndn1->GetFaceByNetDevice (nd1);
- Ptr<ndn::Face> face2 = ndn2->GetFaceByNetDevice (nd2);
+ if (nd2->GetNode() == node2) {
+ Ptr<ndn::Face> face1 = ndn1->GetFaceByNetDevice(nd1);
+ Ptr<ndn::Face> face2 = ndn2->GetFaceByNetDevice(nd2);
- face1->SetUp (false);
- face2->SetUp (false);
- break;
- }
+ face1->SetUp(false);
+ face2->SetUp(false);
+ break;
}
+ }
}
void
-LinkControlHelper::FailLinkByName (const std::string &node1, const std::string &node2)
+LinkControlHelper::FailLinkByName(const std::string& node1, const std::string& node2)
{
- FailLink (Names::Find<Node> (node1), Names::Find<Node> (node2));
+ FailLink(Names::Find<Node>(node1), Names::Find<Node>(node2));
}
void
-LinkControlHelper::UpLink (Ptr<Node> node1, Ptr<Node> node2)
+LinkControlHelper::UpLink(Ptr<Node> node1, Ptr<Node> node2)
{
- NS_LOG_FUNCTION (node1 << node2);
+ NS_LOG_FUNCTION(node1 << node2);
- NS_ASSERT (node1 != 0);
- NS_ASSERT (node2 != 0);
-
- Ptr<ndn::L3Protocol> ndn1 = node1->GetObject<ndn::L3Protocol> ();
- Ptr<ndn::L3Protocol> ndn2 = node2->GetObject<ndn::L3Protocol> ();
+ NS_ASSERT(node1 != 0);
+ NS_ASSERT(node2 != 0);
- NS_ASSERT (ndn1 != 0);
- NS_ASSERT (ndn2 != 0);
+ Ptr<ndn::L3Protocol> ndn1 = node1->GetObject<ndn::L3Protocol>();
+ Ptr<ndn::L3Protocol> ndn2 = node2->GetObject<ndn::L3Protocol>();
+
+ NS_ASSERT(ndn1 != 0);
+ NS_ASSERT(ndn2 != 0);
// iterate over all faces to find the right one
- for (uint32_t faceId = 0; faceId < ndn1->GetNFaces (); faceId++)
- {
- Ptr<ndn::NetDeviceFace> ndFace = ndn1->GetFace (faceId)->GetObject<ndn::NetDeviceFace> ();
- if (ndFace == 0) continue;
+ for (uint32_t faceId = 0; faceId < ndn1->GetNFaces(); faceId++) {
+ Ptr<ndn::NetDeviceFace> ndFace = ndn1->GetFace(faceId)->GetObject<ndn::NetDeviceFace>();
+ if (ndFace == 0)
+ continue;
- Ptr<PointToPointNetDevice> nd1 = ndFace->GetNetDevice ()->GetObject<PointToPointNetDevice> ();
- if (nd1 == 0) continue;
+ Ptr<PointToPointNetDevice> nd1 = ndFace->GetNetDevice()->GetObject<PointToPointNetDevice>();
+ if (nd1 == 0)
+ continue;
- Ptr<Channel> channel = nd1->GetChannel ();
- if (channel == 0) continue;
+ Ptr<Channel> channel = nd1->GetChannel();
+ if (channel == 0)
+ continue;
- Ptr<PointToPointChannel> ppChannel = DynamicCast<PointToPointChannel> (channel);
+ Ptr<PointToPointChannel> ppChannel = DynamicCast<PointToPointChannel>(channel);
- Ptr<NetDevice> nd2 = ppChannel->GetDevice (0);
- if (nd2->GetNode () == node1)
- nd2 = ppChannel->GetDevice (1);
+ Ptr<NetDevice> nd2 = ppChannel->GetDevice(0);
+ if (nd2->GetNode() == node1)
+ nd2 = ppChannel->GetDevice(1);
- if (nd2->GetNode () == node2)
- {
- Ptr<ndn::Face> face1 = ndn1->GetFaceByNetDevice (nd1);
- Ptr<ndn::Face> face2 = ndn2->GetFaceByNetDevice (nd2);
+ if (nd2->GetNode() == node2) {
+ Ptr<ndn::Face> face1 = ndn1->GetFaceByNetDevice(nd1);
+ Ptr<ndn::Face> face2 = ndn2->GetFaceByNetDevice(nd2);
- face1->SetUp (true);
- face2->SetUp (true);
- break;
- }
+ face1->SetUp(true);
+ face2->SetUp(true);
+ break;
}
+ }
}
void
-LinkControlHelper::UpLinkByName (const std::string &node1, const std::string &node2)
+LinkControlHelper::UpLinkByName(const std::string& node1, const std::string& node2)
{
- UpLink (Names::Find<Node> (node1), Names::Find<Node> (node2));
+ UpLink(Names::Find<Node>(node1), Names::Find<Node>(node2));
}
-
}
}