change signature of MobilityHelper::Layout and MobilityHelper::LayoutAll.
This commit is contained in:
@@ -142,7 +142,7 @@ Experiment::Run (const WifiHelper &wifi)
|
||||
mobility.SetPositionAllocator (positionAlloc);
|
||||
mobility.SetMobilityModel ("ns3::StaticMobilityModel");
|
||||
|
||||
mobility.Layout (c.Begin (), c.End ());
|
||||
mobility.Layout (c);
|
||||
|
||||
PacketSocketAddress destination = PacketSocketAddress ();
|
||||
destination.SetProtocol (1);
|
||||
|
||||
+2
-2
@@ -161,8 +161,8 @@ int main (int argc, char *argv[])
|
||||
wifi.Build (ap, channel);
|
||||
|
||||
// mobility.
|
||||
mobility.Layout (stas.Begin (), stas.End ());
|
||||
mobility.Layout (ap.Begin (), ap.End ());
|
||||
mobility.Layout (stas);
|
||||
mobility.Layout (ap);
|
||||
|
||||
Simulator::Schedule (Seconds (1.0), &AdvancePosition, ap.Get (0));
|
||||
|
||||
|
||||
@@ -16,13 +16,10 @@ int main (int argc, char *argv[])
|
||||
CommandLine cmd;
|
||||
cmd.Parse (argc, argv);
|
||||
|
||||
std::vector<Ptr<Object> > nodes;
|
||||
NodeContainer nodes;
|
||||
|
||||
// create an array of empty nodes for testing purposes
|
||||
for (uint32_t i = 0; i < 120; i++)
|
||||
{
|
||||
nodes.push_back (CreateObject<Node> ());
|
||||
}
|
||||
nodes.Create (120);
|
||||
|
||||
MobilityHelper mobility;
|
||||
// setup the grid itself: objects are layed out
|
||||
@@ -44,13 +41,13 @@ int main (int argc, char *argv[])
|
||||
// finalize the setup by attaching to each object
|
||||
// in the input array a position and initializing
|
||||
// this position with the calculated coordinates.
|
||||
mobility.Layout (nodes.begin (), nodes.end ());
|
||||
mobility.Layout (nodes);
|
||||
|
||||
// iterate our nodes and print their position.
|
||||
for (std::vector<Ptr<Object> >::const_iterator j = nodes.begin ();
|
||||
j != nodes.end (); j++)
|
||||
for (NodeContainer::Iterator j = nodes.Begin ();
|
||||
j != nodes.End (); ++j)
|
||||
{
|
||||
Ptr<Object> object = *j;
|
||||
Ptr<Node> object = *j;
|
||||
Ptr<MobilityModel> position = object->GetObject<MobilityModel> ();
|
||||
NS_ASSERT (position != 0);
|
||||
Vector pos = position->GetPosition ();
|
||||
|
||||
@@ -29,11 +29,8 @@ int main (int argc, char *argv[])
|
||||
cmd.Parse (argc, argv);
|
||||
|
||||
|
||||
std::vector<Ptr<Object> > objects;
|
||||
for (uint32_t i = 0; i < 10000; i++)
|
||||
{
|
||||
objects.push_back (CreateObject<Node> ());
|
||||
}
|
||||
NodeContainer c;
|
||||
c.Create (10000);
|
||||
|
||||
MobilityHelper mobility;
|
||||
mobility.EnableNotifier ();
|
||||
@@ -42,7 +39,7 @@ int main (int argc, char *argv[])
|
||||
"Y", String ("100.0"),
|
||||
"Rho", String ("Uniform:0:30"));
|
||||
mobility.SetMobilityModel ("ns3::StaticMobilityModel");
|
||||
mobility.Layout (objects.begin (), objects.end ());
|
||||
mobility.Layout (c);
|
||||
|
||||
Config::Connect ("/NodeList/*/$ns3::MobilityModelNotifier/CourseChange",
|
||||
MakeCallback (&CourseChange));
|
||||
|
||||
@@ -36,10 +36,8 @@ int main (int argc, char *argv[])
|
||||
CommandLine cmd;
|
||||
cmd.Parse (argc, argv);
|
||||
|
||||
for (uint32_t i = 0; i < 100; i++)
|
||||
{
|
||||
Ptr<Node> node = CreateObject<Node> ();
|
||||
}
|
||||
NodeContainer c;
|
||||
c.Create (100);
|
||||
|
||||
MobilityHelper mobility;
|
||||
mobility.EnableNotifier ();
|
||||
@@ -52,7 +50,7 @@ int main (int argc, char *argv[])
|
||||
"Time", String ("2s"),
|
||||
"Speed", String ("Constant:1.0"),
|
||||
"Bounds", String ("0:200:0:100"));
|
||||
mobility.Layout (NodeList::Begin (), NodeList::End ());
|
||||
mobility.LayoutAll ();
|
||||
Config::Connect ("/NodeList/*/$ns3::MobilityModelNotifier/CourseChange",
|
||||
MakeCallback (&CourseChange));
|
||||
|
||||
|
||||
@@ -101,9 +101,9 @@ MobilityHelper::GetMobilityModelType (void) const
|
||||
}
|
||||
|
||||
void
|
||||
MobilityHelper::Layout (const std::vector<Ptr<Object> > &objects)
|
||||
MobilityHelper::Layout (NodeContainer c)
|
||||
{
|
||||
for (std::vector<Ptr<Object> >::const_iterator i = objects.begin (); i != objects.end (); i++)
|
||||
for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
|
||||
{
|
||||
Ptr<Object> object = *i;
|
||||
Ptr<MobilityModel> model = object->GetObject<MobilityModel> ();
|
||||
@@ -145,4 +145,10 @@ MobilityHelper::Layout (const std::vector<Ptr<Object> > &objects)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MobilityHelper::LayoutAll (void)
|
||||
{
|
||||
Layout (NodeContainer::GetGlobal ());
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -4,13 +4,17 @@
|
||||
#include <vector>
|
||||
#include "ns3/object-factory.h"
|
||||
#include "ns3/attribute.h"
|
||||
#include "position-allocator.h"
|
||||
#include "ns3/position-allocator.h"
|
||||
#include "node-container.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class PositionAllocator;
|
||||
class MobilityModel;
|
||||
|
||||
/**
|
||||
* \brief assign positions and mobility models to nodes.
|
||||
*/
|
||||
class MobilityHelper
|
||||
{
|
||||
public:
|
||||
@@ -48,10 +52,9 @@ public:
|
||||
|
||||
std::string GetMobilityModelType (void) const;
|
||||
|
||||
template <typename T>
|
||||
void Layout (T begin, T end);
|
||||
void Layout (NodeContainer container);
|
||||
void LayoutAll (void);
|
||||
private:
|
||||
void Layout (const std::vector<Ptr<Object> > &objects);
|
||||
|
||||
std::vector<Ptr<MobilityModel> > m_mobilityStack;
|
||||
bool m_notifierEnabled;
|
||||
@@ -61,21 +64,4 @@ private:
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
MobilityHelper::Layout (T begin, T end)
|
||||
{
|
||||
std::vector<Ptr<Object> > objects;
|
||||
for (T i = begin; i != end; i++)
|
||||
{
|
||||
Ptr<Object> object = *i;
|
||||
objects.push_back (object);
|
||||
}
|
||||
Layout (objects);
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* MOBILITY_HELPER_H */
|
||||
|
||||
Reference in New Issue
Block a user