diff --git a/.sconf_temp/.cache b/.sconf_temp/.cache new file mode 100644 index 000000000..81c062c51 --- /dev/null +++ b/.sconf_temp/.cache @@ -0,0 +1,9 @@ +(dp1 +S'data' +p2 +(dp3 +sS'scons_version' +p4 +S'0.96.1' +p5 +s. \ No newline at end of file diff --git a/.sconf_temp/conftest_0.c b/.sconf_temp/conftest_0.c new file mode 100644 index 000000000..e1e0b39fd --- /dev/null +++ b/.sconf_temp/conftest_0.c @@ -0,0 +1,3 @@ + +#include "stdlib.h" + diff --git a/.sconf_temp/conftest_1.c b/.sconf_temp/conftest_1.c new file mode 100644 index 000000000..c0c823d8c --- /dev/null +++ b/.sconf_temp/conftest_1.c @@ -0,0 +1,3 @@ + +#include "stdint.h" + diff --git a/build.pyc b/build.pyc new file mode 100644 index 000000000..5a0edb528 Binary files /dev/null and b/build.pyc differ diff --git a/config.log b/config.log new file mode 100644 index 000000000..5e6cd0a55 --- /dev/null +++ b/config.log @@ -0,0 +1,22 @@ + +file /Users/riley/lib/scons/SCons/Environment.py,line 1019: + Configure( confdir = .sconf_temp ) + +Checking for C header file stdlib.h... .sconf_temp/conftest_0.c <- + | + |#include "stdlib.h" + | + | +gcc -c -o .sconf_temp/conftest_0.o .sconf_temp/conftest_0.c +yes + +file /Users/riley/lib/scons/SCons/Environment.py,line 1019: + Configure( confdir = .sconf_temp ) + +Checking for C header file stdint.h... .sconf_temp/conftest_1.c <- + | + |#include "stdint.h" + | + | +gcc -c -o .sconf_temp/conftest_1.o .sconf_temp/conftest_1.c +yes diff --git a/src/common/smartvector.h b/src/common/smartvector.h index db72975e6..fc76b19dc 100644 --- a/src/common/smartvector.h +++ b/src/common/smartvector.h @@ -29,7 +29,8 @@ namespace ns3 { // Define a "smart" vector container to be used by any ns3 object // maintaining a collection of pointers, which must be freed at // a later time. The template parameter T must be a pointer, or an -// object supporting the delete operator. The vector implementation +// object supporting the delete operator, and the dereferenced object +// must support the Copy() operation. The vector implementation // has in inefficient "Remove" operation, that removes and deletes // a single element in the container. If frequent "Remove" operations // are needed, the SmartSet is likey a better choice. diff --git a/src/devices/serial/serial-channel.cc b/src/devices/serial/serial-channel.cc index ece101dbd..2c4945bbc 100644 --- a/src/devices/serial/serial-channel.cc +++ b/src/devices/serial/serial-channel.cc @@ -46,8 +46,8 @@ SerialChannel::SerialChannel() } SerialChannel::SerialChannel( - DataRate bps, - Time delay) + const DataRate& bps, + const Time& delay) : Channel ("Serial Channel"), m_bps (bps), @@ -59,9 +59,9 @@ SerialChannel::SerialChannel( } SerialChannel::SerialChannel( - std::string name, - DataRate bps, - Time delay) + const std::string& name, + const DataRate& bps, + const Time& delay) : Channel (name), m_bps (bps), diff --git a/src/devices/serial/serial-channel.h b/src/devices/serial/serial-channel.h index a4400ed7f..af809322a 100644 --- a/src/devices/serial/serial-channel.h +++ b/src/devices/serial/serial-channel.h @@ -59,8 +59,9 @@ public: static const int N_DEVICES = 2; SerialChannel (); - SerialChannel (DataRate bps, Time delay); - SerialChannel (std::string name, DataRate bps, Time delay); + SerialChannel (const DataRate& bps, const Time& delay); + SerialChannel (const std::string& name, + const DataRate& bps, const Time& delay); void Attach (SerialPhy* phy); bool Propagate (Packet& p, SerialPhy *src); diff --git a/src/devices/serial/serial-net-device.h b/src/devices/serial/serial-net-device.h index 59f901e65..f3f4cf921 100644 --- a/src/devices/serial/serial-net-device.h +++ b/src/devices/serial/serial-net-device.h @@ -51,7 +51,7 @@ private: public: bool Attach(SerialChannel* ch); - void AddQueue(Queue *); + void AddQueue(Queue*); // called by SerialPhy void Receive (Packet& p); diff --git a/src/devices/serial/serial-topology.h b/src/devices/serial/serial-topology.h index 1c5cbf13b..eb13615bc 100644 --- a/src/devices/serial/serial-topology.h +++ b/src/devices/serial/serial-topology.h @@ -30,7 +30,7 @@ namespace ns3 { class SerialChannel; class Node; -class IpvrAddress; +class IPAddr; //class SerialNetDevice; //class Queue; //class Rate; @@ -44,13 +44,12 @@ public: // with the specified IP addresses, with specified maximum transmission rate // and propagation delay. static SerialChannel* AddSerialLink( - Node*, const Ipv4Address&, - Node*, const Ipv4Address&, + Node*, const IPAddr&, + Node*, const IPAddr&, // const Rate&, uint64_t, const Time&); -#if 0 // Get the connecting node n1 to node n2 static Channel* GetChannel(Node*, Node*); // Get the NetDevice connecting node n1 to n2 @@ -59,7 +58,6 @@ public: static Queue* GetQueue(Node*, Node*); // Set the queue associated with a link between two nodes static Queue* SetQueue(Node*, Node*, const Queue&); -#endif }; } // namespace ns3 diff --git a/src/node/node.h b/src/node/node.h index f347b5e77..483183ed8 100644 --- a/src/node/node.h +++ b/src/node/node.h @@ -58,17 +58,7 @@ // 3) If needed, implement a destructor. Again, this is typically only // needed if you use dynamic memory. // 4) Implement a Copy() method that returns a copy of your capability. -// 5) Where possible Create a "Null" capability subclass of your capability -// that does nothing. For example, the basic energy model provides the -// NullEnergyModel that is returned by the node base class "GetEnergyModel()" -// call when the energy model does not exist. This Null capability of course -// has the same API as all energy models, but does nothing. THis allows -// users of the energy model to use the pointer returned by GetEnergyModel() -// without having to check for the nil return. -// 6) Implement a static GetNullCapability() method that returns either a -// pointer to the Null capability (see 5 above) of a nil pointer if no -// null capability exists. -// 7) Implement a "Get*" virtual method in the node base that returns +// 5) Implement a "Get*" virtual method in the node base that returns // the null capability. // // To implement a variation on an existing capability, perform @@ -85,13 +75,14 @@ // and those modifying ns3 for their own uses are encouraged to subclass // an existing capability where possible. -#ifndef NODE_H -#define NODE_H +#ifndef __NODE_H__ +#define __NODE_H__ #include #include #include "ns3/smartvector.h" +#include "ns3/smartset.h" namespace ns3 { @@ -107,6 +98,9 @@ class NodeList; class Node { friend class NodeList; +friend class SmartVector; +friend class SmartSet; + public: typedef SmartVector SmartNodeVec_t; Node(); @@ -120,6 +114,18 @@ public: uint32_t GetSystemId (void) const; void SetSystemId(uint32_t s); +#ifdef REMOVE_FOR_NOW + // Define a protected delete operator. This will prevent users + // from attempting to delete Node objects. The deletion of + // Nodes is completely the responsibility of the Node class, + // and in no case should be deleted by users. +protected: + void operator delete(void* a) + { // Just call the normal delete + ::delete (Node*)a; + } +#endif +public: // Static methods for creating nodes and managing the node stack // Create a new node. The node will be a copy of the top of the diff --git a/src/node/ref-counted-object.h b/src/node/ref-counted-object.h new file mode 100644 index 000000000..3442fca8f --- /dev/null +++ b/src/node/ref-counted-object.h @@ -0,0 +1,45 @@ +// -*- Mode:NS3 -*- +// +// Copyright (c) 2006 Georgia Tech Research Corporation +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// Author: George F. Riley +// Based on original class declaration by Mathieu Lacage +// + +#ifndef __REF_COUNTED_OBJECT__ +#define __REF_COUNTED_OBJECT__ + +class RefCountedObject +{ +public: + RefCountedObject() : m_count(1) {} + virtual ~RefCountedObject() {} + + void Ref() + { + m_count++; + } + + void Unref() + { + if (!--m_count) delete this; // Refcount to zero, delete + } +private: + uint32_t m_count; +}; +#endif +