network: Add NodeContainer::Contains()

This commit is contained in:
Tom Henderson
2018-08-09 05:53:06 -07:00
parent 55df7237fe
commit a04ea625f7
4 changed files with 25 additions and 0 deletions

View File

@@ -64,6 +64,8 @@ nodes to be placed outside of buildings defined in the scenario.</li>
<li> Added a priority queue disc (PrioQueueDisc).</li>
<li> Added a new trace source in StaWifiMac for tracing beacon arrivals</li>
<li> Added a new helper method to ApplicationContainer to start applications with some jitter around the start time</li>
<li> (network) Add a method to check whether a node with a given ID is within a NodeContainer.</li>
</ul>
<h2>Changes to existing API:</h2>
<ul>

View File

@@ -32,6 +32,8 @@ New user-visible features
- (wifi) Add a new trace source to StaWifiMac to trace beacon arrivals
- (network) Add a method to allow random variable-based jitter to be added
to the start times of applications in a container.
- (network) Add a method to check whether a node with a given ID is within
a NodeContainer.
Bugs fixed
----------

View File

@@ -136,4 +136,17 @@ NodeContainer::GetGlobal (void)
return c;
}
bool
NodeContainer::Contains (uint32_t id) const
{
for (uint32_t i = 0; i < m_nodes.size (); i++)
{
if (m_nodes[i]->GetId () == id)
{
return true;
}
}
return false;
}
} // namespace ns3

View File

@@ -288,6 +288,14 @@ public:
*/
static NodeContainer GetGlobal (void);
/**
* \brief Return true if container contains a Node with index id
*
* \return whether the NodeContainer contains a node with index id
* \param id Node Id
*/
bool Contains (uint32_t id) const;
private:
std::vector<Ptr<Node> > m_nodes; //!< Nodes smart pointers
};