add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.

This commit is contained in:
Mathieu Lacage
2008-03-13 11:10:38 -07:00
parent aa3db11715
commit fb452286e6
43 changed files with 232 additions and 328 deletions

View File

@@ -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()

View File

@@ -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:
/**

View File

@@ -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.
*

View File

@@ -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>