rename NsUnknown to Interface and NsUnknownManager to ComponentManager
This commit is contained in:
@@ -29,7 +29,7 @@ namespace ns3{
|
||||
const Iid ApplicationList::iid ("ApplicationList");
|
||||
|
||||
ApplicationList::ApplicationList(Ptr<Node> n)
|
||||
: NsUnknown (ApplicationList::iid)
|
||||
: Interface (ApplicationList::iid)
|
||||
{}
|
||||
|
||||
void
|
||||
@@ -43,7 +43,7 @@ ApplicationList::DoDispose (void)
|
||||
*i = 0;
|
||||
}
|
||||
m_apps.clear ();
|
||||
NsUnknown::DoDispose ();
|
||||
Interface::DoDispose ();
|
||||
}
|
||||
|
||||
ApplicationList::~ApplicationList()
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class ApplicationList : public NsUnknown
|
||||
class ApplicationList : public Interface
|
||||
{
|
||||
public:
|
||||
static const Iid iid;
|
||||
|
||||
@@ -49,15 +49,15 @@ bool operator == (const ClassId &a, const ClassId &b)
|
||||
return a.m_classId == b.m_classId;
|
||||
}
|
||||
|
||||
Ptr<NsUnknown>
|
||||
NsUnknownManager::Create (ClassId classId)
|
||||
Ptr<Interface>
|
||||
ComponentManager::Create (ClassId classId)
|
||||
{
|
||||
Callback<Ptr<NsUnknown> > callback = DoGetCallback<empty,empty,empty,empty,empty> (classId);
|
||||
Callback<Ptr<Interface> > callback = DoGetCallback<empty,empty,empty,empty,empty> (classId);
|
||||
return callback ();
|
||||
}
|
||||
|
||||
CallbackBase *
|
||||
NsUnknownManager::Lookup (ClassId classId)
|
||||
ComponentManager::Lookup (ClassId classId)
|
||||
{
|
||||
List *list = Singleton<List>::Get ();
|
||||
for (List::const_iterator i = list->begin (); i != list->end (); i++)
|
||||
@@ -71,13 +71,13 @@ NsUnknownManager::Lookup (ClassId classId)
|
||||
}
|
||||
|
||||
ClassId
|
||||
NsUnknownManager::LookupByName (std::string name)
|
||||
ComponentManager::LookupByName (std::string name)
|
||||
{
|
||||
return ClassId (Singleton<CidManager>::Get ()->LookupByName (name));
|
||||
}
|
||||
|
||||
ClassId
|
||||
NsUnknownManager::Register (std::string name, CallbackBase *callback)
|
||||
ComponentManager::Register (std::string name, CallbackBase *callback)
|
||||
{
|
||||
ClassId classId = ClassId (name);
|
||||
List *list = Singleton<List>::Get ();
|
||||
@@ -96,7 +96,7 @@ NsUnknownManager::Register (std::string name, CallbackBase *callback)
|
||||
namespace {
|
||||
|
||||
|
||||
class B : public ns3::NsUnknown
|
||||
class B : public ns3::Interface
|
||||
{
|
||||
public:
|
||||
static const ns3::Iid iid;
|
||||
@@ -106,11 +106,11 @@ public:
|
||||
const ns3::Iid B::iid ("IB");
|
||||
|
||||
B::B ()
|
||||
: NsUnknown (B::iid)
|
||||
: Interface (B::iid)
|
||||
{}
|
||||
|
||||
|
||||
class A : public ns3::NsUnknown
|
||||
class A : public ns3::Interface
|
||||
{
|
||||
public:
|
||||
static const ns3::ClassId cidZero;
|
||||
@@ -130,13 +130,13 @@ public:
|
||||
int m_ui32;
|
||||
};
|
||||
|
||||
const ns3::ClassId A::cidZero = ns3::NsUnknownManager::RegisterConstructor <A> ("A");
|
||||
const ns3::ClassId A::cidOneBool = ns3::NsUnknownManager::RegisterConstructor <A,bool> ("ABool");
|
||||
const ns3::ClassId A::cidOneUi32 = ns3::NsUnknownManager::RegisterConstructor <A,uint32_t> ("AUi32");
|
||||
const ns3::ClassId A::cidZero = ns3::ComponentManager::RegisterConstructor <A> ("A");
|
||||
const ns3::ClassId A::cidOneBool = ns3::ComponentManager::RegisterConstructor <A,bool> ("ABool");
|
||||
const ns3::ClassId A::cidOneUi32 = ns3::ComponentManager::RegisterConstructor <A,uint32_t> ("AUi32");
|
||||
const ns3::Iid A::iid ("IA");
|
||||
|
||||
A::A ()
|
||||
: NsUnknown (A::iid),
|
||||
: Interface (A::iid),
|
||||
m_zeroInvoked (true),
|
||||
m_oneBoolInvoked (false),
|
||||
m_oneUi32Invoked (false)
|
||||
@@ -146,7 +146,7 @@ A::A ()
|
||||
}
|
||||
|
||||
A::A (bool bo)
|
||||
: NsUnknown (A::iid),
|
||||
: Interface (A::iid),
|
||||
m_zeroInvoked (false),
|
||||
m_oneBoolInvoked (true),
|
||||
m_oneUi32Invoked (false),
|
||||
@@ -157,7 +157,7 @@ A::A (bool bo)
|
||||
}
|
||||
|
||||
A::A (uint32_t i)
|
||||
: NsUnknown (A::iid),
|
||||
: Interface (A::iid),
|
||||
m_zeroInvoked (false),
|
||||
m_oneBoolInvoked (false),
|
||||
m_oneUi32Invoked (true),
|
||||
@@ -171,30 +171,30 @@ A::A (uint32_t i)
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class NsUnknownManagerTest : public Test
|
||||
class ComponentManagerTest : public Test
|
||||
{
|
||||
public:
|
||||
NsUnknownManagerTest ();
|
||||
ComponentManagerTest ();
|
||||
virtual bool RunTests (void);
|
||||
};
|
||||
|
||||
NsUnknownManagerTest::NsUnknownManagerTest ()
|
||||
: Test ("NsUnknownManager")
|
||||
ComponentManagerTest::ComponentManagerTest ()
|
||||
: Test ("ComponentManager")
|
||||
{}
|
||||
bool
|
||||
NsUnknownManagerTest::RunTests (void)
|
||||
ComponentManagerTest::RunTests (void)
|
||||
{
|
||||
bool ok = true;
|
||||
|
||||
Ptr<A> a = 0;
|
||||
a = NsUnknownManager::Create<A> (A::cidZero, A::iid);
|
||||
a = ComponentManager::Create<A> (A::cidZero, A::iid);
|
||||
if (a == 0 ||
|
||||
!a->m_zeroInvoked)
|
||||
{
|
||||
ok = false;
|
||||
}
|
||||
|
||||
a = NsUnknownManager::Create<A,bool> (A::cidOneBool, A::iid, true);
|
||||
a = ComponentManager::Create<A,bool> (A::cidOneBool, A::iid, true);
|
||||
if (a == 0 ||
|
||||
!a->m_oneBoolInvoked ||
|
||||
!a->m_bool)
|
||||
@@ -202,7 +202,7 @@ NsUnknownManagerTest::RunTests (void)
|
||||
ok = false;
|
||||
}
|
||||
|
||||
a = NsUnknownManager::Create<A,bool> (A::cidOneBool, A::iid, false);
|
||||
a = ComponentManager::Create<A,bool> (A::cidOneBool, A::iid, false);
|
||||
if (a == 0 ||
|
||||
!a->m_oneBoolInvoked ||
|
||||
a->m_bool)
|
||||
@@ -210,7 +210,7 @@ NsUnknownManagerTest::RunTests (void)
|
||||
ok = false;
|
||||
}
|
||||
|
||||
a = NsUnknownManager::Create<A,uint32_t> (A::cidOneUi32, A::iid, 10);
|
||||
a = ComponentManager::Create<A,uint32_t> (A::cidOneUi32, A::iid, 10);
|
||||
if (a == 0 ||
|
||||
!a->m_oneUi32Invoked ||
|
||||
a->m_ui32 != 10)
|
||||
@@ -218,7 +218,7 @@ NsUnknownManagerTest::RunTests (void)
|
||||
ok = false;
|
||||
}
|
||||
|
||||
a = NsUnknownManager::Create<A> (A::cidOneUi32, A::iid, (uint32_t)10);
|
||||
a = ComponentManager::Create<A> (A::cidOneUi32, A::iid, (uint32_t)10);
|
||||
if (a == 0 ||
|
||||
!a->m_oneUi32Invoked ||
|
||||
a->m_ui32 != 10)
|
||||
@@ -226,7 +226,7 @@ NsUnknownManagerTest::RunTests (void)
|
||||
ok = false;
|
||||
}
|
||||
|
||||
Ptr<B> b = NsUnknownManager::Create<B,uint32_t> (A::cidOneUi32, B::iid, 10);
|
||||
Ptr<B> b = ComponentManager::Create<B,uint32_t> (A::cidOneUi32, B::iid, 10);
|
||||
if (b == 0)
|
||||
{
|
||||
ok = false;
|
||||
@@ -236,7 +236,7 @@ NsUnknownManagerTest::RunTests (void)
|
||||
}
|
||||
|
||||
|
||||
static NsUnknownManagerTest g_unknownManagerTest;
|
||||
static ComponentManagerTest g_unknownManagerTest;
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
|
||||
@@ -52,22 +52,22 @@ public:
|
||||
private:
|
||||
ClassId (std::string name);
|
||||
ClassId (uint32_t classId);
|
||||
friend class NsUnknownManager;
|
||||
friend class ComponentManager;
|
||||
friend bool operator == (const ClassId &a, const ClassId &b);
|
||||
uint32_t m_classId;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Create any NsUnknown
|
||||
* \brief Create any Interface
|
||||
*
|
||||
* This class keeps track of a set of ClassId, each
|
||||
* of which uniquely identifies the constructor of an
|
||||
* object which derives from the NsUnknown base class.
|
||||
* object which derives from the Interface base class.
|
||||
* This class can also create an instance of any of
|
||||
* the objects tracked through any of their tracked
|
||||
* constructor/ClassId.
|
||||
*/
|
||||
class NsUnknownManager
|
||||
class ComponentManager
|
||||
{
|
||||
public:
|
||||
/**
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
* Create an instance of the object identified by its
|
||||
* ClassId. This method invokes the default constructor.
|
||||
*/
|
||||
static Ptr<NsUnknown> Create (ClassId classId);
|
||||
static Ptr<Interface> Create (ClassId classId);
|
||||
|
||||
/**
|
||||
* \param classId class id of the constructor to invoke.
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
* ClassId.
|
||||
*/
|
||||
template <typename T1>
|
||||
static Ptr<NsUnknown> Create (ClassId classId, T1 a1);
|
||||
static Ptr<Interface> Create (ClassId classId, T1 a1);
|
||||
|
||||
/**
|
||||
* \param classId class id of the constructor to invoke.
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
* ClassId.
|
||||
*/
|
||||
template <typename T1, typename T2>
|
||||
static Ptr<NsUnknown> Create (ClassId classId, T1 a1, T2 a2);
|
||||
static Ptr<Interface> Create (ClassId classId, T1 a1, T2 a2);
|
||||
|
||||
/**
|
||||
* \param classId class id of the constructor to invoke.
|
||||
@@ -137,9 +137,9 @@ public:
|
||||
template <typename T>
|
||||
static ClassId RegisterConstructor (std::string name)
|
||||
{
|
||||
static Callback<Ptr<NsUnknown> > callback =
|
||||
MakeCallback (&NsUnknownManager::MakeObjectZero<T>);
|
||||
return NsUnknownManager::Register (name, &callback);
|
||||
static Callback<Ptr<Interface> > callback =
|
||||
MakeCallback (&ComponentManager::MakeObjectZero<T>);
|
||||
return ComponentManager::Register (name, &callback);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,8 +151,8 @@ public:
|
||||
template <typename T, typename T1>
|
||||
static ClassId RegisterConstructor (std::string name)
|
||||
{
|
||||
static Callback<Ptr<NsUnknown> ,T1> callback = MakeCallback (&NsUnknownManager::MakeObjectOne<T,T1>);
|
||||
return NsUnknownManager::Register (name, &callback);
|
||||
static Callback<Ptr<Interface> ,T1> callback = MakeCallback (&ComponentManager::MakeObjectOne<T,T1>);
|
||||
return ComponentManager::Register (name, &callback);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,8 +164,8 @@ public:
|
||||
template <typename T, typename T1, typename T2>
|
||||
static ClassId RegisterConstructor (std::string name)
|
||||
{
|
||||
static Callback<Ptr<NsUnknown>,T1,T2> callback = MakeCallback (&NsUnknownManager::MakeObjectTwo<T,T1,T2>);
|
||||
return NsUnknownManager::Register (name, &callback);
|
||||
static Callback<Ptr<Interface>,T1,T2> callback = MakeCallback (&ComponentManager::MakeObjectTwo<T,T1,T2>);
|
||||
return ComponentManager::Register (name, &callback);
|
||||
}
|
||||
private:
|
||||
static ClassId Register (std::string name, CallbackBase *callback);
|
||||
@@ -173,16 +173,16 @@ private:
|
||||
template <typename T1, typename T2,
|
||||
typename T3, typename T4,
|
||||
typename T5>
|
||||
static Callback<Ptr<NsUnknown>,T1,T2,T3,T4,T5> DoGetCallback (ClassId classId);
|
||||
static Callback<Ptr<Interface>,T1,T2,T3,T4,T5> DoGetCallback (ClassId classId);
|
||||
|
||||
template <typename T>
|
||||
static Ptr<NsUnknown> MakeObjectZero (void);
|
||||
static Ptr<Interface> MakeObjectZero (void);
|
||||
|
||||
template <typename T, typename T1>
|
||||
static Ptr<NsUnknown> MakeObjectOne (T1 a1);
|
||||
static Ptr<Interface> MakeObjectOne (T1 a1);
|
||||
|
||||
template <typename T, typename T1, typename T2>
|
||||
static Ptr<NsUnknown> MakeObjectTwo (T1 a1, T2 a2);
|
||||
static Ptr<Interface> MakeObjectTwo (T1 a1, T2 a2);
|
||||
|
||||
typedef std::vector<std::pair<ClassId, CallbackBase *> > List;
|
||||
static List *GetList (void);
|
||||
@@ -197,79 +197,79 @@ namespace ns3 {
|
||||
template <typename T1, typename T2,
|
||||
typename T3, typename T4,
|
||||
typename T5>
|
||||
Callback<Ptr<NsUnknown>,T1,T2,T3,T4,T5>
|
||||
NsUnknownManager::DoGetCallback (ClassId classId)
|
||||
Callback<Ptr<Interface>,T1,T2,T3,T4,T5>
|
||||
ComponentManager::DoGetCallback (ClassId classId)
|
||||
{
|
||||
CallbackBase *callback = Lookup (classId);
|
||||
if (callback == 0)
|
||||
{
|
||||
NS_FATAL_ERROR ("Invalid Class Id.");
|
||||
}
|
||||
Callback<Ptr<NsUnknown>, T1,T2,T3,T4,T5> reference;
|
||||
Callback<Ptr<Interface>, T1,T2,T3,T4,T5> reference;
|
||||
reference.Assign (*callback);
|
||||
return reference;
|
||||
}
|
||||
|
||||
|
||||
template <typename T1>
|
||||
Ptr<NsUnknown>
|
||||
NsUnknownManager::Create (ClassId classId, T1 a1)
|
||||
Ptr<Interface>
|
||||
ComponentManager::Create (ClassId classId, T1 a1)
|
||||
{
|
||||
Callback<Ptr<NsUnknown>, T1> callback = DoGetCallback<T1,empty,empty,empty,empty> (classId);
|
||||
Callback<Ptr<Interface>, T1> callback = DoGetCallback<T1,empty,empty,empty,empty> (classId);
|
||||
return callback (a1);
|
||||
}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
Ptr<NsUnknown>
|
||||
NsUnknownManager::Create (ClassId classId, T1 a1, T2 a2)
|
||||
Ptr<Interface>
|
||||
ComponentManager::Create (ClassId classId, T1 a1, T2 a2)
|
||||
{
|
||||
Callback<Ptr<NsUnknown> , T1,T2> callback = DoGetCallback<T1,T2,empty,empty,empty> (classId);
|
||||
Callback<Ptr<Interface> , T1,T2> callback = DoGetCallback<T1,T2,empty,empty,empty> (classId);
|
||||
return callback (a1, a2);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Ptr<T>
|
||||
NsUnknownManager::Create (ClassId classId, Iid iid)
|
||||
ComponentManager::Create (ClassId classId, Iid iid)
|
||||
{
|
||||
Ptr<NsUnknown> obj = Create (classId);
|
||||
Ptr<Interface> obj = Create (classId);
|
||||
Ptr<T> i = obj->QueryInterface<T> (iid);
|
||||
return i;
|
||||
}
|
||||
|
||||
template <typename T, typename T1>
|
||||
Ptr<T>
|
||||
NsUnknownManager::Create (ClassId classId, Iid iid, T1 a1)
|
||||
ComponentManager::Create (ClassId classId, Iid iid, T1 a1)
|
||||
{
|
||||
Ptr<NsUnknown> obj = Create (classId, a1);
|
||||
Ptr<Interface> obj = Create (classId, a1);
|
||||
Ptr<T> i = obj->QueryInterface<T> (iid);
|
||||
return i;
|
||||
}
|
||||
|
||||
template <typename T, typename T1, typename T2>
|
||||
Ptr<T>
|
||||
NsUnknownManager::Create (ClassId classId, Iid iid, T1 a1, T2 a2)
|
||||
ComponentManager::Create (ClassId classId, Iid iid, T1 a1, T2 a2)
|
||||
{
|
||||
Ptr<NsUnknown> obj = Create (classId, a1, a2);
|
||||
Ptr<Interface> obj = Create (classId, a1, a2);
|
||||
Ptr<T> i = obj->QueryInterface<T> (iid);
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
Ptr<NsUnknown>
|
||||
NsUnknownManager::MakeObjectZero (void)
|
||||
Ptr<Interface>
|
||||
ComponentManager::MakeObjectZero (void)
|
||||
{
|
||||
return MakeNewObject<T> ();
|
||||
}
|
||||
template <typename T, typename T1>
|
||||
Ptr<NsUnknown>
|
||||
NsUnknownManager::MakeObjectOne (T1 a1)
|
||||
Ptr<Interface>
|
||||
ComponentManager::MakeObjectOne (T1 a1)
|
||||
{
|
||||
return MakeNewObject<T> (a1);
|
||||
}
|
||||
template <typename T, typename T1, typename T2>
|
||||
Ptr<NsUnknown>
|
||||
NsUnknownManager::MakeObjectTwo (T1 a1, T2 a2)
|
||||
Ptr<Interface>
|
||||
ComponentManager::MakeObjectTwo (T1 a1, T2 a2)
|
||||
{
|
||||
return MakeNewObject<T> (a1, a2);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "assert.h"
|
||||
#include "debug.h"
|
||||
|
||||
NS_DEBUG_COMPONENT_DEFINE ("NsUnknown");
|
||||
NS_DEBUG_COMPONENT_DEFINE ("Interface");
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -44,34 +44,34 @@ bool operator == (const Iid &a, const Iid &b)
|
||||
}
|
||||
|
||||
|
||||
class NsUnknownImpl
|
||||
class InterfaceImpl
|
||||
{
|
||||
public:
|
||||
NsUnknownImpl (Iid iid, NsUnknown *interface);
|
||||
~NsUnknownImpl ();
|
||||
InterfaceImpl (Iid iid, Interface *interface);
|
||||
~InterfaceImpl ();
|
||||
void Ref (void);
|
||||
void RefAll (NsUnknownImpl *other);
|
||||
void RefAll (InterfaceImpl *other);
|
||||
void Unref (void);
|
||||
void UnrefAll (void);
|
||||
NsUnknown *PeekQueryInterface (Iid iid) const;
|
||||
Interface *PeekQueryInterface (Iid iid) const;
|
||||
void DoDisposeAll (void);
|
||||
void AddInterface (NsUnknown * interface);
|
||||
void AddSelfInterface (Iid iid, NsUnknown *interface);
|
||||
void AddInterface (Interface * interface);
|
||||
void AddSelfInterface (Iid iid, Interface *interface);
|
||||
private:
|
||||
typedef std::list<std::pair<Iid,NsUnknown *> > List;
|
||||
typedef std::list<std::pair<Iid,Interface *> > List;
|
||||
uint32_t m_ref;
|
||||
List m_list;
|
||||
bool m_disposed;
|
||||
};
|
||||
|
||||
NsUnknownImpl::NsUnknownImpl (Iid iid, NsUnknown * interface)
|
||||
InterfaceImpl::InterfaceImpl (Iid iid, Interface * interface)
|
||||
: m_ref (1),
|
||||
m_disposed (false)
|
||||
{
|
||||
NS_DEBUG ("new " << this << " ref=" << m_ref);
|
||||
m_list.push_back (std::make_pair (iid, interface));
|
||||
}
|
||||
NsUnknownImpl::~NsUnknownImpl ()
|
||||
InterfaceImpl::~InterfaceImpl ()
|
||||
{
|
||||
for (List::const_iterator i = m_list.begin ();
|
||||
i != m_list.end (); i++)
|
||||
@@ -81,19 +81,19 @@ NsUnknownImpl::~NsUnknownImpl ()
|
||||
m_list.clear ();
|
||||
}
|
||||
void
|
||||
NsUnknownImpl::Ref (void)
|
||||
InterfaceImpl::Ref (void)
|
||||
{
|
||||
m_ref++;
|
||||
NS_DEBUG ("inc " << this << " ref=" << m_ref);
|
||||
}
|
||||
void
|
||||
NsUnknownImpl::RefAll (NsUnknownImpl *other)
|
||||
InterfaceImpl::RefAll (InterfaceImpl *other)
|
||||
{
|
||||
m_ref += other->m_ref;
|
||||
NS_DEBUG ("inc all " << this << " o=" << other->m_ref << " ref=" << m_ref);
|
||||
}
|
||||
void
|
||||
NsUnknownImpl::Unref (void)
|
||||
InterfaceImpl::Unref (void)
|
||||
{
|
||||
NS_ASSERT (m_ref > 0);
|
||||
m_ref--;
|
||||
@@ -104,7 +104,7 @@ NsUnknownImpl::Unref (void)
|
||||
}
|
||||
}
|
||||
void
|
||||
NsUnknownImpl::UnrefAll (void)
|
||||
InterfaceImpl::UnrefAll (void)
|
||||
{
|
||||
NS_ASSERT (m_ref > 0);
|
||||
m_ref = 0;
|
||||
@@ -112,19 +112,19 @@ NsUnknownImpl::UnrefAll (void)
|
||||
NS_DEBUG ("dec all " << this);
|
||||
}
|
||||
void
|
||||
NsUnknownImpl::DoDisposeAll (void)
|
||||
InterfaceImpl::DoDisposeAll (void)
|
||||
{
|
||||
NS_ASSERT (!m_disposed);
|
||||
for (List::const_iterator i = m_list.begin ();
|
||||
i != m_list.end (); i++)
|
||||
{
|
||||
NsUnknown *interface = i->second;
|
||||
Interface *interface = i->second;
|
||||
interface->DoDispose ();
|
||||
}
|
||||
m_disposed = true;
|
||||
}
|
||||
NsUnknown *
|
||||
NsUnknownImpl::PeekQueryInterface (Iid iid) const
|
||||
Interface *
|
||||
InterfaceImpl::PeekQueryInterface (Iid iid) const
|
||||
{
|
||||
for (List::const_iterator i = m_list.begin ();
|
||||
i != m_list.end (); i++)
|
||||
@@ -137,7 +137,7 @@ NsUnknownImpl::PeekQueryInterface (Iid iid) const
|
||||
return 0;
|
||||
}
|
||||
void
|
||||
NsUnknownImpl::AddInterface (NsUnknown *interface)
|
||||
InterfaceImpl::AddInterface (Interface *interface)
|
||||
{
|
||||
for (List::const_iterator i = interface->m_impl->m_list.begin ();
|
||||
i != interface->m_impl->m_list.end (); i++)
|
||||
@@ -149,53 +149,53 @@ NsUnknownImpl::AddInterface (NsUnknown *interface)
|
||||
}
|
||||
}
|
||||
void
|
||||
NsUnknownImpl::AddSelfInterface (Iid iid, NsUnknown *interface)
|
||||
InterfaceImpl::AddSelfInterface (Iid iid, Interface *interface)
|
||||
{
|
||||
interface->RefInternal ();
|
||||
m_list.push_back (std::make_pair (iid, interface));
|
||||
}
|
||||
|
||||
|
||||
NsUnknown::NsUnknown (Iid iid)
|
||||
: m_impl (new NsUnknownImpl (iid, this)),
|
||||
Interface::Interface (Iid iid)
|
||||
: m_impl (new InterfaceImpl (iid, this)),
|
||||
m_ref (1)
|
||||
{}
|
||||
NsUnknown::~NsUnknown ()
|
||||
Interface::~Interface ()
|
||||
{
|
||||
m_impl = 0;
|
||||
m_ref = -1;
|
||||
}
|
||||
void
|
||||
NsUnknown::Ref (void) const
|
||||
Interface::Ref (void) const
|
||||
{
|
||||
m_impl->Ref ();
|
||||
}
|
||||
void
|
||||
NsUnknown::Unref (void) const
|
||||
Interface::Unref (void) const
|
||||
{
|
||||
m_impl->Unref ();
|
||||
}
|
||||
|
||||
void
|
||||
NsUnknown::Dispose (void)
|
||||
Interface::Dispose (void)
|
||||
{
|
||||
m_impl->DoDisposeAll ();
|
||||
}
|
||||
|
||||
void
|
||||
NsUnknown::DoDispose (void)
|
||||
Interface::DoDispose (void)
|
||||
{
|
||||
// we do not do anything by default.
|
||||
}
|
||||
|
||||
void
|
||||
NsUnknown::RefInternal (void)
|
||||
Interface::RefInternal (void)
|
||||
{
|
||||
m_ref++;
|
||||
}
|
||||
|
||||
void
|
||||
NsUnknown::UnrefInternal (void)
|
||||
Interface::UnrefInternal (void)
|
||||
{
|
||||
NS_ASSERT (m_ref != 0);
|
||||
m_ref--;
|
||||
@@ -205,16 +205,16 @@ NsUnknown::UnrefInternal (void)
|
||||
}
|
||||
}
|
||||
|
||||
Ptr<NsUnknown>
|
||||
NsUnknown::DoQueryInterface (Iid iid) const
|
||||
Ptr<Interface>
|
||||
Interface::DoQueryInterface (Iid iid) const
|
||||
{
|
||||
return m_impl->PeekQueryInterface (iid);
|
||||
}
|
||||
|
||||
void
|
||||
NsUnknown::AddInterface (Ptr<NsUnknown> interface)
|
||||
Interface::AddInterface (Ptr<Interface> interface)
|
||||
{
|
||||
NsUnknown *p = PeekPointer (interface);
|
||||
Interface *p = PeekPointer (interface);
|
||||
m_impl->AddInterface (p);
|
||||
m_impl->RefAll (p->m_impl);
|
||||
p->m_impl->UnrefAll ();
|
||||
@@ -222,7 +222,7 @@ NsUnknown::AddInterface (Ptr<NsUnknown> interface)
|
||||
}
|
||||
|
||||
void
|
||||
NsUnknown::AddSelfInterface (Iid iid, Ptr<NsUnknown> interface)
|
||||
Interface::AddSelfInterface (Iid iid, Ptr<Interface> interface)
|
||||
{
|
||||
m_impl->AddSelfInterface (iid, PeekPointer (interface));
|
||||
}
|
||||
@@ -236,44 +236,44 @@ NsUnknown::AddSelfInterface (Iid iid, Ptr<NsUnknown> interface)
|
||||
|
||||
namespace {
|
||||
|
||||
class A : public ns3::NsUnknown
|
||||
class A : public ns3::Interface
|
||||
{
|
||||
public:
|
||||
static const ns3::Iid iid;
|
||||
A ()
|
||||
: NsUnknown (A::iid)
|
||||
: Interface (A::iid)
|
||||
{}
|
||||
};
|
||||
class B : public ns3::NsUnknown
|
||||
class B : public ns3::Interface
|
||||
{
|
||||
public:
|
||||
static const ns3::Iid iid;
|
||||
B ()
|
||||
: NsUnknown (B::iid)
|
||||
: Interface (B::iid)
|
||||
{}
|
||||
};
|
||||
class BaseA : public ns3::NsUnknown
|
||||
class BaseA : public ns3::Interface
|
||||
{
|
||||
public:
|
||||
static const ns3::Iid iid;
|
||||
BaseA ()
|
||||
: NsUnknown (BaseA::iid)
|
||||
: Interface (BaseA::iid)
|
||||
{}
|
||||
};
|
||||
class BaseB : public ns3::NsUnknown
|
||||
class BaseB : public ns3::Interface
|
||||
{
|
||||
public:
|
||||
static const ns3::Iid iid;
|
||||
BaseB ()
|
||||
: NsUnknown (BaseB::iid)
|
||||
: Interface (BaseB::iid)
|
||||
{}
|
||||
};
|
||||
class Base : public ns3::NsUnknown
|
||||
class Base : public ns3::Interface
|
||||
{
|
||||
public:
|
||||
static const ns3::Iid iid;
|
||||
Base ()
|
||||
: NsUnknown (Base::iid)
|
||||
: Interface (Base::iid)
|
||||
{}
|
||||
};
|
||||
class Derived : public Base
|
||||
@@ -306,7 +306,7 @@ public:
|
||||
};
|
||||
|
||||
InterfaceTest::InterfaceTest ()
|
||||
: Test ("NsUnknown")
|
||||
: Test ("Interface")
|
||||
{}
|
||||
bool
|
||||
InterfaceTest::RunTests (void)
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class NsUnknownImpl;
|
||||
class InterfaceImpl;
|
||||
|
||||
class Iid
|
||||
{
|
||||
@@ -45,15 +45,15 @@ private:
|
||||
* inheritance where this base class is at the top of the dreaded
|
||||
* "diamond" shape is not allowed.
|
||||
*/
|
||||
class NsUnknown
|
||||
class Interface
|
||||
{
|
||||
public:
|
||||
virtual ~NsUnknown ();
|
||||
virtual ~Interface ();
|
||||
void Ref (void) const;
|
||||
void Unref (void) const;
|
||||
|
||||
/**
|
||||
* \param iid the NsUnknown id of the requested interface
|
||||
* \param iid the Interface id of the requested interface
|
||||
*/
|
||||
template <typename T>
|
||||
Ptr<T> QueryInterface (Iid iid) const;
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
* will be able to perform QI on each other and their lifetimes
|
||||
* will be found by the same reference count.
|
||||
*/
|
||||
void AddInterface (Ptr<NsUnknown> interface);
|
||||
void AddInterface (Ptr<Interface> interface);
|
||||
|
||||
void Dispose (void);
|
||||
protected:
|
||||
@@ -77,17 +77,17 @@ protected:
|
||||
* If you are a direct subclass of this class, you _must_ register
|
||||
* the name of your interface with this constructor.
|
||||
*/
|
||||
NsUnknown (Iid iid);
|
||||
Interface (Iid iid);
|
||||
/**
|
||||
* \param iid the Interface id of the interface
|
||||
* \param a pointer to the interface object
|
||||
*
|
||||
* If you are not a direct subclass of the ns3::NsUnknown base class,
|
||||
* If you are not a direct subclass of the ns3::Interface base class,
|
||||
* and if you want to register yourself as another accessible interface
|
||||
* (typically, your subclass has added API), you need to call
|
||||
* this method to associate an interface id to your interface.
|
||||
*/
|
||||
void AddSelfInterface (Iid iid, Ptr<NsUnknown> interface);
|
||||
void AddSelfInterface (Iid iid, Ptr<Interface> interface);
|
||||
protected:
|
||||
/**
|
||||
* Subclasses who want to handle the "dispose" event should
|
||||
@@ -97,12 +97,12 @@ protected:
|
||||
*/
|
||||
virtual void DoDispose (void);
|
||||
private:
|
||||
friend class NsUnknownImpl;
|
||||
NsUnknown ();
|
||||
Ptr<NsUnknown> DoQueryInterface (Iid iid) const;
|
||||
friend class InterfaceImpl;
|
||||
Interface ();
|
||||
Ptr<Interface> DoQueryInterface (Iid iid) const;
|
||||
void RefInternal (void);
|
||||
void UnrefInternal (void);
|
||||
NsUnknownImpl *m_impl;
|
||||
InterfaceImpl *m_impl;
|
||||
uint32_t m_ref;
|
||||
};
|
||||
|
||||
@@ -112,9 +112,9 @@ namespace ns3 {
|
||||
|
||||
template <typename T>
|
||||
Ptr<T>
|
||||
NsUnknown::QueryInterface (Iid iid) const
|
||||
Interface::QueryInterface (Iid iid) const
|
||||
{
|
||||
Ptr<NsUnknown> found = DoQueryInterface (iid);
|
||||
Ptr<Interface> found = DoQueryInterface (iid);
|
||||
if (found != 0)
|
||||
{
|
||||
return Ptr<T> (dynamic_cast<T *> (PeekPointer (found)));
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace ns3 {
|
||||
const Iid IArpPrivate::iid ("IArpPrivate");
|
||||
|
||||
IArpPrivate::IArpPrivate (Ptr<Arp> arp)
|
||||
: NsUnknown (IArpPrivate::iid),
|
||||
: Interface (IArpPrivate::iid),
|
||||
m_arp (arp)
|
||||
{}
|
||||
IArpPrivate::~IArpPrivate ()
|
||||
@@ -48,7 +48,7 @@ void
|
||||
IArpPrivate::DoDispose (void)
|
||||
{
|
||||
m_arp = 0;
|
||||
NsUnknown::DoDispose ();
|
||||
Interface::DoDispose ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class MacAddress;
|
||||
class Packet;
|
||||
class Arp;
|
||||
|
||||
class IArpPrivate : public NsUnknown
|
||||
class IArpPrivate : public Interface
|
||||
{
|
||||
public:
|
||||
static const Iid iid;
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace ns3 {
|
||||
const Iid IIpv4Private::iid ("IIpv4Private");
|
||||
|
||||
IIpv4Private::IIpv4Private (Ptr<Ipv4> ipv4)
|
||||
: NsUnknown (IIpv4Private::iid),
|
||||
: Interface (IIpv4Private::iid),
|
||||
m_ipv4 (ipv4)
|
||||
{}
|
||||
IIpv4Private::~IIpv4Private ()
|
||||
@@ -60,7 +60,7 @@ void
|
||||
IIpv4Private::DoDispose (void)
|
||||
{
|
||||
m_ipv4 = 0;
|
||||
NsUnknown::DoDispose ();
|
||||
Interface::DoDispose ();
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -35,7 +35,7 @@ class TraceResolver;
|
||||
class Ipv4Interface;
|
||||
class NetDevice;
|
||||
|
||||
class IIpv4Private : public NsUnknown
|
||||
class IIpv4Private : public Interface
|
||||
{
|
||||
public:
|
||||
static const Iid iid;
|
||||
|
||||
@@ -58,13 +58,13 @@ InternetNode::InternetNode()
|
||||
Ptr<IIpv4Impl> ipv4Impl = MakeNewObject<IIpv4Impl> (ipv4);
|
||||
Ptr<IIpv4Private> ipv4Private = MakeNewObject<IIpv4Private> (ipv4);
|
||||
|
||||
NsUnknown::AddInterface (ipv4Private);
|
||||
NsUnknown::AddInterface (ipv4Impl);
|
||||
NsUnknown::AddInterface (arpPrivate);
|
||||
NsUnknown::AddInterface (udpImpl);
|
||||
NsUnknown::AddInterface (applicationList);
|
||||
NsUnknown::AddInterface (l3Demux);
|
||||
NsUnknown::AddInterface (ipv4L4Demux);
|
||||
Interface::AddInterface (ipv4Private);
|
||||
Interface::AddInterface (ipv4Impl);
|
||||
Interface::AddInterface (arpPrivate);
|
||||
Interface::AddInterface (udpImpl);
|
||||
Interface::AddInterface (applicationList);
|
||||
Interface::AddInterface (l3Demux);
|
||||
Interface::AddInterface (ipv4L4Demux);
|
||||
}
|
||||
|
||||
InternetNode::~InternetNode ()
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace ns3 {
|
||||
const Iid Ipv4L4Demux::iid ("Ipv4L4Demux");
|
||||
|
||||
Ipv4L4Demux::Ipv4L4Demux (Ptr<Node> node)
|
||||
: NsUnknown (Ipv4L4Demux::iid),
|
||||
: Interface (Ipv4L4Demux::iid),
|
||||
m_node (node)
|
||||
{}
|
||||
|
||||
@@ -50,7 +50,7 @@ Ipv4L4Demux::DoDispose (void)
|
||||
}
|
||||
m_protocols.clear ();
|
||||
m_node = 0;
|
||||
NsUnknown::DoDispose ();
|
||||
Interface::DoDispose ();
|
||||
}
|
||||
|
||||
TraceResolver *
|
||||
|
||||
@@ -39,7 +39,7 @@ class TraceContext;
|
||||
/**
|
||||
* \brief L4 Ipv4 Demux
|
||||
*/
|
||||
class Ipv4L4Demux : public NsUnknown
|
||||
class Ipv4L4Demux : public Interface
|
||||
{
|
||||
public:
|
||||
static const Iid iid;
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace ns3 {
|
||||
const Iid L3Demux::iid ("L3Demux");
|
||||
|
||||
L3Demux::L3Demux (Ptr<Node> node)
|
||||
: NsUnknown (L3Demux::iid),
|
||||
: Interface (L3Demux::iid),
|
||||
m_node (node)
|
||||
{}
|
||||
|
||||
@@ -49,7 +49,7 @@ L3Demux::DoDispose (void)
|
||||
}
|
||||
m_protocols.clear ();
|
||||
m_node = 0;
|
||||
NsUnknown::DoDispose ();
|
||||
Interface::DoDispose ();
|
||||
}
|
||||
|
||||
TraceResolver *
|
||||
|
||||
@@ -41,7 +41,7 @@ class TraceContext;
|
||||
/**
|
||||
* \brief L3 Demux
|
||||
*/
|
||||
class L3Demux : public NsUnknown
|
||||
class L3Demux : public Interface
|
||||
{
|
||||
public:
|
||||
static const Iid iid;
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace ns3 {
|
||||
const Iid IIpv4::iid ("IIpv4");
|
||||
|
||||
IIpv4::IIpv4 ()
|
||||
: NsUnknown (IIpv4::iid)
|
||||
: Interface (IIpv4::iid)
|
||||
{}
|
||||
|
||||
IIpv4::~IIpv4 ()
|
||||
|
||||
@@ -31,7 +31,7 @@ class NetDevice;
|
||||
class Packet;
|
||||
class Ipv4Route;
|
||||
|
||||
class IIpv4 : public NsUnknown
|
||||
class IIpv4 : public Interface
|
||||
{
|
||||
public:
|
||||
static const Iid iid;
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace ns3 {
|
||||
const Iid IUdp::iid ("IUdp");
|
||||
|
||||
IUdp::IUdp ()
|
||||
: NsUnknown (IUdp::iid)
|
||||
: Interface (IUdp::iid)
|
||||
{}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace ns3 {
|
||||
|
||||
class Socket;
|
||||
|
||||
class IUdp : public NsUnknown
|
||||
class IUdp : public Interface
|
||||
{
|
||||
public:
|
||||
static const Iid iid;
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace ns3{
|
||||
const Iid Node::iid ("Node");
|
||||
|
||||
Node::Node()
|
||||
: NsUnknown (Node::iid),
|
||||
: Interface (Node::iid),
|
||||
m_id(0),
|
||||
m_sid(0)
|
||||
{
|
||||
@@ -40,7 +40,7 @@ Node::Node()
|
||||
}
|
||||
|
||||
Node::Node(uint32_t sid)
|
||||
: NsUnknown (Node::iid),
|
||||
: Interface (Node::iid),
|
||||
m_id(0),
|
||||
m_sid(sid)
|
||||
{
|
||||
@@ -98,7 +98,7 @@ void Node::DoDispose()
|
||||
*i = 0;
|
||||
}
|
||||
m_devices.clear ();
|
||||
NsUnknown::DoDispose ();
|
||||
Interface::DoDispose ();
|
||||
}
|
||||
|
||||
}//namespace ns3
|
||||
|
||||
@@ -35,7 +35,7 @@ class TraceContext;
|
||||
class TraceResolver;
|
||||
class NetDevice;
|
||||
|
||||
class Node : public NsUnknown
|
||||
class Node : public Interface
|
||||
{
|
||||
public:
|
||||
static const Iid iid;
|
||||
|
||||
Reference in New Issue
Block a user