ns3::Object Class Reference
[Object]

a base class which provides memory management and object aggregation More...

#include <object.h>

Inheritance diagram for ns3::Object:

Inheritance graph
[legend]
Collaboration diagram for ns3::Object:

Collaboration graph
[legend]

List of all members.

Classes

class  AggregateIterator
 Iterate over the objects aggregated to an ns3::Object. More...

Public Member Functions

virtual TypeId GetInstanceTypeId (void) const
void Ref (void) const
void Unref (void) const
uint32_t GetReferenceCount (void) const
template<typename T >
Ptr< T > GetObject (void) const
template<typename T >
Ptr< T > GetObject (TypeId tid) const
void Dispose (void)
void AggregateObject (Ptr< Object > other)
AggregateIterator GetAggregateIterator (void) const

Static Public Member Functions

static TypeId GetTypeId (void)
 This method returns the TypeId associated to ns3::Object.

Protected Member Functions

virtual void NotifyNewAggregate ()
virtual void DoDispose (void)
 Object (const Object &o)

Private Member Functions

void MaybeDelete (void) const
void SetTypeId (TypeId tid)
void Construct (const AttributeList &attributes)

Private Attributes

uint32_t m_count
TypeId m_tid
bool m_disposed
Objectm_next

Friends

template<typename T >
Ptr< T > CreateObjectWithAttributes (const AttributeList &attributes)
template<typename T >
Ptr< T > CopyObject (Ptr< T > object)
template<typename T >
Ptr< T > CopyObject (Ptr< const T > object)


Detailed Description

a base class which provides memory management and object aggregation

The memory management scheme is based on reference-counting with dispose-like functionality to break the reference cycles. The reference count is increamented and decremented with the methods Object::Ref and Object::Unref. If a reference cycle is present, the user is responsible for breaking it by calling Object::Dispose in a single location. This will eventually trigger the invocation of Object::DoDispose on itself and all its aggregates. The Object::DoDispose method is always automatically invoked from the Object::Unref method before destroying the object, even if the user did not call Object::Dispose directly.


Constructor & Destructor Documentation

ns3::Object::Object ( const Object o  )  [protected]

Parameters:
o the object to copy.
Allow subclasses to implement a copy constructor. While it is technically possible to implement a copy constructor in a subclass, we strongly discourage you to do so. If you really want to do it anyway, you have to understand that this copy constructor will _not_ copy aggregated objects. i.e., if your object instance is already aggregated to another object and if you invoke this copy constructor, the new object instance will be a pristine standlone object instance not aggregated to any other object. It is thus _your_ responsability as a caller of this method to do what needs to be done (if it is needed) to ensure that the object stays in a valid state.


Member Function Documentation

void ns3::Object::AggregateObject ( Ptr< Object other  ) 

Parameters:
other another object pointer
This method aggregates the two objects together: after this method returns, it becomes possible to call GetObject on one to get the other, and vice-versa.

void ns3::Object::Construct ( const AttributeList attributes  )  [private]

Parameters:
attributes the attribute values used to initialize the member variables of this object's instance.
Invoked from ns3::ObjectFactory::Create and ns3::CreateObject only. Initialize all the member variables which were registered with the associated TypeId.

void ns3::Object::Dispose ( void   ) 

Run the DoDispose methods of this object and all the objects aggregated to it. After calling this method, the object is expected to be totally unusable except for the Ref and Unref methods. It is an error to call Dispose twice on the same object instance.

This method is typically used to break reference cycles.

virtual void ns3::Object::DoDispose ( void   )  [protected, virtual]

AggregateIterator ns3::Object::GetAggregateIterator ( void   )  const

Returns:
an iterator to the first object aggregated to this object.
If no objects are aggregated to this object, then, the returned iterator will be empty and AggregateIterator::HasNext will always return false.

virtual TypeId ns3::Object::GetInstanceTypeId ( void   )  const [virtual]

Returns:
the TypeId associated to the most-derived type of this instance.
This method is typically implemented by ns3::Object::GetInstanceTypeId but some classes which derive from ns3::ObjectBase directly have to implement it themselves.

Implements ns3::ObjectBase.

template<typename T >
Ptr< T > ns3::Object::GetObject ( TypeId  tid  )  const [inline]

Parameters:
tid the interface id of the requested interface
Returns:
a pointer to the requested interface or zero if it could not be found.

template<typename T >
Ptr< T > ns3::Object::GetObject ( void   )  const [inline]

Returns:
a pointer to the requested interface or zero if it could not be found.

uint32_t ns3::Object::GetReferenceCount ( void   )  const

Get the reference count of the object. Normally not needed; for language bindings.

static TypeId ns3::Object::GetTypeId ( void   )  [static]

This method returns the TypeId associated to ns3::Object.

No Attributes defined for this type.
No TraceSources defined for this type.

Reimplemented from ns3::ObjectBase.

Reimplemented in ns3::OnOffApplication, ns3::PacketSink, ns3::UdpEchoClient, ns3::UdpEchoServer, ns3::ErrorModel, ns3::RateErrorModel, ns3::ListErrorModel, ns3::BridgeChannel, ns3::BridgeNetDevice, ns3::CsmaChannel, ns3::CsmaNetDevice, ns3::EmuNetDevice, ns3::PointToPointChannel, ns3::PointToPointNetDevice, ns3::TapBridge, ns3::VirtualNetDevice, ns3::AarfWifiManager, ns3::AarfcdWifiManager, ns3::AdhocWifiMac, ns3::AmrrWifiManager, ns3::ArfWifiManager, ns3::CaraWifiManager, ns3::ConstantRateWifiManager, ns3::DcaTxop, ns3::IdealWifiManager, ns3::JakesPropagationLossModel, ns3::MsduAggregator, ns3::NqapWifiMac, ns3::NqstaWifiMac, ns3::OnoeWifiManager, ns3::PropagationDelayModel, ns3::RandomPropagationDelayModel, ns3::ConstantSpeedPropagationDelayModel, ns3::PropagationLossModel, ns3::RandomPropagationLossModel, ns3::FriisPropagationLossModel, ns3::LogDistancePropagationLossModel, ns3::ThreeLogDistancePropagationLossModel, ns3::NakagamiPropagationLossModel, ns3::FixedRssLossModel, ns3::RraaWifiManager, ns3::WifiChannel, ns3::WifiMacQueue, ns3::WifiMac, ns3::WifiNetDevice, ns3::WifiPhy, ns3::WifiRemoteStationManager, ns3::YansErrorRateModel, ns3::YansWifiChannel, ns3::YansWifiPhy, ns3::ArpCache, ns3::ArpL3Protocol, ns3::Ipv4Interface, ns3::Ipv4L3Protocol, ns3::Ipv4L4Protocol, ns3::LoopbackNetDevice, ns3::NscTcpL4Protocol, ns3::NscTcpSocketImpl, ns3::TcpL4Protocol, ns3::TcpSocketImpl, ns3::UdpL4Protocol, ns3::UdpSocketImpl, ns3::ConstantAccelerationMobilityModel, ns3::ConstantPositionMobilityModel, ns3::ConstantVelocityMobilityModel, ns3::HierarchicalMobilityModel, ns3::MobilityModel, ns3::PositionAllocator, ns3::ListPositionAllocator, ns3::GridPositionAllocator, ns3::RandomRectanglePositionAllocator, ns3::RandomDiscPositionAllocator, ns3::RandomDirection2dMobilityModel, ns3::RandomWalk2dMobilityModel, ns3::RandomWaypointMobilityModel, ns3::Application, ns3::Channel, ns3::DropTailQueue, ns3::Ipv4RawSocketFactory, ns3::NetDevice, ns3::Node, ns3::PacketSocketFactory, ns3::PacketSocket, ns3::Queue, ns3::SimpleChannel, ns3::SimpleNetDevice, ns3::SocketFactory, ns3::TcpSocketFactory, ns3::TcpSocket, ns3::UdpSocketFactory, ns3::UdpSocket, ns3::rapidnet::Database, ns3::rapidnet::RapidNetApplicationBase, ns3::rapidnet::RelationBase, ns3::rapidnet::Relation, ns3::rapidnet::TempRelation, ns3::rapidnet::TupleAttribute, ns3::rapidnet::Tuple, ns3::GlobalRouter, ns3::Ipv4GlobalRouting, ns3::Ipv4ListRouting, ns3::Ipv4StaticRouting, ns3::CalendarScheduler, ns3::HeapScheduler, ns3::ListScheduler, ns3::MapScheduler, ns3::Ns2CalendarScheduler, ns3::Scheduler, and ns3::Synchronizer.

void ns3::Object::MaybeDelete ( void   )  const [private]

Attempt to delete this object. This method iterates over all aggregated objects to check if they all have a zero refcount. If yes, the object and all its aggregates are deleted. If not, nothing is done.

Referenced by Unref().

virtual void ns3::Object::NotifyNewAggregate (  )  [protected, virtual]

This function is called by the AggregateObject on all the objects connected in the listed chain. This way the new object aggregated will be used if needed by the NotifyNewAggregate corresponding to each object connected in the listed chain. It should be implemented by objects needing an additional/special behavior when aggregated to another object.

Reimplemented in ns3::ArpL3Protocol, ns3::Ipv4L3Protocol, ns3::NscTcpL4Protocol, ns3::TcpL4Protocol, and ns3::UdpL4Protocol.

void ns3::Object::Ref ( void   )  const [inline]

Increment the reference count. This method should not be called by user code. Object instances are expected to be used in conjunction of the Ptr template which would make calling Ref unecessary and dangerous.

References m_count.

void ns3::Object::SetTypeId ( TypeId  tid  )  [private]

Parameters:
tid an TypeId
Invoked from ns3::CreateObject only. Initialize the m_tid member variable to keep track of the type of this object instance.

void ns3::Object::Unref ( void   )  const [inline]

Decrement the reference count. This method should not be called by user code. Object instances are expected to be used in conjunction of the Ptr template which would make calling Ref unecessary and dangerous.

References m_count, MaybeDelete(), and NS_ASSERT.


Friends And Related Function Documentation

template<typename T >
Ptr<T> CopyObject ( Ptr< const T >  object  )  [friend]

Parameters:
object a pointer to the object to copy.
Returns:
a copy of the input object.
This method invoke the copy constructor of the input object and returns the new instance.

template<typename T >
Ptr<T> CopyObject ( Ptr< T >  object  )  [friend]

Parameters:
object a pointer to the object to copy.
Returns:
a copy of the input object.
This method invoke the copy constructor of the input object and returns the new instance.

template<typename T >
Ptr<T> CreateObjectWithAttributes ( const AttributeList attributes  )  [friend]

Parameters:
attributes a list of attributes to set on the object during construction.
Returns:
a pointer to a newly allocated object.
This allocates an object on the heap and initializes it with a set of attributes.


Member Data Documentation

uint32_t ns3::Object::m_count [mutable, private]

The reference count for this object. Each aggregate has an individual reference count. When the global reference count (the sum of all reference counts) reaches zero, the object and all its aggregates is deleted.

Reimplemented in ns3::UdpEchoClient, and ns3::TimeMinMaxAvgTotalCalculator.

Referenced by Ref(), and Unref().

bool ns3::Object::m_disposed [private]

Set to true when the DoDispose method of the object has run, false otherwise.

A pointer to the next aggregate object. This is a circular linked list of aggregated objects: the last one points back to the first one. If an object is not aggregated to any other object, the value of this field is equal to the value of the 'this' pointer.

Reimplemented in ns3::PropagationLossModel.

Identifies the type of this object instance.

Reimplemented in ns3::OnOffApplication, and ns3::PacketSink.


The documentation for this class was generated from the following files:

Generated on Fri Apr 9 15:01:08 2010 for NS-3 by  doxygen 1.5.8