add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
This commit is contained in:
@@ -40,10 +40,6 @@ Application::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("Application")
|
||||
.SetParent<Object> ()
|
||||
.AddAttribute ("Node", "The on which this application resides",
|
||||
Ptr<Node> (0),
|
||||
MakePtrAccessor (&Application::m_node),
|
||||
MakePtrChecker<Node> ())
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
@@ -92,6 +88,12 @@ Ptr<Node> Application::GetNode() const
|
||||
return m_node;
|
||||
}
|
||||
|
||||
void
|
||||
Application::SetNode (Ptr<Node> node)
|
||||
{
|
||||
m_node = node;
|
||||
}
|
||||
|
||||
// Protected methods
|
||||
// StartApp and StopApp will likely be overridden by application subclasses
|
||||
void Application::StartApplication()
|
||||
|
||||
@@ -102,6 +102,8 @@ public:
|
||||
* \returns the Node to which this Application object is attached.
|
||||
*/
|
||||
Ptr<Node> GetNode() const;
|
||||
|
||||
void SetNode (Ptr<Node> node);
|
||||
|
||||
private:
|
||||
/**
|
||||
|
||||
@@ -221,6 +221,8 @@ public:
|
||||
*/
|
||||
virtual Ptr<Node> GetNode (void) const = 0;
|
||||
|
||||
virtual void SetNode (Ptr<Node> node) = 0;
|
||||
|
||||
/**
|
||||
* \returns true if ARP is needed, false otherwise.
|
||||
*
|
||||
|
||||
@@ -96,6 +96,7 @@ Node::AddDevice (Ptr<NetDevice> device)
|
||||
{
|
||||
uint32_t index = m_devices.size ();
|
||||
m_devices.push_back (device);
|
||||
device->SetNode (this);
|
||||
device->SetIfIndex(index);
|
||||
device->SetReceiveCallback (MakeCallback (&Node::ReceiveFromDevice, this));
|
||||
NotifyDeviceAdded (device);
|
||||
@@ -117,6 +118,7 @@ Node::AddApplication (Ptr<Application> application)
|
||||
{
|
||||
uint32_t index = m_applications.size ();
|
||||
m_applications.push_back (application);
|
||||
application->SetNode (this);
|
||||
return index;
|
||||
}
|
||||
Ptr<Application>
|
||||
|
||||
Reference in New Issue
Block a user