#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 | 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 |
Object * | m_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) |
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. |
other | another object pointer |
void ns3::Object::Construct | ( | const AttributeList & | attributes | ) | [private] |
attributes | the attribute values used to initialize the member variables of this object's instance. |
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::EmuNetDevice, ns3::PointToPointNetDevice, ns3::TapBridge, ns3::VirtualNetDevice, ns3::AdhocWifiMac, ns3::DcaTxop, ns3::MacLow, ns3::NqapWifiMac, ns3::NqstaWifiMac, ns3::WifiNetDevice, ns3::WifiRemoteStationManager, ns3::YansWifiPhy, ns3::ArpCache, ns3::ArpL3Protocol, ns3::Ipv4Interface, ns3::Ipv4L3Protocol, ns3::LoopbackNetDevice, ns3::NscTcpL4Protocol, ns3::NscTcpSocketFactoryImpl, ns3::TcpL4Protocol, ns3::TcpSocketFactoryImpl, ns3::UdpL4Protocol, ns3::UdpSocketFactoryImpl, ns3::RandomDirection2dMobilityModel, ns3::RandomWalk2dMobilityModel, ns3::Application, ns3::Node, ns3::PacketSocket, ns3::SimpleNetDevice, ns3::Socket, ns3::rapidnet::RapidNetApplicationBase, ns3::GlobalRouter, ns3::Ipv4GlobalRouting, ns3::Ipv4ListRouting, and ns3::Ipv4StaticRouting.
AggregateIterator ns3::Object::GetAggregateIterator | ( | void | ) | const |
virtual TypeId ns3::Object::GetInstanceTypeId | ( | void | ) | const [virtual] |
Implements ns3::ObjectBase.
tid | the interface id of the requested interface |
Ptr< T > ns3::Object::GetObject | ( | void | ) | const [inline] |
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] |
void ns3::Object::SetTypeId | ( | TypeId | tid | ) | [private] |
tid | an TypeId |
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.
object | a pointer to the object to copy. |
object | a pointer to the object to copy. |
Ptr<T> CreateObjectWithAttributes | ( | const AttributeList & | attributes | ) | [friend] |
attributes | a list of attributes to set on the object during construction. |
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.
Reimplemented in ns3::PropagationLossModel.
TypeId ns3::Object::m_tid [private] |
Identifies the type of this object instance.
Reimplemented in ns3::OnOffApplication, and ns3::PacketSink.