From 8b9fb7b105d12e97375a24c5cded881ccbf272ce Mon Sep 17 00:00:00 2001 From: "George F. Riley" Date: Thu, 22 Mar 2007 14:54:20 -0400 Subject: [PATCH] Clean up parameter passing per TOm's request --- .sconf_temp/.cache | 9 +++++ .sconf_temp/conftest_0.c | 3 ++ .sconf_temp/conftest_1.c | 3 ++ build.pyc | Bin 0 -> 24535 bytes config.log | 22 ++++++++++++ src/common/smartvector.h | 3 +- src/devices/serial/serial-channel.cc | 10 +++--- src/devices/serial/serial-channel.h | 5 +-- src/devices/serial/serial-net-device.h | 2 +- src/devices/serial/serial-topology.h | 8 ++--- src/node/node.h | 32 +++++++++++------- src/node/ref-counted-object.h | 45 +++++++++++++++++++++++++ 12 files changed, 115 insertions(+), 27 deletions(-) create mode 100644 .sconf_temp/.cache create mode 100644 .sconf_temp/conftest_0.c create mode 100644 .sconf_temp/conftest_1.c create mode 100644 build.pyc create mode 100644 config.log create mode 100644 src/node/ref-counted-object.h 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 0000000000000000000000000000000000000000..5a0edb5287f73f4eda6d3343fe347361ecaf0cb4 GIT binary patch literal 24535 zcmc&++ix7#c|Wtf-$Y8JNKuj{M)HNSOwzUz$JfNX=@LsTg_KO0iMn0w49Ss}yX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$}4qt)xi6KuAB9mx7JrURf;yH87b#9?E?4__>*E z&f#vQ(vWQEew5yQb#iEr(?lj3&e|yFPyzS87bmm_uPPc41-|ViqEU?WEd}Zx&&2qb zCtrsT-lV0d&I4_hOuM~Pz|={Z^_*5vbyqCq!OeZw&ajT2MONG@j=_y-R7`SfnaFM-1l!pOnz3f%LMo-Rh(HpK#MYAb zY)@s?nT{4laT=Z5ccRM(#5q(v(#08FP$`8$vzo2A7C=zB_@x<2d;plIN2s58_0a*N^+rf5dwmy@tGF=szh(Ig@Pd;2H6tH-y>y z(4t2>W9T=;V;~uERt|wqVV(ih_G5X|sAM*4r9p&nUexHbXf)`Fzsqt$*nXRGaeGbYnFR}6H-yRaS zywu_@$2Ptf;%e!GB|l_jH{yniaT3I2y$D@5dsHYTb#{oUJ0?#s@VU_|eFJ^{P%Hj?SI21Y F{{u6wOC10J literal 0 HcmV?d00001 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 +