Clean up parameter passing per TOm's request
This commit is contained in:
@@ -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
|
||||
|
||||
45
src/node/ref-counted-object.h
Normal file
45
src/node/ref-counted-object.h
Normal 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
|
||||
|
||||
Reference in New Issue
Block a user