a base class which provides memory management and object aggregation More...
#include <object.h>
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 | 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 |
Object * | m_next |
Friends | |
template<typename T > | |
Ptr< T > | CreateObject (const AttributeList &attributes) |
template<typename T > | |
Ptr< T > | CopyObject (Ptr< T > object) |
template<typename T > | |
Ptr< T > | CopyObject (Ptr< const T > object) |
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.
ns3::Object::Object | ( | const Object & | o | ) | [protected] |
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.
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] |
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] |
This method is called by Object::Dispose or by the object's destructor, whichever comes first.
Subclasses are expected to implement their real destruction code in an overriden version of this method and chain up to their parent's implementation once they are done. i.e., for simplicity, the destructor of every subclass should be empty and its content should be moved to the associated DoDispose method.
Reimplemented in ns3::OnOffApplication, ns3::PacketSink, ns3::UdpEchoClient, ns3::UdpEchoServer, ns3::TimeMinMaxAvgTotalCalculator, ns3::BridgeNetDevice, ns3::CsmaNetDevice, ns3::PointToPointNetDevice, ns3::AdhocWifiMac, ns3::DcaTxop, ns3::MacLow, ns3::NqapWifiMac, ns3::NqstaWifiMac, ns3::WifiNetDevice, ns3::WifiPhy, ns3::WifiRemoteStationManager, ns3::ArpCache, ns3::ArpIpv4Interface, ns3::ArpL3Protocol, ns3::Ipv4Interface, ns3::Ipv4L3Protocol, ns3::Ipv4StaticRouting, ns3::NscTcpSocketFactoryImpl, ns3::TcpL4Protocol, ns3::TcpSocketFactoryImpl, ns3::UdpL4Protocol, ns3::UdpSocketFactoryImpl, ns3::RandomDirection2dMobilityModel, ns3::RandomWalk2dMobilityModel, ns3::Application, ns3::Node, ns3::PacketSocket, ns3::SimpleNetDevice, and ns3::GlobalRouter.
AggregateIterator ns3::Object::GetAggregateIterator | ( | void | ) | const |
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] |
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.
Ptr< T > ns3::Object::GetObject | ( | void | ) | const |
tid | the interface id of the requested interface |
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::PointToPointChannel, ns3::PointToPointNetDevice, ns3::AarfWifiManager, ns3::AdhocWifiMac, ns3::AmrrWifiManager, ns3::ArfWifiManager, ns3::CompositePropagationLossModel, ns3::ConstantRateWifiManager, ns3::DcaTxop, ns3::IdealWifiManager, ns3::JakesPropagationLossModel, ns3::NqapWifiMac, ns3::NqstaWifiMac, ns3::OnoeWifiManager, ns3::PropagationDelayModel, ns3::RandomPropagationDelayModel, ns3::ConstantSpeedPropagationDelayModel, ns3::PropagationLossModel, ns3::RandomPropagationLossModel, ns3::FriisPropagationLossModel, ns3::LogDistancePropagationLossModel, ns3::RraaWifiManager, ns3::WifiChannel, ns3::WifiMacQueue, ns3::WifiMac, ns3::WifiNetDevice, ns3::WifiPhy, ns3::WifiRemoteStationManager, ns3::ArpCache, ns3::ArpIpv4Interface, ns3::ArpL3Protocol, ns3::Ipv4Interface, ns3::Ipv4L3Protocol, ns3::Ipv4L4Protocol, ns3::Ipv4LoopbackInterface, ns3::NscTcpSocketImpl, ns3::TcpL4Protocol, ns3::TcpSocketImpl, ns3::UdpL4Protocol, ns3::UdpSocketImpl, ns3::HierarchicalMobilityModel, ns3::MobilityModel, ns3::PositionAllocator, ns3::ListPositionAllocator, ns3::GridPositionAllocator, ns3::RandomRectanglePositionAllocator, ns3::RandomDiscPositionAllocator, ns3::RandomDirection2dMobilityModel, ns3::RandomWalk2dMobilityModel, ns3::RandomWaypointMobilityModel, ns3::StaticMobilityModel, ns3::StaticSpeedMobilityModel, ns3::Application, ns3::Channel, ns3::DropTailQueue, ns3::Ipv4, 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::GlobalRouter, ns3::olsr::Agent, 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.
void ns3::Object::Ref | ( | void | ) | const [inline] |
void ns3::Object::SetTypeId | ( | TypeId | tid | ) | [private] |
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] |
object | a pointer to the object to copy. |
This method invoke the copy constructor of the input object and returns the new instance.
object | a pointer to the object to copy. |
This method invoke the copy constructor of the input object and returns the new instance.
Ptr<T> CreateObject | ( | const AttributeList & | attributes | ) | [friend] |
attributes | a list of attributes to set on the object during construction. |
This allocates an object on the heap and initializes it with a set of attributes.
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.
bool ns3::Object::m_disposed [private] |
Set to true when the DoDispose method of the object has run, false otherwise.
Object* ns3::Object::m_next [private] |
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.
TypeId ns3::Object::m_tid [private] |
Identifies the type of this object instance.
Reimplemented in ns3::OnOffApplication, and ns3::PacketSink.