Anchor the ns-3 type and attribute system. More...
#include "object-base.h"
Public Member Functions | |
virtual | ~ObjectBase () |
Virtual destructor. | |
void | GetAttribute (std::string name, AttributeValue &value, bool permissive=false) const |
Get the value of an attribute, raising fatal errors if unsuccessful. | |
bool | GetAttributeFailSafe (std::string name, AttributeValue &value) const |
Get the value of an attribute without raising errors. | |
virtual TypeId | GetInstanceTypeId () const =0 |
Get the most derived TypeId for this Object. | |
void | SetAttribute (std::string name, const AttributeValue &value) |
Set a single attribute, raising fatal errors if unsuccessful. | |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
Set a single attribute without raising errors. | |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
Connect a TraceSource to a Callback with a context. | |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
Connect a TraceSource to a Callback without a context. | |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected with a context. | |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected without a context. | |
Static Public Member Functions | |
static TypeId | GetTypeId () |
Get the type ID. | |
Protected Member Functions | |
void | ConstructSelf (const AttributeConstructionList &attributes) |
Complete construction of ObjectBase; invoked by derived classes. | |
virtual void | NotifyConstructionCompleted () |
Notifier called once the ObjectBase is fully constructed. | |
Private Member Functions | |
bool | DoSet (Ptr< const AttributeAccessor > spec, Ptr< const AttributeChecker > checker, const AttributeValue &value) |
Attempt to set the value referenced by the accessor spec to a valid value according to the checker , based on value . | |
Related Symbols | |
(Note that these are not member symbols.) | |
static TypeId | GetObjectIid () |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. | |
Anchor 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 161 of file object-base.h.
|
virtual |
|
protected |
Complete construction of ObjectBase; invoked by derived classes.
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.
[in] | attributes | The attribute values used to initialize the member variables of this object's instance. |
Definition at line 81 of file object-base.cc.
References ns3::TypeId::AttributeInformation::accessor, ns3::TypeId::ATTR_CONSTRUCT, ns3::TypeId::AttributeInformation::checker, ns3::Create(), DoSet(), ns3::AttributeConstructionList::Find(), ns3::TypeId::AttributeInformation::flags, ns3::EnvironmentVariable::Get(), ns3::TypeId::GetAttribute(), ns3::TypeId::GetAttributeFullName(), ns3::TypeId::GetAttributeN(), GetInstanceTypeId(), ns3::TypeId::GetName(), ns3::TypeId::GetParent(), GetTypeId(), ns3::TypeId::AttributeInformation::initialValue, ns3::TypeId::AttributeInformation::name, NotifyConstructionCompleted(), NS_FATAL_ERROR, NS_LOG_DEBUG, and NS_LOG_FUNCTION.
Referenced by ns3::ConfigStore::ConfigStore(), ns3::EmuEpcHelper::EmuEpcHelper(), ns3::EpsBearer::EpsBearer(), ns3::EpsBearer::EpsBearer(), ns3::EpsBearer::EpsBearer(), ns3::EpsBearer::EpsBearer(), ns3::NoBackhaulEpcHelper::NoBackhaulEpcHelper(), ns3::PointToPointEpcHelper::PointToPointEpcHelper(), ns3::RttEstimator::RttEstimator(), and ns3::Object::Construct().
|
private |
Attempt to set the value referenced by the accessor spec to a valid value according to the checker
, based on value .
[in] | spec | The accessor for the storage location. |
[in] | checker | The checker to use in validating the value. |
[in] | value | The value to attempt to store. |
true
if the value
could be validated by the checker and written to the storage location. Definition at line 185 of file object-base.cc.
References NS_LOG_FUNCTION.
Referenced by ConstructSelf(), SetAttribute(), and SetAttributeFailSafe().
void ns3::ObjectBase::GetAttribute | ( | std::string | name, |
AttributeValue & | value, | ||
bool | permissive = false ) const |
Get the value of an attribute, raising fatal errors if unsuccessful.
This will either succeed at setting the attribute or it will raise NS_FATAL_ERROR() on these conditions:
[in] | name | The name of the attribute to read. |
[out] | value | Where the result should be stored. |
[in] | permissive | If false (by default), will generate warnings and errors for deprecated and obsolete attributes, respectively. If set to true, warnings for deprecated attributes will be suppressed. |
Definition at line 240 of file object-base.cc.
References ns3::TypeId::AttributeInformation::accessor, ns3::TypeId::ATTR_GET, ns3::TypeId::AttributeInformation::checker, ns3::TypeId::AttributeInformation::flags, GetInstanceTypeId(), ns3::TypeId::GetName(), ns3::TypeId::LookupAttributeByName(), NS_FATAL_ERROR, NS_LOG_FUNCTION, and ns3::PeekPointer().
Referenced by ns3::cell_data_function_col_1(), ns3::cell_tooltip_callback(), ns3::Packet::Print(), and SpectrumWifiPhyTrackedBandsTest::VerifyTrackedBands().
bool ns3::ObjectBase::GetAttributeFailSafe | ( | std::string | name, |
AttributeValue & | value ) const |
Get the value of an attribute without raising errors.
If the attribute could not be read this will return false
, but not raise any errors.
[in] | name | The name of the attribute to read. |
[out] | value | Where the result value should be stored. |
true
if the requested attribute was found, false
otherwise. Definition at line 277 of file object-base.cc.
References ns3::TypeId::AttributeInformation::accessor, ns3::TypeId::ATTR_GET, ns3::TypeId::AttributeInformation::checker, ns3::TypeId::AttributeInformation::flags, GetInstanceTypeId(), ns3::TypeId::LookupAttributeByName(), NS_LOG_FUNCTION, and ns3::PeekPointer().
|
pure virtual |
Get the most derived TypeId for this Object.
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-test-suite.cc}::ALargeTestTag, anonymous_namespace{packet-test-suite.cc}::ATestHeader< N >, anonymous_namespace{packet-test-suite.cc}::ATestTag< N >, anonymous_namespace{packet-test-suite.cc}::ATestTrailer< N >, anonymous_namespace{sequence-number-test-suite.cc}::SequenceNumberTestObj, BenchHeader< N >, BenchTag< N >, IPv4TestTag, IPv6TestTag, MyHeader, MyTag, ns3::AlohaNoackMacHeader, ns3::AmpduSubframeHeader, ns3::AmpduTag, ns3::AmsduSubframeHeader, ns3::AnimByteTag, ns3::aodv::DeferredRouteOutputTag, ns3::aodv::RerrHeader, ns3::aodv::RrepAckHeader, ns3::aodv::RrepHeader, ns3::aodv::RreqHeader, ns3::aodv::TypeHeader, ns3::ArpHeader, ns3::Asn1Header, ns3::BandwidthRequestHeader, ns3::ConfigStore, ns3::CtrlBAckRequestHeader, ns3::CtrlBAckResponseHeader, ns3::CtrlTriggerHeader, ns3::Dcd, ns3::DeviceNameTag, ns3::DhcpHeader, ns3::DlMap, ns3::dot11s::HwmpTag, ns3::dot11s::MeshHeader, ns3::dot11s::PeerLinkCloseStart, ns3::dot11s::PeerLinkConfirmStart, ns3::dot11s::PeerLinkOpenStart, ns3::DsaAck, ns3::DsaReq, ns3::DsaRsp, ns3::dsdv::DeferredRouteOutputTag, ns3::dsdv::DsdvHeader, ns3::dsr::DsrFsHeader, ns3::dsr::DsrOptionAck, ns3::dsr::DsrOptionAckHeader, ns3::dsr::DsrOptionAckReq, ns3::dsr::DsrOptionAckReqHeader, ns3::dsr::DsrOptionHeader, ns3::dsr::DsrOptionPad1Header, ns3::dsr::DsrOptionPadnHeader, ns3::dsr::DsrOptionRerr, ns3::dsr::DsrOptionRerrHeader, ns3::dsr::DsrOptionRerrUnreachHeader, ns3::dsr::DsrOptionRerrUnsupportedHeader, ns3::dsr::DsrOptionRrep, ns3::dsr::DsrOptionRrepHeader, ns3::dsr::DsrOptionRreq, ns3::dsr::DsrOptionRreqHeader, ns3::dsr::DsrOptionSR, ns3::dsr::DsrOptionSRHeader, ns3::dsr::DsrRoutingHeader, ns3::EmuEpcHelper, ns3::EpcX2HandoverCancelHeader, ns3::EpcX2HandoverPreparationFailureHeader, ns3::EpcX2HandoverRequestAckHeader, ns3::EpcX2HandoverRequestHeader, ns3::EpcX2Header, ns3::EpcX2LoadInformationHeader, ns3::EpcX2ResourceStatusUpdateHeader, ns3::EpcX2SnStatusTransferHeader, ns3::EpcX2UeContextReleaseHeader, ns3::EpsBearer, ns3::EpsBearerTag, ns3::EthernetHeader, ns3::EthernetTrailer, ns3::FilsDiscHeader, ns3::flame::FlameHeader, ns3::flame::FlameTag, ns3::FlowIdTag, ns3::FlowMonitor, ns3::FragmentationSubheader, ns3::GenericMacHeader, ns3::GrantManagementSubheader, ns3::GtpcCreateSessionRequestMessage, ns3::GtpcCreateSessionResponseMessage, ns3::GtpcDeleteBearerCommandMessage, ns3::GtpcDeleteBearerRequestMessage, ns3::GtpcDeleteBearerResponseMessage, ns3::GtpcHeader, ns3::GtpcModifyBearerRequestMessage, ns3::GtpcModifyBearerResponseMessage, ns3::GtpuHeader, ns3::Icmpv4DestinationUnreachable, ns3::Icmpv4Echo, ns3::Icmpv4Header, ns3::Icmpv4TimeExceeded, ns3::Icmpv6DestinationUnreachable, ns3::Icmpv6Echo, ns3::Icmpv6Header, ns3::Icmpv6L4Protocol, ns3::Icmpv6NA, ns3::Icmpv6NS, ns3::Icmpv6OptionHeader, ns3::Icmpv6OptionLinkLayerAddress, ns3::Icmpv6OptionMtu, ns3::Icmpv6OptionPrefixInformation, ns3::Icmpv6OptionRedirected, ns3::Icmpv6ParameterError, ns3::Icmpv6RA, ns3::Icmpv6Redirection, ns3::Icmpv6RS, ns3::Icmpv6TimeExceeded, ns3::Icmpv6TooBig, ns3::IdealHandoverCommandHeader, ns3::IdealHandoverPreparationInfoHeader, ns3::Ipv4FlowProbeTag, ns3::Ipv4Header, ns3::Ipv4PacketInfoTag, ns3::Ipv6ExtensionAHHeader, ns3::Ipv6ExtensionDestinationHeader, ns3::Ipv6ExtensionESPHeader, ns3::Ipv6ExtensionFragmentHeader, ns3::Ipv6ExtensionHeader, ns3::Ipv6ExtensionHopByHopHeader, ns3::Ipv6ExtensionLooseRoutingHeader, ns3::Ipv6ExtensionRoutingHeader, ns3::Ipv6FlowProbeTag, ns3::Ipv6Header, ns3::Ipv6OptionHeader, ns3::Ipv6OptionJumbogramHeader, ns3::Ipv6OptionPad1Header, ns3::Ipv6OptionPadnHeader, ns3::Ipv6OptionRouterAlertHeader, ns3::Ipv6PacketInfoTag, ns3::LlcSnapHeader, ns3::lorawan::LoraFrameHeader, ns3::lorawan::LoraTag, ns3::lorawan::LorawanMacHeader, ns3::lrwpan::BeaconPayloadHeader, ns3::lrwpan::CommandPayloadHeader, ns3::lrwpan::LrWpanLqiTag, ns3::lrwpan::LrWpanMacHeader, ns3::lrwpan::LrWpanMacTrailer, ns3::LtePdcpHeader, ns3::LtePhyTag, ns3::LteRadioBearerTag, ns3::LteRlcAmHeader, ns3::LteRlcHeader, ns3::LteRlcSduStatusTag, ns3::MacHeaderType, ns3::ManagementMessageType, ns3::MeshInformationElementVector, ns3::MgtAddBaRequestHeader, ns3::MgtAddBaResponseHeader, ns3::MgtDelBaHeader, ns3::MgtEmlOmn, ns3::MuSnrTag, ns3::NoBackhaulEpcHelper, ns3::Object, ns3::olsr::MessageHeader, ns3::olsr::PacketHeader, ns3::PacketSocketTag, ns3::PbbPacket, ns3::PdcpTag, ns3::PointToPointEpcHelper, ns3::PppHeader, ns3::PyVizPacketTag, ns3::RadiotapHeader, ns3::RipHeader, ns3::RipNgHeader, ns3::RipNgRte, ns3::RipRte, ns3::RlcTag, ns3::RngReq, ns3::RngRsp, ns3::RrcAsn1Header, ns3::RttEstimator, ns3::RttMeanDeviation, ns3::SeqTsEchoHeader, ns3::SeqTsHeader, ns3::SeqTsSizeHeader, ns3::SimpleTag, ns3::SixLowPanBc0, ns3::SixLowPanFrag1, ns3::SixLowPanFragN, ns3::SixLowPanHc1, ns3::SixLowPanIphc, ns3::SixLowPanIpv6, ns3::SixLowPanMesh, ns3::SixLowPanNhcExtension, ns3::SixLowPanUdpNhcExtension, ns3::SllHeader, ns3::SnrTag, ns3::SocketIpTosTag, ns3::SocketIpTtlTag, ns3::SocketIpv6HopLimitTag, ns3::SocketIpv6TclassTag, ns3::SocketPriorityTag, ns3::SocketSetDontFragmentTag, ns3::TcpHeader, ns3::TcpOption, ns3::TcpOptionEnd, ns3::TcpOptionMSS, ns3::TcpOptionNOP, ns3::TcpOptionSack, ns3::TcpOptionSackPermitted, ns3::TcpOptionTS, ns3::TcpOptionUnknown, ns3::TcpOptionWinScale, ns3::TcpSocketBase, ns3::ThreeGppHttpHeader, ns3::TimestampTag, ns3::Tlv, ns3::TrafficControlLayer, ns3::UanHeaderCommon, ns3::UanHeaderRcAck, ns3::UanHeaderRcCts, ns3::UanHeaderRcCtsGlobal, ns3::UanHeaderRcData, ns3::UanHeaderRcRts, ns3::Ucd, ns3::UdpHeader, ns3::UlMap, ns3::WifiActionHeader, ns3::WifiMacHeader, ns3::WifiMacTrailer, and ns3::WimaxMacToMacHeader.
Referenced by ns3::PacketTagList::Add(), ns3::Packet::AddByteTag(), ns3::Packet::AddByteTag(), ns3::Packet::AddHeader(), ns3::PacketMetadata::AddHeader(), ns3::Packet::AddPacketTag(), ns3::Packet::AddTrailer(), ns3::PacketMetadata::AddTrailer(), ConstructSelf(), ns3::PacketTagList::COWTraverse(), ns3::Packet::FindFirstMatchingByteTag(), GetAttribute(), GetAttributeFailSafe(), ns3::ByteTagIterator::Item::GetTag(), ns3::PacketTagIterator::Item::GetTag(), ns3::PacketTagList::Peek(), ns3::Packet::PeekHeader(), ns3::Packet::PeekHeader(), ns3::Packet::PeekTrailer(), ns3::Packet::RemoveHeader(), ns3::Packet::RemoveHeader(), ns3::PacketMetadata::RemoveHeader(), ns3::Packet::RemovePacketTag(), ns3::Packet::RemoveTrailer(), ns3::PacketMetadata::RemoveTrailer(), ns3::Packet::ReplacePacketTag(), ns3::PacketTagList::ReplaceWriter(), SetAttribute(), SetAttributeFailSafe(), TraceConnect(), TraceConnectWithoutContext(), TraceDisconnect(), and TraceDisconnectWithoutContext().
|
static |
Get the type ID.
Definition at line 62 of file object-base.cc.
References GetObjectIid(), and NS_LOG_FUNCTION_NOARGS.
Referenced by ConstructSelf().
|
protectedvirtual |
Notifier called once the ObjectBase is fully constructed.
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.
Reimplemented in ns3::FlowMonitor, ns3::VisualSimulatorImpl, and ns3::WifiMac.
Definition at line 75 of file object-base.cc.
References NS_LOG_FUNCTION.
Referenced by ConstructSelf(), and ns3::FlowMonitor::NotifyConstructionCompleted().
void ns3::ObjectBase::SetAttribute | ( | std::string | name, |
const AttributeValue & | value ) |
Set a single attribute, raising fatal errors if unsuccessful.
This will either succeed at setting the attribute or it will raise NS_FATAL_ERROR() on these conditions:
[in] | name | The name of the attribute to set. |
[in] | value | The name of the attribute to set. |
Definition at line 200 of file object-base.cc.
References ns3::TypeId::AttributeInformation::accessor, ns3::TypeId::ATTR_SET, ns3::TypeId::AttributeInformation::checker, DoSet(), ns3::TypeId::AttributeInformation::flags, GetInstanceTypeId(), ns3::TypeId::GetName(), ns3::TypeId::LookupAttributeByName(), NS_FATAL_ERROR, and NS_LOG_FUNCTION.
Referenced by ns3::cell_edited_callback(), ChainRegressionTest::CreateDevices(), ns3::olsr::Bug780Test::CreateNodes(), ns3::FqCobaltQueueDisc::DoEnqueue(), ns3::FqCoDelQueueDisc::DoEnqueue(), ns3::FqPieQueueDisc::DoEnqueue(), BuildingsPenetrationLossesTestCase::DoRun(), DsssModulationTest::DoRun(), Ipv4DeduplicationTest::DoRun(), Ipv6PacketInfoTagTest::DoRun(), ThreeGppChannelConditionModelTestCase::DoRun(), ThreeGppV2vHighwayLosNlosvChCondModelTestCase::DoRun(), ThreeGppV2vUrbanLosNlosvChCondModelTestCase::DoRun(), V2vHighwayProbChCondModelTestCase::DoRun(), V2vUrbanProbChCondModelTestCase::DoRun(), AmpduAggregationTest::DoSetup(), ns3::ThreeGppHttpClient::OpenConnection(), ThreeGppShadowingTestCase::RunTest(), ns3::Ping::Send(), ns3::Ping::StartApplication(), ns3::Radvd::StartApplication(), ns3::ThreeGppHttpServer::StartApplication(), ns3::V4TraceRoute::StartApplication(), Ipv4FragmentationTest::StartClient(), Ipv6FragmentationTest::StartClient(), and SixlowpanFragmentationTest::StartClient().
bool ns3::ObjectBase::SetAttributeFailSafe | ( | std::string | name, |
const AttributeValue & | value ) |
Set a single attribute without raising errors.
If the attribute could not be set this will return false
, but not raise any errors.
[in] | name | The name of the attribute to set. |
[in] | value | The value to set it to. |
true
if the requested attribute exists and could be set, false
otherwise. Definition at line 223 of file object-base.cc.
References ns3::TypeId::AttributeInformation::accessor, ns3::TypeId::ATTR_SET, ns3::TypeId::AttributeInformation::checker, DoSet(), ns3::TypeId::AttributeInformation::flags, GetInstanceTypeId(), ns3::TypeId::LookupAttributeByName(), and NS_LOG_FUNCTION.
Referenced by ns3::LteHelper::InstallSingleEnbDevice().
bool ns3::ObjectBase::TraceConnect | ( | std::string | name, |
std::string | context, | ||
const CallbackBase & | cb ) |
Connect a TraceSource to a Callback with a context.
The target trace source should be registered with TypeId::AddTraceSource.
[in] | name | The name of the target trace source. |
[in] | context | The trace context associated to the callback. |
[in] | cb | The callback to connect to the trace source. |
true
on success, false
if TraceSource was not found. Definition at line 326 of file object-base.cc.
References GetInstanceTypeId(), ns3::TypeId::GetName(), ns3::TypeId::LookupTraceSourceByName(), NS_LOG_DEBUG, and NS_LOG_FUNCTION.
bool ns3::ObjectBase::TraceConnectWithoutContext | ( | std::string | name, |
const CallbackBase & | cb ) |
Connect a TraceSource to a Callback without a context.
The target trace source should be registered with TypeId::AddTraceSource.
[in] | name | The name of the target trace source. |
[in] | cb | The callback to connect to the trace source. |
true
on success, false
if TraceSource was not found. Definition at line 311 of file object-base.cc.
References GetInstanceTypeId(), ns3::TypeId::GetName(), ns3::TypeId::LookupTraceSourceByName(), NS_LOG_DEBUG, and NS_LOG_FUNCTION.
Referenced by ns3::ApWifiMac::DoInitialize(), ns3::StaWifiMac::DoInitialize(), DownlinkPacketTest::DoRun(), LinkCheckTest::DoRun(), UdpSocketImplTest::DoRun(), WaypointMobilityModelAddWaypointTest::DoRun(), WifiAcMappingTest::DoRun(), SpectrumWifiPhyFilterTest::DoSetup(), TestMultipleHeTbPreambles::DoSetup(), TestUlOfdmaPpduUid::DoSetup(), ns3::ClickInternetStackHelper::EnableAsciiIpv4Internal(), ns3::InternetStackHelper::EnableAsciiIpv4Internal(), TracedValueCallbackTestCase::CheckTvCb< T >::Invoke(), and ns3::FrameExchangeManager::SetWifiPhy().
bool ns3::ObjectBase::TraceDisconnect | ( | std::string | name, |
std::string | context, | ||
const CallbackBase & | cb ) |
Disconnect from a TraceSource a Callback previously connected with a context.
The target trace source should be registered with TypeId::AddTraceSource.
[in] | name | The name of the target trace source. |
[in] | context | The trace context associated to the callback. |
[in] | cb | The callback to disconnect from the trace source. |
true
on success, false
if TraceSource was not found. Definition at line 355 of file object-base.cc.
References GetInstanceTypeId(), ns3::TypeId::LookupTraceSourceByName(), and NS_LOG_FUNCTION.
bool ns3::ObjectBase::TraceDisconnectWithoutContext | ( | std::string | name, |
const CallbackBase & | cb ) |
Disconnect from a TraceSource a Callback previously connected without a context.
The target trace source should be registered with TypeId::AddTraceSource.
[in] | name | The name of the target trace source. |
[in] | cb | The callback to disconnect from the trace source. |
true
on success, false
if TraceSource was not found. Definition at line 341 of file object-base.cc.
References GetInstanceTypeId(), ns3::TypeId::LookupTraceSourceByName(), and NS_LOG_FUNCTION.
Referenced by ns3::FrameExchangeManager::ResetPhy().
|
related |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly.
Definition at line 52 of file object-base.cc.
References NS_LOG_FUNCTION_NOARGS, ns3::TypeId::SetGroupName(), and ns3::TypeId::SetParent().
Referenced by GetTypeId().