use a 16 bit interface id
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Fri, 25 May 2007 12:23:51 +0200
changeset 712 0708bee3dbf3
parent 711 5b2e9f62aa4d
child 713 c3c745a80610
use a 16 bit interface id
src/core/object.cc
src/core/object.h
--- a/src/core/object.cc	Fri May 25 12:19:58 2007 +0200
+++ b/src/core/object.cc	Fri May 25 12:23:51 2007 +0200
@@ -32,20 +32,20 @@
 class IidTree
 {
 public:
-  void SetParent (uint32_t child, const uint32_t *parent);
-  uint32_t LookupParent (uint32_t child);
+  void SetParent (uint16_t child, const uint16_t *parent);
+  uint16_t LookupParent (uint16_t child);
 private:
-  std::vector<const uint32_t *> m_parents;
+  std::vector<const uint16_t *> m_parents;
 };
 
 void 
-IidTree::SetParent (uint32_t child, const uint32_t *parent)
+IidTree::SetParent (uint16_t child, const uint16_t *parent)
 {
   m_parents.resize (child+1);
   m_parents[child] = parent;
 }
-uint32_t 
-IidTree::LookupParent (uint32_t child)
+uint16_t 
+IidTree::LookupParent (uint16_t child)
 {
   return *(m_parents[child]);
 }
@@ -54,7 +54,7 @@
 
 namespace ns3 {
 
-InterfaceId::InterfaceId (uint32_t iid)
+InterfaceId::InterfaceId (uint16_t iid)
   : m_iid (iid)
 {}
 InterfaceId::~InterfaceId ()
@@ -62,7 +62,9 @@
 InterfaceId 
 InterfaceId::LookupByName (std::string name)
 {
-  return InterfaceId (Singleton<IidManager>::Get ()->LookupByName (name));
+  uint32_t uid = Singleton<IidManager>::Get ()->LookupByName (name);
+  NS_ASSERT (uid <= 0xffff);
+  return InterfaceId (uid);
 }
 InterfaceId 
 InterfaceId::LookupParent (InterfaceId iid)
@@ -83,7 +85,9 @@
 InterfaceId
 MakeInterfaceId (std::string name, const InterfaceId &parent)
 {
-  InterfaceId iid = Singleton<IidManager>::Get ()->Allocate (name);
+  uint32_t uid = Singleton<IidManager>::Get ()->Allocate (name);
+  NS_ASSERT (uid <= 0xffff);
+  InterfaceId iid = uid;
   Singleton<IidTree>::Get ()->SetParent (iid.m_iid, &parent.m_iid);
   return iid;
 }
--- a/src/core/object.h	Fri May 25 12:19:58 2007 +0200
+++ b/src/core/object.h	Fri May 25 12:23:51 2007 +0200
@@ -34,12 +34,12 @@
   static InterfaceId LookupParent (InterfaceId iid);
   ~InterfaceId ();
 private:
-  InterfaceId (uint32_t iid);
+  InterfaceId (uint16_t iid);
   friend InterfaceId MakeInterfaceId (std::string name, const InterfaceId &parent);
   friend InterfaceId MakeObjectInterfaceId (void);
   friend bool operator == (const InterfaceId &a, const InterfaceId &b);
   friend bool operator != (const InterfaceId &a, const InterfaceId &b);
-  uint32_t m_iid;
+  uint16_t m_iid;
 };
 
 InterfaceId