Clean up parameter passing per TOm's request

This commit is contained in:
George F. Riley
2007-03-22 14:54:20 -04:00
parent ac13b5523f
commit 8b9fb7b105
12 changed files with 115 additions and 27 deletions

View File

@@ -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.

View File

@@ -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),

View File

@@ -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);

View File

@@ -51,7 +51,7 @@ private:
public:
bool Attach(SerialChannel* ch);
void AddQueue(Queue *);
void AddQueue(Queue*);
// called by SerialPhy
void Receive (Packet& p);

View File

@@ -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

View File

@@ -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 <vector>
#include <list>
#include "ns3/smartvector.h"
#include "ns3/smartset.h"
namespace ns3 {
@@ -107,6 +98,9 @@ class NodeList;
class Node {
friend class NodeList;
friend class SmartVector<Node*>;
friend class SmartSet<Node*>;
public:
typedef SmartVector<Node*> 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

View File

@@ -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<riley@ece.gatech.edu>
// 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