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/model/ndn-net-device-face.cpp b/model/ndn-net-device-face.cpp
index af4baa0..31d57fc 100644
--- a/model/ndn-net-device-face.cpp
+++ b/model/ndn-net-device-face.cpp
@@ -33,20 +33,17 @@
#include "ns3/channel.h"
#include "ns3/ndn-name.hpp"
-NS_LOG_COMPONENT_DEFINE ("ndn.NetDeviceFace");
+NS_LOG_COMPONENT_DEFINE("ndn.NetDeviceFace");
namespace ns3 {
namespace ndn {
-NS_OBJECT_ENSURE_REGISTERED (NetDeviceFace);
+NS_OBJECT_ENSURE_REGISTERED(NetDeviceFace);
TypeId
-NetDeviceFace::GetTypeId ()
+NetDeviceFace::GetTypeId()
{
- static TypeId tid = TypeId ("ns3::ndn::NetDeviceFace")
- .SetParent<Face> ()
- .SetGroupName ("Ndn")
- ;
+ static TypeId tid = TypeId("ns3::ndn::NetDeviceFace").SetParent<Face>().SetGroupName("Ndn");
return tid;
}
@@ -54,20 +51,20 @@
* By default, Ndn face are created in the "down" state. Before
* becoming useable, the user must invoke SetUp on the face
*/
-NetDeviceFace::NetDeviceFace (Ptr<Node> node, const Ptr<NetDevice> &netDevice)
- : Face (node)
- , m_netDevice (netDevice)
+NetDeviceFace::NetDeviceFace(Ptr<Node> node, const Ptr<NetDevice>& netDevice)
+ : Face(node)
+ , m_netDevice(netDevice)
{
- NS_LOG_FUNCTION (this << netDevice);
+ NS_LOG_FUNCTION(this << netDevice);
- SetMetric (1); // default metric
+ SetMetric(1); // default metric
- NS_ASSERT_MSG (m_netDevice != 0, "NetDeviceFace needs to be assigned a valid NetDevice");
+ NS_ASSERT_MSG(m_netDevice != 0, "NetDeviceFace needs to be assigned a valid NetDevice");
}
-NetDeviceFace::~NetDeviceFace ()
+NetDeviceFace::~NetDeviceFace()
{
- NS_LOG_FUNCTION_NOARGS ();
+ NS_LOG_FUNCTION_NOARGS();
}
NetDeviceFace& NetDeviceFace::operator= (const NetDeviceFace &)
@@ -76,84 +73,85 @@
}
Ptr<NetDevice>
-NetDeviceFace::GetNetDevice () const
+NetDeviceFace::GetNetDevice() const
{
return m_netDevice;
}
void
-NetDeviceFace::RegisterProtocolHandlers (const InterestHandler &interestHandler, const DataHandler &dataHandler)
+NetDeviceFace::RegisterProtocolHandlers(const InterestHandler& interestHandler,
+ const DataHandler& dataHandler)
{
- NS_LOG_FUNCTION (this);
+ NS_LOG_FUNCTION(this);
- Face::RegisterProtocolHandlers (interestHandler, dataHandler);
+ Face::RegisterProtocolHandlers(interestHandler, dataHandler);
- m_node->RegisterProtocolHandler (MakeCallback (&NetDeviceFace::ReceiveFromNetDevice, this),
- L3Protocol::ETHERNET_FRAME_TYPE, m_netDevice, true/*promiscuous mode*/);
+ m_node->RegisterProtocolHandler(MakeCallback(&NetDeviceFace::ReceiveFromNetDevice, this),
+ L3Protocol::ETHERNET_FRAME_TYPE, m_netDevice,
+ true /*promiscuous mode*/);
}
void
-NetDeviceFace:: UnRegisterProtocolHandlers ()
+NetDeviceFace::UnRegisterProtocolHandlers()
{
- m_node->UnregisterProtocolHandler (MakeCallback (&NetDeviceFace::ReceiveFromNetDevice, this));
- Face::UnRegisterProtocolHandlers ();
+ m_node->UnregisterProtocolHandler(MakeCallback(&NetDeviceFace::ReceiveFromNetDevice, this));
+ Face::UnRegisterProtocolHandlers();
}
bool
-NetDeviceFace::Send (Ptr<Packet> packet)
+NetDeviceFace::Send(Ptr<Packet> packet)
{
- if (!Face::Send (packet))
- {
- return false;
- }
-
- NS_LOG_FUNCTION (this << packet);
+ if (!Face::Send(packet)) {
+ return false;
+ }
- NS_ASSERT_MSG (packet->GetSize () <= m_netDevice->GetMtu (),
- "Packet size " << packet->GetSize () << " exceeds device MTU "
- << m_netDevice->GetMtu ()
- << " for Ndn; fragmentation not supported");
+ NS_LOG_FUNCTION(this << packet);
- bool ok = m_netDevice->Send (packet, m_netDevice->GetBroadcast (),
- L3Protocol::ETHERNET_FRAME_TYPE);
+ NS_ASSERT_MSG(packet->GetSize() <= m_netDevice->GetMtu(),
+ "Packet size " << packet->GetSize() << " exceeds device MTU "
+ << m_netDevice->GetMtu() << " for Ndn; fragmentation not supported");
+
+ bool ok = m_netDevice->Send(packet, m_netDevice->GetBroadcast(), L3Protocol::ETHERNET_FRAME_TYPE);
return ok;
}
// callback
void
-NetDeviceFace::ReceiveFromNetDevice (Ptr<NetDevice> device,
- Ptr<const Packet> p,
- uint16_t protocol,
- const Address &from,
- const Address &to,
- NetDevice::PacketType packetType)
+NetDeviceFace::ReceiveFromNetDevice(Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol,
+ const Address& from, const Address& to,
+ NetDevice::PacketType packetType)
{
- NS_LOG_FUNCTION (device << p << protocol << from << to << packetType);
- Receive (p);
+ NS_LOG_FUNCTION(device << p << protocol << from << to << packetType);
+ Receive(p);
}
-
std::ostream&
-NetDeviceFace::Print (std::ostream& os) const
+NetDeviceFace::Print(std::ostream& os) const
{
#ifdef NS3_LOG_ENABLE
- os << "dev[" << GetNode ()->GetId () << "]=net(" << GetId ();
+ os << "dev[" << GetNode()->GetId() << "]=net(" << GetId();
- if (DynamicCast<PointToPointNetDevice> (m_netDevice))
- {
- // extra debugging information which available ONLY for PointToPointNetDevice's
- os << ",";
- os << DynamicCast<PointToPointNetDevice> (m_netDevice)->GetChannel ()->GetDevice (0)->GetNode ()->GetId ();
- os << "-";
- os << DynamicCast<PointToPointNetDevice> (m_netDevice)->GetChannel ()->GetDevice (1)->GetNode ()->GetId ();
- }
+ if (DynamicCast<PointToPointNetDevice>(m_netDevice)) {
+ // extra debugging information which available ONLY for PointToPointNetDevice's
+ os << ",";
+ os << DynamicCast<PointToPointNetDevice>(m_netDevice)
+ ->GetChannel()
+ ->GetDevice(0)
+ ->GetNode()
+ ->GetId();
+ os << "-";
+ os << DynamicCast<PointToPointNetDevice>(m_netDevice)
+ ->GetChannel()
+ ->GetDevice(1)
+ ->GetNode()
+ ->GetId();
+ }
os << ")";
#else
- os << "dev=net(" << GetId () << ")";
+ os << "dev=net(" << GetId() << ")";
#endif
return os;
}
} // namespace ndnsim
} // namespace ns3
-