make ApplicationList an NsUnknown object.
parent
b0399a9f9c
commit
e89d1692e5
|
@ -126,7 +126,7 @@ int main (int argc, char *argv[])
|
|||
DataRate(448000),
|
||||
210);
|
||||
// Add to Node's ApplicationList (takes ownership of pointer)
|
||||
ApplicationList *apl0 = n0->GetApplicationList();
|
||||
ApplicationList *apl0 = n0->QueryInterface<ApplicationList> (ApplicationList::iid);
|
||||
apl0->Add(ooff0);
|
||||
apl0->Unref ();
|
||||
// Start the application
|
||||
|
@ -144,7 +144,7 @@ int main (int argc, char *argv[])
|
|||
DataRate(448000),
|
||||
210);
|
||||
// Add to Node's ApplicationList (takes ownership of pointer)
|
||||
ApplicationList *apl3 = n3->GetApplicationList();
|
||||
ApplicationList *apl3 = n3->QueryInterface<ApplicationList> (ApplicationList::iid);
|
||||
apl3->Add(ooff1);
|
||||
apl3->Unref ();
|
||||
// Start the application
|
||||
|
|
|
@ -23,10 +23,14 @@
|
|||
|
||||
#include "application.h"
|
||||
#include "application-list.h"
|
||||
#include "ns3/iid-manager.h"
|
||||
|
||||
namespace ns3{
|
||||
|
||||
const uint32_t ApplicationList::iid = IidManager::Allocate ("ApplicationList");
|
||||
|
||||
ApplicationList::ApplicationList(Node* n)
|
||||
: NsUnknown (ApplicationList::iid)
|
||||
{}
|
||||
|
||||
void
|
||||
|
|
|
@ -25,14 +25,15 @@
|
|||
#define __APPLICATION_LIST_H__
|
||||
|
||||
#include "application.h"
|
||||
#include "ns3/object.h"
|
||||
#include "ns3/ns-unknown.h"
|
||||
#include <vector>
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class ApplicationList : public Object
|
||||
class ApplicationList : public NsUnknown
|
||||
{
|
||||
public:
|
||||
static const uint32_t iid;
|
||||
ApplicationList(Node*);
|
||||
// Copy constructor not needed, default one is correct
|
||||
virtual ~ApplicationList();
|
||||
|
|
|
@ -38,10 +38,11 @@ namespace ns3 {
|
|||
InternetNode::InternetNode()
|
||||
{
|
||||
// Instantiate the capabilities
|
||||
m_applicationList = new ApplicationList(this);
|
||||
ApplicationList *applicationList = new ApplicationList(this);
|
||||
L3Demux *l3Demux = new L3Demux(this);
|
||||
Ipv4L4Demux *ipv4L4Demux = new Ipv4L4Demux(this);
|
||||
|
||||
NsUnknown::AddInterface (applicationList);
|
||||
NsUnknown::AddInterface (l3Demux);
|
||||
NsUnknown::AddInterface (ipv4L4Demux);
|
||||
|
||||
|
@ -53,6 +54,7 @@ InternetNode::InternetNode()
|
|||
l3Demux->Insert (arp);
|
||||
ipv4L4Demux->Insert (udp);
|
||||
|
||||
applicationList->Unref ();
|
||||
l3Demux->Unref ();
|
||||
ipv4L4Demux->Unref ();
|
||||
ipv4->Unref ();
|
||||
|
@ -97,24 +99,9 @@ InternetNode::CreateTraceResolver (TraceContext const &context)
|
|||
void
|
||||
InternetNode::DoDispose()
|
||||
{
|
||||
if (m_applicationList != 0)
|
||||
{
|
||||
m_applicationList->Dispose ();
|
||||
m_applicationList->Unref ();
|
||||
m_applicationList = 0;
|
||||
}
|
||||
|
||||
Node::DoDispose ();
|
||||
}
|
||||
|
||||
ApplicationList*
|
||||
InternetNode::GetApplicationList() const
|
||||
{
|
||||
m_applicationList->Ref ();
|
||||
return m_applicationList;
|
||||
}
|
||||
|
||||
|
||||
Ipv4 *
|
||||
InternetNode::GetIpv4 (void) const
|
||||
{
|
||||
|
|
|
@ -45,7 +45,6 @@ public:
|
|||
virtual ~InternetNode ();
|
||||
virtual TraceResolver *CreateTraceResolver (TraceContext const &context);
|
||||
// Capability access
|
||||
virtual ApplicationList* GetApplicationList() const;
|
||||
virtual Ipv4 * GetIpv4 (void) const;
|
||||
virtual Udp * GetUdp (void) const;
|
||||
virtual Arp * GetArp (void) const;
|
||||
|
@ -57,7 +56,6 @@ private:
|
|||
virtual void DoAddDevice (NetDevice *device) const;
|
||||
bool ReceiveFromDevice (NetDevice *device, const Packet &p, uint16_t protocolNumber) const;
|
||||
// Capabilities
|
||||
ApplicationList* m_applicationList;
|
||||
std::string m_name;
|
||||
};
|
||||
|
||||
|
|
|
@ -102,11 +102,6 @@ void Node::DoDispose()
|
|||
NsUnknown::DoDispose ();
|
||||
}
|
||||
|
||||
ApplicationList* Node::GetApplicationList() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Ipv4 *
|
||||
Node::GetIpv4 (void) const
|
||||
{
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
|
||||
namespace ns3 {
|
||||
|
||||
class ApplicationList;
|
||||
class Ipv4;
|
||||
class Udp;
|
||||
class Arp;
|
||||
|
@ -72,7 +71,6 @@ public:
|
|||
// Each of these has a default behavior of returning a null capability
|
||||
// of the correct type if one exists, or the nil pointer if no
|
||||
// null capability exists.
|
||||
virtual ApplicationList* GetApplicationList() const;
|
||||
virtual Ipv4 * GetIpv4 (void) const;
|
||||
virtual Udp * GetUdp (void) const;
|
||||
virtual Arp * GetArp (void) const;
|
||||
|
|
Loading…
Reference in New Issue