implement the ns-3 type and attribute system More...
#include <object-base.h>
Public Member Functions | |
virtual | ~ObjectBase () |
virtual TypeId | GetInstanceTypeId (void) const =0 |
void | SetAttribute (std::string name, const AttributeValue &value) |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
void | GetAttribute (std::string name, AttributeValue &value) const |
bool | GetAttributeFailSafe (std::string name, AttributeValue &attribute) const |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Static Public Member Functions | |
static TypeId | GetTypeId (void) |
This method returns the TypeId associated to ns3::ObjectBase. | |
Protected Member Functions | |
virtual void | NotifyConstructionCompleted (void) |
void | ConstructSelf (const AttributeList &attributes) |
Private Member Functions | |
bool | DoSet (Ptr< const AttributeAccessor > spec, Ptr< const AttributeChecker > checker, const AttributeValue &value) |
implement the ns-3 type and attribute system
Every class which wants to integrate in the ns-3 type and attribute system should derive from this base class. This base class provides:
Definition at line 54 of file object-base.h.
ns3::ObjectBase::~ObjectBase | ( | ) | [virtual] |
Definition at line 45 of file object-base.cc.
void ns3::ObjectBase::ConstructSelf | ( | const AttributeList & | attributes | ) | [protected] |
attributes | the attribute values used to initialize the member variables of this object's instance. |
Invoked from subclasses to initialize all of their attribute members. This method will typically be invoked automatically from ns3::CreateObject if your class derives from ns3::Object. If you derive from ns3::ObjectBase directly, you should make sure that you invoke this method from your most-derived constructor.
Definition at line 53 of file object-base.cc.
References ns3::TypeId::ATTR_CONSTRUCT, DoSet(), ns3::TypeId::GetAttributeAccessor(), ns3::TypeId::GetAttributeChecker(), ns3::TypeId::GetAttributeFlags(), ns3::TypeId::GetAttributeInitialValue(), ns3::TypeId::GetAttributeN(), ns3::TypeId::GetAttributeName(), ns3::AttributeList::GetGlobal(), GetInstanceTypeId(), ns3::TypeId::GetName(), ns3::TypeId::GetParent(), GetTypeId(), ns3::AttributeList::m_attributes, NotifyConstructionCompleted(), and NS_LOG_DEBUG.
Referenced by ns3::ConfigStore::ConfigStore(), and ns3::Object::Construct().
bool ns3::ObjectBase::DoSet | ( | Ptr< const AttributeAccessor > | spec, | |
Ptr< const AttributeChecker > | checker, | |||
const AttributeValue & | value | |||
) | [private] |
Definition at line 117 of file object-base.cc.
References ns3::StringValue::Get().
Referenced by ConstructSelf(), SetAttribute(), and SetAttributeFailSafe().
void ns3::ObjectBase::GetAttribute | ( | std::string | name, | |
AttributeValue & | value | |||
) | const |
name | the name of the attribute to read | |
value | a reference to the value where the result should be stored. |
If the input attribute name does not exist, this method crashes.
Definition at line 185 of file object-base.cc.
References ns3::TypeId::AttributeInfo::accessor, ns3::TypeId::ATTR_GET, ns3::TypeId::AttributeInfo::checker, ns3::TypeId::AttributeInfo::flags, GetInstanceTypeId(), NS_FATAL_ERROR, ns3::PeekPointer(), and ns3::StringValue::Set().
Referenced by ns3::Packet::Print().
bool ns3::ObjectBase::GetAttributeFailSafe | ( | std::string | name, | |
AttributeValue & | attribute | |||
) | const |
name | the name of the attribute to read | |
attribute | the attribute where the result value should be stored |
If the input attribute name does not exist, this method crashes.
Definition at line 219 of file object-base.cc.
References ns3::TypeId::AttributeInfo::accessor, ns3::TypeId::ATTR_GET, ns3::TypeId::AttributeInfo::checker, ns3::TypeId::AttributeInfo::flags, GetInstanceTypeId(), ns3::PeekPointer(), and ns3::StringValue::Set().
virtual TypeId ns3::ObjectBase::GetInstanceTypeId | ( | void | ) | const [pure virtual] |
This method is typically implemented by ns3::Object::GetInstanceTypeId but some classes which derive from ns3::ObjectBase directly have to implement it themselves.
Implemented in anonymous_namespace{packet-metadata-test.cc}::HistoryHeader< N >, anonymous_namespace{packet-metadata-test.cc}::HistoryTrailer< N >, anonymous_namespace{packet.cc}::ATestTag< N >, anonymous_namespace{packet.cc}::ATestHeader< N >, anonymous_namespace{packet.cc}::ATestTrailer< N >, ns3::ConfigStore, ns3::DelayJitterEstimationTimestampTag, ns3::FlowIdTag, ns3::Object, ns3::PppHeader, ns3::SnrTag, ns3::MgtAssocRequestHeader, ns3::MgtAssocResponseHeader, ns3::MgtProbeRequestHeader, ns3::MgtProbeResponseHeader, ns3::WifiMacHeader, ns3::WifiMacTrailer, ns3::WifiPhyTxTag, ns3::WifiPhyRxTag, ns3::TxModeTag, ns3::ArpHeader, ns3::Icmpv4Header, ns3::Icmpv4Echo, ns3::Icmpv4DestinationUnreachable, ns3::Icmpv4TimeExceeded, ns3::Ns3NscStack, ns3::TcpHeader, ns3::UdpHeader, ns3::EthernetHeader, ns3::EthernetTrailer, ns3::Ipv4Header, ns3::Ipv6Header, ns3::LlcSnapHeader, ns3::SocketAddressTag, ns3::SocketIpTtlTag, ns3::SocketSetDontFragmentTag, ns3::olsr::PacketHeader, and ns3::olsr::MessageHeader.
Referenced by ns3::PacketMetadata::AddHeader(), ns3::Packet::AddTag(), ns3::PacketMetadata::AddTrailer(), ConstructSelf(), ns3::Packet::FindFirstMatchingTag(), GetAttribute(), GetAttributeFailSafe(), ns3::TagIterator::Item::GetTag(), ns3::PacketMetadata::RemoveHeader(), ns3::PacketMetadata::RemoveTrailer(), SetAttribute(), SetAttributeFailSafe(), TraceConnect(), TraceConnectWithoutContext(), TraceDisconnect(), and TraceDisconnectWithoutContext().
TypeId ns3::ObjectBase::GetTypeId | ( | void | ) | [static] |
This method returns the TypeId associated to ns3::ObjectBase.
No Attributes defined for this type.
No TraceSources defined for this type.
Reimplemented in ns3::OnOffApplication, ns3::PacketSink, ns3::UdpEchoClient, ns3::UdpEchoServer, ns3::V4Ping, ns3::Chunk, ns3::ErrorModel, ns3::RateErrorModel, ns3::ListErrorModel, ns3::Header, anonymous_namespace{packet-metadata-test.cc}::HistoryHeaderBase, anonymous_namespace{packet-metadata-test.cc}::HistoryHeader< N >, anonymous_namespace{packet-metadata-test.cc}::HistoryTrailerBase, anonymous_namespace{packet-metadata-test.cc}::HistoryTrailer< N >, anonymous_namespace{packet.cc}::ATestTag< N >, anonymous_namespace{packet.cc}::ATestHeader< N >, anonymous_namespace{packet.cc}::ATestTrailer< N >, ns3::Tag, ns3::Trailer, ns3::ConfigStore, ns3::DelayJitterEstimationTimestampTag, ns3::FlowIdTag, ns3::Derived, ns3::AttributeObjectTest, ns3::MyNode, anonymous_namespace{object.cc}::BaseA, anonymous_namespace{object.cc}::DerivedA, anonymous_namespace{object.cc}::BaseB, anonymous_namespace{object.cc}::DerivedB, ns3::Object, ns3::BridgeChannel, ns3::BridgeNetDevice, ns3::CsmaChannel, ns3::CsmaNetDevice, ns3::EmuNetDevice, ns3::PointToPointChannel, ns3::PointToPointNetDevice, ns3::PppHeader, ns3::AarfWifiManager, ns3::AdhocWifiMac, ns3::AmrrWifiManager, ns3::ArfWifiManager, ns3::ConstantRateWifiManager, ns3::DcaTxop, ns3::ErrorRateModel, ns3::IdealWifiManager, ns3::JakesPropagationLossModel, ns3::SnrTag, ns3::MgtAssocRequestHeader, ns3::MgtAssocResponseHeader, ns3::MgtProbeRequestHeader, ns3::MgtProbeResponseHeader, ns3::NqapWifiMac, ns3::NqstaWifiMac, ns3::Ns2ExtWifiChannel, ns3::Ns2ExtWifiPhyStateHelper, ns3::Ns2ExtWifiPhy, ns3::OnoeWifiManager, ns3::PropagationDelayModel, ns3::RandomPropagationDelayModel, ns3::ConstantSpeedPropagationDelayModel, ns3::PropagationLossModel, ns3::RandomPropagationLossModel, ns3::FriisPropagationLossModel, ns3::LogDistancePropagationLossModel, ns3::ThreeLogDistancePropagationLossModel, ns3::NakagamiPropagationLossModel, ns3::RraaWifiManager, ns3::WifiChannel, ns3::WifiMacHeader, ns3::WifiMacQueue, ns3::WifiMacTrailer, ns3::WifiMac, ns3::WifiNetDevice, ns3::WifiPhyTxTag, ns3::WifiPhyRxTag, ns3::WifiPhy, ns3::TxModeTag, ns3::WifiRemoteStationManager, ns3::YansErrorRateModel, ns3::YansWifiChannel, ns3::YansWifiPhyStateHelper, ns3::YansWifiPhy, ns3::ArpCache, ns3::ArpHeader, ns3::ArpIpv4Interface, ns3::ArpL3Protocol, ns3::Icmpv4L4Protocol, ns3::Icmpv4Header, ns3::Icmpv4Echo, ns3::Icmpv4DestinationUnreachable, ns3::Icmpv4TimeExceeded, ns3::Ipv4GlobalRouting, ns3::Ipv4Interface, ns3::Ipv4L3Protocol, ns3::Ipv4L4Protocol, ns3::Ipv4LoopbackInterface, ns3::Ipv4RawSocketImpl, ns3::Ns3NscStack, ns3::NscTcpL4Protocol, ns3::NscTcpSocketImpl, ns3::RttEstimator, ns3::RttMeanDeviation, ns3::TcpHeader, ns3::TcpL4Protocol, ns3::TcpSocketImpl, ns3::UdpHeader, 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::EthernetHeader, ns3::EthernetTrailer, ns3::Ipv4Header, ns3::Ipv4RawSocketFactory, ns3::Ipv4, ns3::Ipv6Header, ns3::LlcSnapHeader, ns3::NetDevice, ns3::NodeListPriv, ns3::Node, ns3::PacketSocketFactory, ns3::PacketSocket, ns3::Queue, ns3::SimpleChannel, ns3::SimpleNetDevice, ns3::SocketFactory, ns3::SocketAddressTag, ns3::SocketIpTtlTag, ns3::SocketSetDontFragmentTag, ns3::TcpSocketFactory, ns3::TcpSocket, ns3::UdpSocketFactory, ns3::UdpSocket, ns3::GlobalRouter, ns3::olsr::AgentImpl, ns3::olsr::Agent, ns3::olsr::PacketHeader, ns3::olsr::MessageHeader, ns3::CalendarScheduler, ns3::DefaultSimulatorImpl, ns3::HeapScheduler, ns3::ListScheduler, ns3::MapScheduler, ns3::RealtimeSimulatorImpl, ns3::Scheduler, and ns3::Synchronizer.
Definition at line 39 of file object-base.cc.
References ns3::GetObjectIid().
Referenced by ConstructSelf().
void ns3::ObjectBase::NotifyConstructionCompleted | ( | void | ) | [protected, virtual] |
This method is invoked once all member attributes have been initialized. Subclasses can override this method to be notified of this event but if they do this, they must chain up to their parent's NotifyConstructionCompleted method.
Definition at line 49 of file object-base.cc.
Referenced by ConstructSelf().
void ns3::ObjectBase::SetAttribute | ( | std::string | name, | |
const AttributeValue & | value | |||
) |
name | the name of the attribute to set | |
value | the name of the attribute to set |
Set a single attribute. This cannot fail: if the input is invalid, it will crash immediately.
Definition at line 149 of file object-base.cc.
References ns3::TypeId::AttributeInfo::accessor, ns3::TypeId::ATTR_SET, ns3::TypeId::AttributeInfo::checker, DoSet(), ns3::TypeId::AttributeInfo::flags, GetInstanceTypeId(), and NS_FATAL_ERROR.
bool ns3::ObjectBase::SetAttributeFailSafe | ( | std::string | name, | |
const AttributeValue & | value | |||
) |
name | the name of the attribute to set | |
value | the name of the attribute to set |
Definition at line 168 of file object-base.cc.
References ns3::TypeId::AttributeInfo::accessor, ns3::TypeId::ATTR_SET, ns3::TypeId::AttributeInfo::checker, DoSet(), ns3::TypeId::AttributeInfo::flags, and GetInstanceTypeId().
bool ns3::ObjectBase::TraceConnect | ( | std::string | name, | |
std::string | context, | |||
const CallbackBase & | cb | |||
) |
name | the name of the targetted trace source | |
context | the trace context associated to the callback | |
cb | the callback to connect to the trace source. |
The targetted trace source should be registered with TypeId::AddTraceSource.
Definition at line 265 of file object-base.cc.
References GetInstanceTypeId(), and ns3::TypeId::LookupTraceSourceByName().
bool ns3::ObjectBase::TraceConnectWithoutContext | ( | std::string | name, | |
const CallbackBase & | cb | |||
) |
name | the name of the targetted trace source | |
cb | the callback to connect to the trace source. |
The targetted trace source should be registered with TypeId::AddTraceSource.
Definition at line 253 of file object-base.cc.
References GetInstanceTypeId(), and ns3::TypeId::LookupTraceSourceByName().
bool ns3::ObjectBase::TraceDisconnect | ( | std::string | name, | |
std::string | context, | |||
const CallbackBase & | cb | |||
) |
name | the name of the targetted trace source | |
context | the trace context associated to the callback | |
cb | the callback to disconnect from the trace source. |
The targetted trace source should be registered with TypeId::AddTraceSource.
Definition at line 289 of file object-base.cc.
References GetInstanceTypeId(), and ns3::TypeId::LookupTraceSourceByName().
bool ns3::ObjectBase::TraceDisconnectWithoutContext | ( | std::string | name, | |
const CallbackBase & | cb | |||
) |
name | the name of the targetted trace source | |
cb | the callback to disconnect from the trace source. |
The targetted trace source should be registered with TypeId::AddTraceSource.
Definition at line 277 of file object-base.cc.
References GetInstanceTypeId(), and ns3::TypeId::LookupTraceSourceByName().