Change nix-vector to use SimpleRefCount instead of Object
authorJosh Pelkey <jpelkey@gatech.edu>
Mon, 19 Jul 2010 14:21:12 -0400
changeset 6455 e17da5733c0b
parent 6451 77184657a698
child 6456 da948859de66
Change nix-vector to use SimpleRefCount instead of Object
bindings/python/apidefs/gcc-ILP32/ns3_module_common.py
bindings/python/apidefs/gcc-ILP32/ns3_module_core.py
bindings/python/apidefs/gcc-LP64/ns3_module_common.py
bindings/python/apidefs/gcc-LP64/ns3_module_core.py
src/common/nix-vector.cc
src/common/nix-vector.h
src/common/packet.cc
src/common/pcap-file-wrapper.h
src/routing/nix-vector-routing/ipv4-nix-vector-routing.cc
--- a/bindings/python/apidefs/gcc-ILP32/ns3_module_common.py	Mon Jul 19 22:37:44 2010 +0530
+++ b/bindings/python/apidefs/gcc-ILP32/ns3_module_common.py	Mon Jul 19 14:21:12 2010 -0400
@@ -67,6 +67,8 @@
     module.add_class('RandomPropagationDelayModel', parent=root_module['ns3::PropagationDelayModel'])
     ## propagation-loss-model.h: ns3::RandomPropagationLossModel [class]
     module.add_class('RandomPropagationLossModel', parent=root_module['ns3::PropagationLossModel'])
+    ## simple-ref-count.h: ns3::SimpleRefCount<ns3::NixVector, ns3::empty, ns3::DefaultDeleter<ns3::NixVector> > [class]
+    module.add_class('SimpleRefCount', automatic_type_narrowing=True, template_parameters=['ns3::NixVector', 'ns3::empty', 'ns3::DefaultDeleter<ns3::NixVector>'], parent=root_module['ns3::empty'], memory_policy=cppclass.ReferenceCountingMethodsPolicy(incref_method='Ref', decref_method='Unref', peekref_method='GetReferenceCount'))
     ## simple-ref-count.h: ns3::SimpleRefCount<ns3::OutputStreamWrapper, ns3::empty, ns3::DefaultDeleter<ns3::OutputStreamWrapper> > [class]
     module.add_class('SimpleRefCount', automatic_type_narrowing=True, template_parameters=['ns3::OutputStreamWrapper', 'ns3::empty', 'ns3::DefaultDeleter<ns3::OutputStreamWrapper>'], parent=root_module['ns3::empty'], memory_policy=cppclass.ReferenceCountingMethodsPolicy(incref_method='Ref', decref_method='Unref', peekref_method='GetReferenceCount'))
     ## simple-ref-count.h: ns3::SimpleRefCount<ns3::Packet, ns3::empty, ns3::DefaultDeleter<ns3::Packet> > [class]
@@ -120,7 +122,7 @@
     ## propagation-loss-model.h: ns3::NakagamiPropagationLossModel [class]
     module.add_class('NakagamiPropagationLossModel', parent=root_module['ns3::PropagationLossModel'])
     ## nix-vector.h: ns3::NixVector [class]
-    module.add_class('NixVector', parent=root_module['ns3::Object'])
+    module.add_class('NixVector', parent=root_module['ns3::SimpleRefCount< ns3::NixVector, ns3::empty, ns3::DefaultDeleter<ns3::NixVector> >'])
     ## output-stream-wrapper.h: ns3::OutputStreamWrapper [class]
     module.add_class('OutputStreamWrapper', parent=root_module['ns3::SimpleRefCount< ns3::OutputStreamWrapper, ns3::empty, ns3::DefaultDeleter<ns3::OutputStreamWrapper> >'])
     ## packet.h: ns3::Packet [class]
@@ -2031,11 +2033,6 @@
                    'uint32_t', 
                    [param('uint32_t', 'numberOfNeighbors')], 
                    is_const=True)
-    ## nix-vector.h: ns3::Ptr<ns3::NixVector> ns3::NixVector::Copy() const [member function]
-    cls.add_method('Copy', 
-                   'ns3::Ptr< ns3::NixVector >', 
-                   [], 
-                   is_const=True)
     ## nix-vector.h: uint32_t ns3::NixVector::Deserialize(uint32_t const * buffer, uint32_t size) [member function]
     cls.add_method('Deserialize', 
                    'uint32_t', 
@@ -2058,11 +2055,6 @@
                    'uint32_t', 
                    [], 
                    is_const=True)
-    ## nix-vector.h: static ns3::TypeId ns3::NixVector::GetTypeId() [member function]
-    cls.add_method('GetTypeId', 
-                   'ns3::TypeId', 
-                   [], 
-                   is_static=True)
     ## nix-vector.h: uint32_t ns3::NixVector::Serialize(uint32_t * buffer, uint32_t maxSize) const [member function]
     cls.add_method('Serialize', 
                    'uint32_t', 
--- a/bindings/python/apidefs/gcc-ILP32/ns3_module_core.py	Mon Jul 19 22:37:44 2010 +0530
+++ b/bindings/python/apidefs/gcc-ILP32/ns3_module_core.py	Mon Jul 19 14:21:12 2010 -0400
@@ -399,6 +399,7 @@
     register_Ns3SimpleRefCount__Ns3Ipv6MulticastRoute_Ns3Empty_Ns3DefaultDeleter__lt__ns3Ipv6MulticastRoute__gt___methods(root_module, root_module['ns3::SimpleRefCount< ns3::Ipv6MulticastRoute, ns3::empty, ns3::DefaultDeleter<ns3::Ipv6MulticastRoute> >'])
     register_Ns3SimpleRefCount__Ns3Ipv6Route_Ns3Empty_Ns3DefaultDeleter__lt__ns3Ipv6Route__gt___methods(root_module, root_module['ns3::SimpleRefCount< ns3::Ipv6Route, ns3::empty, ns3::DefaultDeleter<ns3::Ipv6Route> >'])
     register_Ns3SimpleRefCount__Ns3MeshWifiInterfaceMacPlugin_Ns3Empty_Ns3DefaultDeleter__lt__ns3MeshWifiInterfaceMacPlugin__gt___methods(root_module, root_module['ns3::SimpleRefCount< ns3::MeshWifiInterfaceMacPlugin, ns3::empty, ns3::DefaultDeleter<ns3::MeshWifiInterfaceMacPlugin> >'])
+    register_Ns3SimpleRefCount__Ns3NixVector_Ns3Empty_Ns3DefaultDeleter__lt__ns3NixVector__gt___methods(root_module, root_module['ns3::SimpleRefCount< ns3::NixVector, ns3::empty, ns3::DefaultDeleter<ns3::NixVector> >'])
     register_Ns3SimpleRefCount__Ns3OutputStreamWrapper_Ns3Empty_Ns3DefaultDeleter__lt__ns3OutputStreamWrapper__gt___methods(root_module, root_module['ns3::SimpleRefCount< ns3::OutputStreamWrapper, ns3::empty, ns3::DefaultDeleter<ns3::OutputStreamWrapper> >'])
     register_Ns3SimpleRefCount__Ns3Packet_Ns3Empty_Ns3DefaultDeleter__lt__ns3Packet__gt___methods(root_module, root_module['ns3::SimpleRefCount< ns3::Packet, ns3::empty, ns3::DefaultDeleter<ns3::Packet> >'])
     register_Ns3SimpleRefCount__Ns3PbbAddressBlock_Ns3Empty_Ns3DefaultDeleter__lt__ns3PbbAddressBlock__gt___methods(root_module, root_module['ns3::SimpleRefCount< ns3::PbbAddressBlock, ns3::empty, ns3::DefaultDeleter<ns3::PbbAddressBlock> >'])
@@ -1973,6 +1974,18 @@
                    is_static=True)
     return
 
+def register_Ns3SimpleRefCount__Ns3NixVector_Ns3Empty_Ns3DefaultDeleter__lt__ns3NixVector__gt___methods(root_module, cls):
+    ## simple-ref-count.h: ns3::SimpleRefCount<ns3::NixVector, ns3::empty, ns3::DefaultDeleter<ns3::NixVector> >::SimpleRefCount() [constructor]
+    cls.add_constructor([])
+    ## simple-ref-count.h: ns3::SimpleRefCount<ns3::NixVector, ns3::empty, ns3::DefaultDeleter<ns3::NixVector> >::SimpleRefCount(ns3::SimpleRefCount<ns3::NixVector, ns3::empty, ns3::DefaultDeleter<ns3::NixVector> > const & o) [copy constructor]
+    cls.add_constructor([param('ns3::SimpleRefCount< ns3::NixVector, ns3::empty, ns3::DefaultDeleter< ns3::NixVector > > const &', 'o')])
+    ## simple-ref-count.h: static void ns3::SimpleRefCount<ns3::NixVector, ns3::empty, ns3::DefaultDeleter<ns3::NixVector> >::Cleanup() [member function]
+    cls.add_method('Cleanup', 
+                   'void', 
+                   [], 
+                   is_static=True)
+    return
+
 def register_Ns3SimpleRefCount__Ns3OutputStreamWrapper_Ns3Empty_Ns3DefaultDeleter__lt__ns3OutputStreamWrapper__gt___methods(root_module, cls):
     ## simple-ref-count.h: ns3::SimpleRefCount<ns3::OutputStreamWrapper, ns3::empty, ns3::DefaultDeleter<ns3::OutputStreamWrapper> >::SimpleRefCount() [constructor]
     cls.add_constructor([])
--- a/bindings/python/apidefs/gcc-LP64/ns3_module_common.py	Mon Jul 19 22:37:44 2010 +0530
+++ b/bindings/python/apidefs/gcc-LP64/ns3_module_common.py	Mon Jul 19 14:21:12 2010 -0400
@@ -67,6 +67,8 @@
     module.add_class('RandomPropagationDelayModel', parent=root_module['ns3::PropagationDelayModel'])
     ## propagation-loss-model.h: ns3::RandomPropagationLossModel [class]
     module.add_class('RandomPropagationLossModel', parent=root_module['ns3::PropagationLossModel'])
+    ## simple-ref-count.h: ns3::SimpleRefCount<ns3::NixVector, ns3::empty, ns3::DefaultDeleter<ns3::NixVector> > [class]
+    module.add_class('SimpleRefCount', automatic_type_narrowing=True, template_parameters=['ns3::NixVector', 'ns3::empty', 'ns3::DefaultDeleter<ns3::NixVector>'], parent=root_module['ns3::empty'], memory_policy=cppclass.ReferenceCountingMethodsPolicy(incref_method='Ref', decref_method='Unref', peekref_method='GetReferenceCount'))
     ## simple-ref-count.h: ns3::SimpleRefCount<ns3::OutputStreamWrapper, ns3::empty, ns3::DefaultDeleter<ns3::OutputStreamWrapper> > [class]
     module.add_class('SimpleRefCount', automatic_type_narrowing=True, template_parameters=['ns3::OutputStreamWrapper', 'ns3::empty', 'ns3::DefaultDeleter<ns3::OutputStreamWrapper>'], parent=root_module['ns3::empty'], memory_policy=cppclass.ReferenceCountingMethodsPolicy(incref_method='Ref', decref_method='Unref', peekref_method='GetReferenceCount'))
     ## simple-ref-count.h: ns3::SimpleRefCount<ns3::Packet, ns3::empty, ns3::DefaultDeleter<ns3::Packet> > [class]
@@ -120,7 +122,7 @@
     ## propagation-loss-model.h: ns3::NakagamiPropagationLossModel [class]
     module.add_class('NakagamiPropagationLossModel', parent=root_module['ns3::PropagationLossModel'])
     ## nix-vector.h: ns3::NixVector [class]
-    module.add_class('NixVector', parent=root_module['ns3::Object'])
+    module.add_class('NixVector', parent=root_module['ns3::SimpleRefCount< ns3::NixVector, ns3::empty, ns3::DefaultDeleter<ns3::NixVector> >'])
     ## output-stream-wrapper.h: ns3::OutputStreamWrapper [class]
     module.add_class('OutputStreamWrapper', parent=root_module['ns3::SimpleRefCount< ns3::OutputStreamWrapper, ns3::empty, ns3::DefaultDeleter<ns3::OutputStreamWrapper> >'])
     ## packet.h: ns3::Packet [class]
@@ -2031,11 +2033,6 @@
                    'uint32_t', 
                    [param('uint32_t', 'numberOfNeighbors')], 
                    is_const=True)
-    ## nix-vector.h: ns3::Ptr<ns3::NixVector> ns3::NixVector::Copy() const [member function]
-    cls.add_method('Copy', 
-                   'ns3::Ptr< ns3::NixVector >', 
-                   [], 
-                   is_const=True)
     ## nix-vector.h: uint32_t ns3::NixVector::Deserialize(uint32_t const * buffer, uint32_t size) [member function]
     cls.add_method('Deserialize', 
                    'uint32_t', 
@@ -2058,11 +2055,6 @@
                    'uint32_t', 
                    [], 
                    is_const=True)
-    ## nix-vector.h: static ns3::TypeId ns3::NixVector::GetTypeId() [member function]
-    cls.add_method('GetTypeId', 
-                   'ns3::TypeId', 
-                   [], 
-                   is_static=True)
     ## nix-vector.h: uint32_t ns3::NixVector::Serialize(uint32_t * buffer, uint32_t maxSize) const [member function]
     cls.add_method('Serialize', 
                    'uint32_t', 
--- a/bindings/python/apidefs/gcc-LP64/ns3_module_core.py	Mon Jul 19 22:37:44 2010 +0530
+++ b/bindings/python/apidefs/gcc-LP64/ns3_module_core.py	Mon Jul 19 14:21:12 2010 -0400
@@ -399,6 +399,7 @@
     register_Ns3SimpleRefCount__Ns3Ipv6MulticastRoute_Ns3Empty_Ns3DefaultDeleter__lt__ns3Ipv6MulticastRoute__gt___methods(root_module, root_module['ns3::SimpleRefCount< ns3::Ipv6MulticastRoute, ns3::empty, ns3::DefaultDeleter<ns3::Ipv6MulticastRoute> >'])
     register_Ns3SimpleRefCount__Ns3Ipv6Route_Ns3Empty_Ns3DefaultDeleter__lt__ns3Ipv6Route__gt___methods(root_module, root_module['ns3::SimpleRefCount< ns3::Ipv6Route, ns3::empty, ns3::DefaultDeleter<ns3::Ipv6Route> >'])
     register_Ns3SimpleRefCount__Ns3MeshWifiInterfaceMacPlugin_Ns3Empty_Ns3DefaultDeleter__lt__ns3MeshWifiInterfaceMacPlugin__gt___methods(root_module, root_module['ns3::SimpleRefCount< ns3::MeshWifiInterfaceMacPlugin, ns3::empty, ns3::DefaultDeleter<ns3::MeshWifiInterfaceMacPlugin> >'])
+    register_Ns3SimpleRefCount__Ns3NixVector_Ns3Empty_Ns3DefaultDeleter__lt__ns3NixVector__gt___methods(root_module, root_module['ns3::SimpleRefCount< ns3::NixVector, ns3::empty, ns3::DefaultDeleter<ns3::NixVector> >'])
     register_Ns3SimpleRefCount__Ns3OutputStreamWrapper_Ns3Empty_Ns3DefaultDeleter__lt__ns3OutputStreamWrapper__gt___methods(root_module, root_module['ns3::SimpleRefCount< ns3::OutputStreamWrapper, ns3::empty, ns3::DefaultDeleter<ns3::OutputStreamWrapper> >'])
     register_Ns3SimpleRefCount__Ns3Packet_Ns3Empty_Ns3DefaultDeleter__lt__ns3Packet__gt___methods(root_module, root_module['ns3::SimpleRefCount< ns3::Packet, ns3::empty, ns3::DefaultDeleter<ns3::Packet> >'])
     register_Ns3SimpleRefCount__Ns3PbbAddressBlock_Ns3Empty_Ns3DefaultDeleter__lt__ns3PbbAddressBlock__gt___methods(root_module, root_module['ns3::SimpleRefCount< ns3::PbbAddressBlock, ns3::empty, ns3::DefaultDeleter<ns3::PbbAddressBlock> >'])
@@ -1973,6 +1974,18 @@
                    is_static=True)
     return
 
+def register_Ns3SimpleRefCount__Ns3NixVector_Ns3Empty_Ns3DefaultDeleter__lt__ns3NixVector__gt___methods(root_module, cls):
+    ## simple-ref-count.h: ns3::SimpleRefCount<ns3::NixVector, ns3::empty, ns3::DefaultDeleter<ns3::NixVector> >::SimpleRefCount() [constructor]
+    cls.add_constructor([])
+    ## simple-ref-count.h: ns3::SimpleRefCount<ns3::NixVector, ns3::empty, ns3::DefaultDeleter<ns3::NixVector> >::SimpleRefCount(ns3::SimpleRefCount<ns3::NixVector, ns3::empty, ns3::DefaultDeleter<ns3::NixVector> > const & o) [copy constructor]
+    cls.add_constructor([param('ns3::SimpleRefCount< ns3::NixVector, ns3::empty, ns3::DefaultDeleter< ns3::NixVector > > const &', 'o')])
+    ## simple-ref-count.h: static void ns3::SimpleRefCount<ns3::NixVector, ns3::empty, ns3::DefaultDeleter<ns3::NixVector> >::Cleanup() [member function]
+    cls.add_method('Cleanup', 
+                   'void', 
+                   [], 
+                   is_static=True)
+    return
+
 def register_Ns3SimpleRefCount__Ns3OutputStreamWrapper_Ns3Empty_Ns3DefaultDeleter__lt__ns3OutputStreamWrapper__gt___methods(root_module, cls):
     ## simple-ref-count.h: ns3::SimpleRefCount<ns3::OutputStreamWrapper, ns3::empty, ns3::DefaultDeleter<ns3::OutputStreamWrapper> >::SimpleRefCount() [constructor]
     cls.add_constructor([])
--- a/src/common/nix-vector.cc	Mon Jul 19 22:37:44 2010 +0530
+++ b/src/common/nix-vector.cc	Mon Jul 19 14:21:12 2010 -0400
@@ -26,8 +26,6 @@
 
 namespace ns3 {
 
-NS_OBJECT_ENSURE_REGISTERED (NixVector);
-
 typedef std::vector<uint32_t> NixBits_t;
 
 NixVector::NixVector ()
@@ -46,15 +44,6 @@
   NS_LOG_FUNCTION_NOARGS ();
 }
 
-Ptr<NixVector>
-NixVector::Copy (void) const
-{
-  // we need to invoke the copy constructor directly
-  // rather than calling Create because the copy constructor
-  // is private.
-  return Ptr<NixVector> (new NixVector (*this), false);
-}
-
 NixVector::NixVector (const NixVector &o)
   : m_nixVector (o.m_nixVector),
     m_used (o.m_used),
@@ -76,17 +65,6 @@
   return *this;
 }
 
-TypeId
-NixVector::GetTypeId(void)
-{
-  static TypeId tid = TypeId ("ns3::NixVector")
-   .SetParent<Object> ()
-   .AddConstructor<NixVector> ()
-    ;
-
-  return tid;
-}
-
 std::ostream & operator << (std::ostream &os, const NixVector &nix)
 {
   nix.DumpNixVector (os); 
--- a/src/common/nix-vector.h	Mon Jul 19 22:37:44 2010 +0530
+++ b/src/common/nix-vector.h	Mon Jul 19 14:21:12 2010 -0400
@@ -21,7 +21,7 @@
 #ifndef __NIX_VECTOR_H__
 #define __NIX_VECTOR_H__
 
-#include "ns3/object.h"
+#include "ns3/simple-ref-count.h"
 #include "ns3/buffer.h"
 
 namespace ns3 {
@@ -59,15 +59,13 @@
  * routed.
  */
 
-class NixVector : public Object
+class NixVector : public SimpleRefCount<NixVector>
 {
   public:
     NixVector ();
+    ~NixVector ();
     NixVector (const NixVector &o);
-    ~NixVector ();
-    Ptr<NixVector> Copy (void) const;
     NixVector &operator = (const NixVector &o);
-    static TypeId GetTypeId (void);
     /**
      * \param newBits the neighbor-index to be added to the vector
      * \param numberOfBits the number of bits that newBits contains
--- a/src/common/packet.cc	Mon Jul 19 22:37:44 2010 +0530
+++ b/src/common/packet.cc	Mon Jul 19 14:21:12 2010 -0400
@@ -148,7 +148,7 @@
     m_packetTagList (o.m_packetTagList),
     m_metadata (o.m_metadata)
 {
-  o.m_nixVector ? m_nixVector = o.m_nixVector->Copy () 
+  o.m_nixVector ? m_nixVector = o.m_nixVector 
     : m_nixVector = 0;
 }
 
@@ -163,7 +163,7 @@
   m_byteTagList = o.m_byteTagList;
   m_packetTagList = o.m_packetTagList;
   m_metadata = o.m_metadata;
-  o.m_nixVector ? m_nixVector = o.m_nixVector->Copy () 
+  o.m_nixVector ? m_nixVector = o.m_nixVector 
     : m_nixVector = 0;
   return *this;
 }
@@ -739,7 +739,7 @@
 
   if (nixSize > 4)
     {
-      Ptr<NixVector> nix = CreateObject<NixVector> ();
+      Ptr<NixVector> nix = Create<NixVector> ();
       uint32_t nixDeserialized = nix->Deserialize (p, nixSize);
       if (!nixDeserialized)
         {
--- a/src/common/pcap-file-wrapper.h	Mon Jul 19 22:37:44 2010 +0530
+++ b/src/common/pcap-file-wrapper.h	Mon Jul 19 14:21:12 2010 -0400
@@ -24,6 +24,7 @@
 #include <fstream>
 #include "ns3/ptr.h"
 #include "ns3/packet.h"
+#include "ns3/object.h"
 #include "ns3/nstime.h"
 #include "pcap-file.h"
 
--- a/src/routing/nix-vector-routing/ipv4-nix-vector-routing.cc	Mon Jul 19 22:37:44 2010 +0530
+++ b/src/routing/nix-vector-routing/ipv4-nix-vector-routing.cc	Mon Jul 19 14:21:12 2010 -0400
@@ -121,7 +121,7 @@
 {
   NS_LOG_FUNCTION_NOARGS ();
 
-  Ptr<NixVector> nixVector = CreateObject<NixVector> ();
+  Ptr<NixVector> nixVector = Create<NixVector> ();
 
   // not in cache, must build the nix vector
   // First, we have to figure out the nodes 
@@ -509,8 +509,8 @@
 
       // create a new nix vector to be used, 
       // we want to keep the cached version clean
-      nixVectorForPacket = CreateObject<NixVector> ();
-      nixVectorForPacket = nixVectorInCache->Copy(); 
+      nixVectorForPacket = Create<NixVector> ();
+      nixVectorForPacket = nixVectorInCache; 
 
       // Get the interface number that we go out of, by extracting
       // from the nix-vector