Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply .clang-tidy linting rules to all files #146

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions examples/adr-example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ main(int argc, char* argv[])
//////////

// End Device mobility
MobilityHelper mobilityEd, mobilityGw;
MobilityHelper mobilityEd;
MobilityHelper mobilityGw;
mobilityEd.SetPositionAllocator(
"ns3::RandomRectanglePositionAllocator",
"X",
Expand Down Expand Up @@ -242,7 +243,7 @@ main(int argc, char* argv[])
// Do not set spreading factors up: we will wait for the NS to do this
if (initializeSF)
{
macHelper.SetSpreadingFactorsUp(endDevices, gateways, channel);
LorawanMacHelper::SetSpreadingFactorsUp(endDevices, gateways, channel);
}

////////////
Expand Down
23 changes: 11 additions & 12 deletions examples/aloha-throughput.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ main(int argc, char* argv[])
mobility.Install(endDevices);

// Make it so that nodes are at a certain height > 0
for (NodeContainer::Iterator j = endDevices.Begin(); j != endDevices.End(); ++j)
for (auto j = endDevices.Begin(); j != endDevices.End(); ++j)
{
Ptr<MobilityModel> mobility = (*j)->GetObject<MobilityModel>();
Vector position = mobility->GetPosition();
Expand All @@ -196,7 +196,7 @@ main(int argc, char* argv[])
// Now end devices are connected to the channel

// Connect trace sources
for (NodeContainer::Iterator j = endDevices.Begin(); j != endDevices.End(); ++j)
for (auto j = endDevices.Begin(); j != endDevices.End(); ++j)
{
Ptr<Node> node = *j;
Ptr<LoraNetDevice> loraNetDevice = node->GetDevice(0)->GetObject<LoraNetDevice>();
Expand Down Expand Up @@ -245,26 +245,25 @@ main(int argc, char* argv[])
{
LoraTxParameters txParams;
txParams.sf = sf;
txParams.headerDisabled = 0;
txParams.headerDisabled = false;
txParams.codingRate = 1;
txParams.bandwidthHz = 125000;
txParams.nPreamble = 8;
txParams.crcEnabled = 1;
txParams.lowDataRateOptimizationEnabled =
LoraPhy::GetTSym(txParams) > MilliSeconds(16) ? true : false;
txParams.crcEnabled = true;
txParams.lowDataRateOptimizationEnabled = LoraPhy::GetTSym(txParams) > MilliSeconds(16);
Ptr<Packet> pkt = Create<Packet>(packetSize);

LoraFrameHeader frameHdr = LoraFrameHeader();
frameHdr.SetAsUplink();
frameHdr.SetFPort(1);
frameHdr.SetAddress(LoraDeviceAddress());
frameHdr.SetAdr(0);
frameHdr.SetAdrAckReq(0);
frameHdr.SetAdr(false);
frameHdr.SetAdrAckReq(false);
frameHdr.SetFCnt(0);
pkt->AddHeader(frameHdr);

LorawanMacHeader macHdr = LorawanMacHeader();
macHdr.SetMType(ns3::lorawan::LorawanMacHeader::UNCONFIRMED_DATA_UP);
macHdr.SetMType(LorawanMacHeader::UNCONFIRMED_DATA_UP);
macHdr.SetMajor(1);
pkt->AddHeader(macHdr);

Expand All @@ -289,22 +288,22 @@ main(int argc, char* argv[])
forHelper.Install(gateways);

// Install trace sources
for (NodeContainer::Iterator node = gateways.Begin(); node != gateways.End(); node++)
for (auto node = gateways.Begin(); node != gateways.End(); node++)
{
(*node)->GetDevice(0)->GetObject<LoraNetDevice>()->GetPhy()->TraceConnectWithoutContext(
"ReceivedPacket",
MakeCallback(OnPacketReceptionCallback));
}

// Install trace sources
for (NodeContainer::Iterator node = endDevices.Begin(); node != endDevices.End(); node++)
for (auto node = endDevices.Begin(); node != endDevices.End(); node++)
{
(*node)->GetDevice(0)->GetObject<LoraNetDevice>()->GetPhy()->TraceConnectWithoutContext(
"StartSending",
MakeCallback(OnTransmissionCallback));
}

macHelper.SetSpreadingFactorsUp(endDevices, gateways, channel);
LorawanMacHelper::SetSpreadingFactorsUp(endDevices, gateways, channel);

////////////////
// Simulation //
Expand Down
8 changes: 4 additions & 4 deletions examples/complete-network-example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ main(int argc, char* argv[])
mobility.Install(endDevices);

// Make it so that nodes are at a certain height > 0
for (NodeContainer::Iterator j = endDevices.Begin(); j != endDevices.End(); ++j)
for (auto j = endDevices.Begin(); j != endDevices.End(); ++j)
{
Ptr<MobilityModel> mobility = (*j)->GetObject<MobilityModel>();
Vector position = mobility->GetPosition();
Expand All @@ -190,7 +190,7 @@ main(int argc, char* argv[])
// Now end devices are connected to the channel

// Connect trace sources
for (NodeContainer::Iterator j = endDevices.Begin(); j != endDevices.End(); ++j)
for (auto j = endDevices.Begin(); j != endDevices.End(); ++j)
{
Ptr<Node> node = *j;
Ptr<LoraNetDevice> loraNetDevice = node->GetDevice(0)->GetObject<LoraNetDevice>();
Expand Down Expand Up @@ -226,7 +226,7 @@ main(int argc, char* argv[])
double deltaY = 17;
int gridWidth = 2 * radius / (xLength + deltaX);
int gridHeight = 2 * radius / (yLength + deltaY);
if (realisticChannelModel == false)
if (!realisticChannelModel)
{
gridWidth = 0;
gridHeight = 0;
Expand Down Expand Up @@ -274,7 +274,7 @@ main(int argc, char* argv[])
* Set up the end device's spreading factor *
**********************************************/

macHelper.SetSpreadingFactorsUp(endDevices, gateways, channel);
LorawanMacHelper::SetSpreadingFactorsUp(endDevices, gateways, channel);

NS_LOG_DEBUG("Completed configuration");

Expand Down
4 changes: 2 additions & 2 deletions examples/frame-counter-update.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ main(int argc, char* argv[])
mobility.Install(endDevices);

// Make it so that nodes are at a certain height > 0
for (NodeContainer::Iterator j = endDevices.Begin(); j != endDevices.End(); ++j)
for (auto j = endDevices.Begin(); j != endDevices.End(); ++j)
{
Ptr<MobilityModel> mobility = (*j)->GetObject<MobilityModel>();
Vector position = mobility->GetPosition();
Expand All @@ -180,7 +180,7 @@ main(int argc, char* argv[])
helper.Install(phyHelper, macHelper, endDevices);

// Connect trace sources
for (NodeContainer::Iterator j = endDevices.Begin(); j != endDevices.End(); ++j)
for (auto j = endDevices.Begin(); j != endDevices.End(); ++j)
{
Ptr<Node> node = *j;
Ptr<LoraNetDevice> loraNetDevice = node->GetDevice(0)->GetObject<LoraNetDevice>();
Expand Down
2 changes: 1 addition & 1 deletion examples/lorawan-energy-model-example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ main(int argc, char* argv[])
macHelper.SetDeviceType(LorawanMacHelper::GW);
helper.Install(phyHelper, macHelper, gateways);

macHelper.SetSpreadingFactorsUp(endDevices, gateways, channel);
LorawanMacHelper::SetSpreadingFactorsUp(endDevices, gateways, channel);

/*********************************************
* Install applications on the end devices *
Expand Down
5 changes: 3 additions & 2 deletions examples/network-server-example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ main(int argc, char* argv[])
//////////

// End Device mobility
MobilityHelper mobilityEd, mobilityGw;
MobilityHelper mobilityEd;
MobilityHelper mobilityGw;
Ptr<ListPositionAllocator> positionAllocEd = CreateObject<ListPositionAllocator>();
positionAllocEd->Add(Vector(6000.0, 0.0, 0.0));
positionAllocEd->Add(Vector(0.0, 100.0, 0.0));
Expand Down Expand Up @@ -153,7 +154,7 @@ main(int argc, char* argv[])
helper.Install(phyHelper, macHelper, gateways);

// Set spreading factors up
macHelper.SetSpreadingFactorsUp(endDevices, gateways, channel);
LorawanMacHelper::SetSpreadingFactorsUp(endDevices, gateways, channel);

////////////
// Create NS
Expand Down
2 changes: 1 addition & 1 deletion examples/simple-network-example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ main(int argc, char* argv[])
* Set Data Rates *
******************/
std::vector<int> sfQuantity(6);
sfQuantity = macHelper.SetSpreadingFactorsUp(endDevices, gateways, channel);
sfQuantity = LorawanMacHelper::SetSpreadingFactorsUp(endDevices, gateways, channel);

/****************
* Simulation *
Expand Down
2 changes: 1 addition & 1 deletion helper/forwarder-helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ ApplicationContainer
ForwarderHelper::Install(NodeContainer c) const
{
ApplicationContainer apps;
for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i)
for (auto i = c.Begin(); i != c.End(); ++i)
{
apps.Add(InstallPriv(*i));
}
Expand Down
12 changes: 6 additions & 6 deletions helper/lora-helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ LoraHelper::Install(const LoraPhyHelper& phyHelper,
NetDeviceContainer devices;

// Go over the various nodes in which to install the NetDevice
for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i)
for (auto i = c.Begin(); i != c.End(); ++i)
{
Ptr<Node> node = *i;

Expand Down Expand Up @@ -151,7 +151,7 @@ LoraHelper::EnablePacketTracking()
}

LoraPacketTracker&
LoraHelper::GetPacketTracker(void)
LoraHelper::GetPacketTracker()
{
NS_LOG_FUNCTION(this);

Expand All @@ -161,7 +161,7 @@ LoraHelper::GetPacketTracker(void)
void
LoraHelper::EnableSimulationTimePrinting(Time interval)
{
m_oldtime = std::time(0);
m_oldtime = std::time(nullptr);
Simulator::Schedule(Seconds(0), &LoraHelper::DoPrintSimulationTime, this, interval);
}

Expand Down Expand Up @@ -204,7 +204,7 @@ LoraHelper::DoPrintDeviceStatus(NodeContainer endDevices,
}

Time currentTime = Simulator::Now();
for (NodeContainer::Iterator j = endDevices.Begin(); j != endDevices.End(); ++j)
for (auto j = endDevices.Begin(); j != endDevices.End(); ++j)
{
Ptr<Node> object = *j;
Ptr<MobilityModel> position = object->GetObject<MobilityModel>();
Expand Down Expand Up @@ -329,9 +329,9 @@ LoraHelper::DoPrintSimulationTime(Time interval)
{
// NS_LOG_INFO ("Time: " << Simulator::Now().GetHours());
std::cout << "Simulated time: " << Simulator::Now().GetHours() << " hours" << std::endl;
std::cout << "Real time from last call: " << std::time(0) - m_oldtime << " seconds"
std::cout << "Real time from last call: " << std::time(nullptr) - m_oldtime << " seconds"
<< std::endl;
m_oldtime = std::time(0);
m_oldtime = std::time(nullptr);
Simulator::Schedule(interval, &LoraHelper::DoPrintSimulationTime, this, interval);
}

Expand Down
6 changes: 3 additions & 3 deletions helper/lora-helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class LoraHelper
* This method automatically connects to trace sources to computes relevant
* metrics.
*/
void EnablePacketTracking(void);
void EnablePacketTracking();

/**
* Periodically prints the simulation time to the standard output.
Expand Down Expand Up @@ -112,9 +112,9 @@ class LoraHelper

void DoPrintGlobalPerformance(std::string filename);

LoraPacketTracker& GetPacketTracker(void);
LoraPacketTracker& GetPacketTracker();

LoraPacketTracker* m_packetTracker = 0;
LoraPacketTracker* m_packetTracker = nullptr;

time_t m_oldtime;

Expand Down
12 changes: 6 additions & 6 deletions helper/lora-packet-tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ LoraPacketTracker::PacketReceptionCallback(Ptr<const Packet> packet, uint32_t gw
// Remove the successfully received packet from the list of sent ones
NS_LOG_INFO("PHY packet " << packet << " was successfully received at gateway " << gwId);

std::map<Ptr<const Packet>, PacketStatus>::iterator it = m_packetTracker.find(packet);
auto it = m_packetTracker.find(packet);
(*it).second.outcomes.insert(std::pair<int, enum PhyPacketOutcome>(gwId, RECEIVED));
}
}
Expand All @@ -144,7 +144,7 @@ LoraPacketTracker::InterferenceCallback(Ptr<const Packet> packet, uint32_t gwId)
{
NS_LOG_INFO("PHY packet " << packet << " was interfered at gateway " << gwId);

std::map<Ptr<const Packet>, PacketStatus>::iterator it = m_packetTracker.find(packet);
auto it = m_packetTracker.find(packet);
(*it).second.outcomes.insert(std::pair<int, enum PhyPacketOutcome>(gwId, INTERFERED));
}
}
Expand All @@ -156,7 +156,7 @@ LoraPacketTracker::NoMoreReceiversCallback(Ptr<const Packet> packet, uint32_t gw
{
NS_LOG_INFO("PHY packet " << packet << " was lost because no more receivers at gateway "
<< gwId);
std::map<Ptr<const Packet>, PacketStatus>::iterator it = m_packetTracker.find(packet);
auto it = m_packetTracker.find(packet);
(*it).second.outcomes.insert(
std::pair<int, enum PhyPacketOutcome>(gwId, NO_MORE_RECEIVERS));
}
Expand All @@ -170,7 +170,7 @@ LoraPacketTracker::UnderSensitivityCallback(Ptr<const Packet> packet, uint32_t g
NS_LOG_INFO("PHY packet " << packet << " was lost because under sensitivity at gateway "
<< gwId);

std::map<Ptr<const Packet>, PacketStatus>::iterator it = m_packetTracker.find(packet);
auto it = m_packetTracker.find(packet);
(*it).second.outcomes.insert(
std::pair<int, enum PhyPacketOutcome>(gwId, UNDER_SENSITIVITY));
}
Expand All @@ -184,7 +184,7 @@ LoraPacketTracker::LostBecauseTxCallback(Ptr<const Packet> packet, uint32_t gwId
NS_LOG_INFO("PHY packet " << packet << " was lost because of GW transmission at gateway "
<< gwId);

std::map<Ptr<const Packet>, PacketStatus>::iterator it = m_packetTracker.find(packet);
auto it = m_packetTracker.find(packet);
(*it).second.outcomes.insert(std::pair<int, enum PhyPacketOutcome>(gwId, LOST_BECAUSE_TX));
}
}
Expand Down Expand Up @@ -330,7 +330,7 @@ LoraPacketTracker::CountMacPacketsGlobally(Time startTime, Time stopTime)
if ((*it).second.sendTime >= startTime && (*it).second.sendTime <= stopTime)
{
sent++;
if ((*it).second.receptionTimes.size())
if (!(*it).second.receptionTimes.empty())
{
received++;
}
Expand Down
2 changes: 1 addition & 1 deletion helper/lora-phy-helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ LoraPhyHelper::SetDeviceType(enum DeviceType dt)
}

TypeId
LoraPhyHelper::GetDeviceType(void) const
LoraPhyHelper::GetDeviceType() const
{
NS_LOG_FUNCTION(this);
return m_phy.GetTypeId();
Expand Down
2 changes: 1 addition & 1 deletion helper/lora-phy-helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class LoraPhyHelper
*/
void SetDeviceType(enum DeviceType dt);

TypeId GetDeviceType(void) const;
TypeId GetDeviceType() const;

/**
* Set an attribute of the underlying PHY object.
Expand Down
8 changes: 4 additions & 4 deletions helper/lora-radio-energy-model-helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,17 @@ LoraRadioEnergyModelHelper::SetTxCurrentModel(std::string name,
Ptr<DeviceEnergyModel>
LoraRadioEnergyModelHelper::DoInstall(Ptr<NetDevice> device, Ptr<EnergySource> source) const
{
NS_ASSERT(device != NULL);
NS_ASSERT(source != NULL);
NS_ASSERT(device);
NS_ASSERT(source);
// check if device is LoraNetDevice
std::string deviceName = device->GetInstanceTypeId().GetName();
if (deviceName.compare("ns3::LoraNetDevice") != 0)
if (deviceName != "ns3::LoraNetDevice")
{
NS_FATAL_ERROR("NetDevice type is not LoraNetDevice!");
}
Ptr<Node> node = device->GetNode();
Ptr<LoraRadioEnergyModel> model = m_radioEnergy.Create()->GetObject<LoraRadioEnergyModel>();
NS_ASSERT(model != NULL);
NS_ASSERT(model);
// set energy source pointer
model->SetEnergySource(source);

Expand Down
7 changes: 4 additions & 3 deletions helper/lora-radio-energy-model-helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ class LoraRadioEnergyModelHelper : public DeviceEnergyModelHelper
/**
* Destroy a RadioEnergy Helper
*/
~LoraRadioEnergyModelHelper();
~LoraRadioEnergyModelHelper() override;

/**
* \param name the name of the attribute to set
* \param v the value of the attribute
*
* Sets an attribute of the underlying PHY object.
*/
void Set(std::string name, const AttributeValue& v);
void Set(std::string name, const AttributeValue& v) override;

/**
* \param name the name of the model to set
Expand Down Expand Up @@ -102,7 +102,8 @@ class LoraRadioEnergyModelHelper : public DeviceEnergyModelHelper
*
* Implements DeviceEnergyModel::Install.
*/
virtual Ptr<DeviceEnergyModel> DoInstall(Ptr<NetDevice> device, Ptr<EnergySource> source) const;
Ptr<DeviceEnergyModel> DoInstall(Ptr<NetDevice> device,
Ptr<EnergySource> source) const override;

private:
ObjectFactory m_radioEnergy; ///< radio energy
Expand Down
Loading
Loading