Callback template class. More...
#include "callback.h"
Inherits ns3::CallbackBase.
Public Member Functions | |
Callback () | |
template<typename... BArgs> | |
Callback (const Callback< R, BArgs..., UArgs... > &cb, BArgs... bargs) | |
Construct from another callback and bind some arguments (if any) | |
Callback (const Ptr< CallbackImpl< R, UArgs... > > &impl) | |
Construct from a CallbackImpl pointer. | |
template<typename T , typename... BArgs, std::enable_if_t<!std::is_base_of_v< CallbackBase, T > &&std::is_invocable_r_v< R, T, BArgs..., UArgs... >, int > = 0> | |
Callback (T func, BArgs... bargs) | |
Construct from a function and bind some arguments (if any) | |
bool | Assign (const CallbackBase &other) |
Adopt the other's implementation, if type compatible. | |
template<typename... BoundArgs> | |
auto | Bind (BoundArgs &&... bargs) |
Bind a variable number of arguments. | |
bool | CheckType (const CallbackBase &other) const |
Check for compatible types. | |
bool | IsEqual (const CallbackBase &other) const |
Equality test. | |
bool | IsNull () const |
Check for null implementation. | |
void | Nullify () |
Discard the implementation, set it to null. | |
R | operator() (UArgs... uargs) const |
Functor with varying numbers of arguments. | |
Public Member Functions inherited from ns3::CallbackBase | |
CallbackBase () | |
Ptr< CallbackImplBase > | GetImpl () const |
Private Member Functions | |
template<std::size_t... INDEX, typename... BoundArgs> | |
auto | BindImpl (std::index_sequence< INDEX... > seq, BoundArgs &&... bargs) |
Implementation of the Bind method. | |
bool | DoCheckType (Ptr< const CallbackImplBase > other) const |
Check for compatible types. | |
CallbackImpl< R, UArgs... > * | DoPeekImpl () const |
Friends | |
template<typename ROther , typename... UArgsOther> | |
class | Callback |
Additional Inherited Members | |
Protected Member Functions inherited from ns3::CallbackBase | |
CallbackBase (Ptr< CallbackImplBase > impl) | |
Construct from a pimpl. | |
Protected Attributes inherited from ns3::CallbackBase | |
Ptr< CallbackImplBase > | m_impl |
the pimpl | |
Callback template class.
This class template implements the Functor Design Pattern. It is used to declare the type of a Callback:
Callback instances are built with the MakeCallback template functions. Callback instances have POD semantics: the memory they allocate is managed automatically, without user intervention which allows you to pass around Callback instances by value.
Sample code which shows how to use this class template as well as the function templates MakeCallback :
This code uses:
This code most notably departs from the alexandrescu implementation in that it does not use type lists to specify and pass around the types of the callback arguments. Of course, it also does not use copy-destruction semantics and relies on a reference list rather than autoPtr to hold the pointer.
R | [explicit] The return type of the Callback. |
UArgs | [explicit] The types of any arguments to the Callback. |
Definition at line 421 of file callback.h.
|
inline |
Definition at line 427 of file callback.h.
|
inline |
Construct from a CallbackImpl pointer.
[in] | impl | The CallbackImpl Ptr |
Definition at line 436 of file callback.h.
|
inline |
Construct from another callback and bind some arguments (if any)
BArgs | [deduced] The types of the bound arguments |
[in] | cb | The existing callback |
[in] | bargs | The values of the bound arguments |
Definition at line 449 of file callback.h.
References ns3::Create(), ns3::Callback< R, UArgs >::DoPeekImpl(), and ns3::CallbackBase::m_impl.
|
inline |
Construct from a function and bind some arguments (if any)
T | [deduced] The type of the function |
BArgs | [deduced] The types of the bound arguments |
[in] | func | The function |
[in] | bargs | The values of the bound arguments |
Definition at line 481 of file callback.h.
References ns3::Create(), and ns3::CallbackBase::m_impl.
|
inline |
Adopt the other's implementation, if type compatible.
[in] | other | Callback |
true
if other was type-compatible and could be adopted. Definition at line 605 of file callback.h.
References ns3::Callback< R, UArgs >::DoCheckType(), ns3::CallbackImpl< R, UArgs >::DoGetTypeid(), ns3::CallbackBase::GetImpl(), ns3::CallbackBase::m_impl, NS_FATAL_ERROR_CONT, and ns3::PeekPointer().
|
inline |
Bind a variable number of arguments.
BoundArgs | [deduced] The types of the arguments to bind |
[in] | bargs | The values of the arguments to bind |
Definition at line 543 of file callback.h.
References ns3::Callback< R, UArgs >::BindImpl().
Referenced by ns3::TracedCallback< Ts >::Connect(), ns3::TracedCallback< Ts >::Disconnect(), CallbackEqualityTestCase::DoRun(), ns3::QosTxop::SetDroppedMpduCallback(), and ns3::Txop::SetDroppedMpduCallback().
|
inlineprivate |
Implementation of the Bind method.
BoundArgs | The types of the arguments to bind |
[in] | seq | A compile-time integer sequence |
[in] | bargs | The values of the arguments to bind |
Definition at line 515 of file callback.h.
References ns3::Create(), and ns3::Callback< R, UArgs >::DoPeekImpl().
Referenced by ns3::Callback< R, UArgs >::Bind().
|
inline |
Check for compatible types.
true
if other can be dynamic_cast to my type Definition at line 594 of file callback.h.
References ns3::Callback< R, UArgs >::DoCheckType(), and ns3::CallbackBase::GetImpl().
|
inlineprivate |
Check for compatible types.
true
if other can be dynamic_cast to my type Definition at line 635 of file callback.h.
References ns3::PeekPointer().
Referenced by ns3::Callback< R, UArgs >::Assign(), and ns3::Callback< R, UArgs >::CheckType().
|
inlineprivate |
Definition at line 624 of file callback.h.
References ns3::CallbackBase::m_impl, and ns3::PeekPointer().
Referenced by ns3::Callback< R, UArgs >::Callback(), ns3::Callback< R, UArgs >::BindImpl(), ns3::Callback< R, UArgs >::IsNull(), and ns3::Callback< R, UArgs >::operator()().
|
inline |
Equality test.
[in] | other | Callback |
true
if we are equal Definition at line 583 of file callback.h.
References ns3::CallbackBase::GetImpl(), and ns3::CallbackBase::m_impl.
Referenced by CallbackEqualityTestCase::DoRun(), ns3::aodv::QueueEntryTest::DoRun(), and ns3::operator!=().
|
inline |
Check for null implementation.
true
if I don't have an implementation Definition at line 555 of file callback.h.
References ns3::Callback< R, UArgs >::DoPeekImpl().
Referenced by ns3::Ipv4EndPoint::~Ipv4EndPoint(), ns3::Ipv6EndPoint::~Ipv6EndPoint(), TcpSocketAdvertisedWindowProxy::AdvertisedWindowSize(), ns3::lrwpan::LrWpanPhy::CancelEd(), ns3::lrwpan::LrWpanCsmaCa::CanProceed(), ns3::TcpTxBuffer::DiscardUpTo(), ns3::WifiRadioEnergyModelHelper::DoInstall(), NullifyCallbackTestCase::DoRun(), ns3::lrwpan::LrWpanPhy::EndCca(), ns3::lrwpan::LrWpanMac::EndChannelEnergyScan(), ns3::lrwpan::LrWpanMac::EndChannelScan(), ns3::lrwpan::LrWpanPhy::EndEd(), ns3::lorawan::SimpleEndDeviceLoraPhy::EndReceive(), ns3::lorawan::SimpleGatewayLoraPhy::EndReceive(), ns3::HalfDuplexIdealPhy::EndRx(), ns3::lrwpan::LrWpanPhy::EndRx(), ns3::LteSpectrumPhy::EndRxData(), ns3::LteSpectrumPhy::EndRxDlCtrl(), ns3::lrwpan::LrWpanPhy::EndSetTRXState(), ns3::lrwpan::LrWpanMac::EndStartRequest(), ns3::HalfDuplexIdealPhy::EndTx(), ns3::lrwpan::LrWpanPhy::EndTx(), ns3::lrwpan::LrWpanMac::EnqueueInd(), ns3::lrwpan::LrWpanMac::EnqueueTxQElement(), ns3::WifiTxTimer::FeedTraceSource(), ns3::WifiTxTimer::FeedTraceSource(), ns3::WifiTxTimer::FeedTraceSource(), ns3::dsr::DsrRouting::ForwardErrPacket(), ns3::dsr::DsrRouting::ForwardPacket(), ns3::FdNetDevice::ForwardUp(), ns3::WifiNetDevice::ForwardUp(), ns3::WifiMode::GetNonHtReferenceRate(), ns3::AcousticModemEnergyModel::HandleEnergyDepletion(), ns3::lorawan::LoraRadioEnergyModel::HandleEnergyDepletion(), ns3::WifiRadioEnergyModel::HandleEnergyDepletion(), ns3::AcousticModemEnergyModel::HandleEnergyRecharged(), ns3::lorawan::LoraRadioEnergyModel::HandleEnergyRecharged(), ns3::WifiRadioEnergyModel::HandleEnergyRecharged(), ns3::BlockAckManager::HandleInFlightMpdu(), ns3::Icmpv6L4Protocol::HandleRA(), AttributeObjectTest::InvokeCbValue(), CallbackValueTestCase::InvokeCbValue(), RandomVariableStreamAttributeTestCase::InvokeCbValue(), ns3::WimaxNetDevice::IsPromisc(), ns3::lrwpan::LrWpanMac::LostAssocRespCommand(), ns3::lrwpan::LrWpanMac::McpsDataRequest(), ns3::lrwpan::LrWpanMac::MlmeAssociateRequest(), ns3::lrwpan::LrWpanMac::MlmeGetRequest(), ns3::lrwpan::LrWpanMac::MlmeScanRequest(), ns3::lrwpan::LrWpanMac::MlmeSetRequest(), ns3::lrwpan::LrWpanMac::MlmeStartRequest(), ns3::WifiRadioEnergyModelPhyListener::NotifyCcaBusyStart(), ns3::SpectrumWifiPhy::NotifyChannelSwitched(), ns3::BlockAckManager::NotifyDiscardedMpdu(), ns3::HePhy::NotifyEndOfHeSigA(), ns3::BlockAckManager::NotifyGotBlockAck(), ns3::Icmpv4L4Protocol::NotifyNewAggregate(), ns3::Icmpv6L4Protocol::NotifyNewAggregate(), ns3::TcpL4Protocol::NotifyNewAggregate(), ns3::UdpL4Protocol::NotifyNewAggregate(), ns3::WifiRadioEnergyModelPhyListener::NotifyOff(), ns3::WifiRadioEnergyModelPhyListener::NotifyOn(), ns3::FrameExchangeManager::NotifyPacketDiscarded(), ns3::FrameExchangeManager::NotifyReceivedNormalAck(), ns3::AlohaNoackNetDevice::NotifyReceptionEndOk(), ns3::WifiRadioEnergyModelPhyListener::NotifyRxEndError(), ns3::WifiRadioEnergyModelPhyListener::NotifyRxEndOk(), ns3::WifiPhyStateHelper::NotifyRxMpdu(), ns3::WifiPhyStateHelper::NotifyRxPsduFailed(), ns3::WifiPhyStateHelper::NotifyRxPsduSucceeded(), ns3::lorawan::LoraRadioEnergyModelPhyListener::NotifyRxStart(), ns3::WifiRadioEnergyModelPhyListener::NotifyRxStart(), ns3::lorawan::LoraRadioEnergyModelPhyListener::NotifySleep(), ns3::WifiRadioEnergyModelPhyListener::NotifySleep(), ns3::lorawan::LoraRadioEnergyModelPhyListener::NotifyStandby(), ns3::WifiRadioEnergyModelPhyListener::NotifySwitchingStart(), ns3::NetDeviceQueue::NotifyTransmittedBytes(), ns3::lorawan::LoraRadioEnergyModelPhyListener::NotifyTxStart(), ns3::WifiRadioEnergyModelPhyListener::NotifyTxStart(), ns3::WifiRadioEnergyModelPhyListener::NotifyWakeup(), ns3::lrwpan::LrWpanMac::PdDataConfirm(), ns3::lrwpan::LrWpanMac::PdDataIndication(), ns3::lrwpan::LrWpanPhy::PdDataRequest(), ns3::QosTxop::PeekNextMpdu(), ns3::lrwpan::LrWpanCsmaCa::PlmeCcaConfirm(), ns3::lrwpan::LrWpanPhy::PlmeCcaRequest(), ns3::lrwpan::LrWpanPhy::PlmeEdRequest(), ns3::lrwpan::LrWpanPhy::PlmeGetAttributeRequest(), ns3::lrwpan::LrWpanMac::PlmeSetAttributeConfirm(), ns3::lrwpan::LrWpanPhy::PlmeSetAttributeRequest(), ns3::lrwpan::LrWpanPhy::PlmeSetTRXStateRequest(), ns3::lrwpan::LrWpanMac::PrepareRetransmission(), ns3::Packet::Print(), ns3::Packet::PrintByteTags(), ns3::Packet::PrintPacketTags(), ns3::lrwpan::LrWpanMac::PurgeInd(), ns3::CsmaNetDevice::Receive(), ns3::LoopbackNetDevice::Receive(), ns3::MockNetDevice::Receive(), ns3::MpiReceiver::Receive(), ns3::PointToPointNetDevice::Receive(), ns3::SimpleNetDevice::Receive(), ns3::VirtualNetDevice::Receive(), ns3::StaWifiMac::ReceiveAssocResp(), ns3::lrwpan::LrWpanMac::ReceiveBeacon(), ns3::TcpSocketMsgBase::ReceivedAck(), ns3::BridgeNetDevice::ReceiveFromDevice(), ns3::MeshPointDevice::ReceiveFromDevice(), ns3::OpenFlowSwitchNetDevice::ReceiveFromDevice(), ns3::SixLowPanNetDevice::ReceiveFromDevice(), ns3::aodv::RoutingProtocol::RouteInput(), ns3::dsdv::RoutingProtocol::RouteInput(), ns3::Ipv4GlobalRouting::RouteInput(), ns3::Ipv4StaticRouting::RouteInput(), ns3::Ipv6StaticRouting::RouteInput(), ns3::NixVectorRouting< T >::RouteInput(), ns3::olsr::RoutingProtocol::RouteInput(), ns3::Rip::RouteInput(), ns3::RipNg::RouteInput(), ns3::UanPhyGen::RxEndEvent(), ns3::dsr::DsrRouting::Send(), ns3::dsr::DsrRouting::SendAck(), ns3::dsr::DsrRouting::SendErrorRequest(), ns3::MockNetDevice::SendFrom(), ns3::dsr::DsrRouting::SendInitialRequest(), ns3::dsr::DsrRouting::SendPacketFromBuffer(), ns3::dsr::DsrRouting::SendReply(), ns3::dsr::DsrRouting::SendRequest(), ns3::TcpSocketMsgBase::SetAfterRetransmitCb(), ns3::SubscriberStationNetDevice::SetBasicConnection(), ns3::TcpSocketMsgBase::SetBeforeRetransmitCb(), ns3::lorawan::LoraRadioEnergyModelPhyListener::SetChangeStateCallback(), ns3::WifiRadioEnergyModelPhyListener::SetChangeStateCallback(), ns3::AcousticModemEnergyModel::SetEnergyDepletionCallback(), ns3::lorawan::LoraRadioEnergyModel::SetEnergyDepletionCallback(), ns3::WifiRadioEnergyModel::SetEnergyDepletionCallback(), ns3::AcousticModemEnergyModel::SetEnergyRechargeCallback(), ns3::lorawan::LoraRadioEnergyModel::SetEnergyRechargedCallback(), ns3::WifiRadioEnergyModel::SetEnergyRechargedCallback(), TcpSocketAdvertisedWindowProxy::SetInvalidAwndCb(), ns3::lrwpan::LrWpanMac::SetLrWpanMacState(), ns3::SubscriberStationNetDevice::SetPrimaryConnection(), ns3::TcpSocketMsgBase::SetProcessedAckCb(), ns3::TcpSocketMsgBase::SetRcvAckCb(), ns3::UanPhyGen::SetSleepMode(), ns3::TcpSocketMsgBase::SetUpdateRttHistoryCb(), ns3::lorawan::LoraRadioEnergyModelPhyListener::SetUpdateTxCurrentCallback(), ns3::WifiRadioEnergyModelPhyListener::SetUpdateTxCurrentCallback(), ns3::HalfDuplexIdealPhy::StartRx(), ns3::LteSpectrumPhy::StartRxDlCtrl(), ns3::WifiRadioEnergyModelPhyListener::SwitchToIdle(), ns3::lorawan::LoraRadioEnergyModelPhyListener::SwitchToStandby(), ns3::lorawan::EndDeviceLoraPhy::TxFinished(), ns3::TcpTxBuffer::Update(), ns3::UanPhyGen::UpdatePowerConsumption(), ns3::TcpSocketMsgBase::UpdateRttHistory(), and ns3::NetDeviceQueue::Wake().
|
inline |
Discard the implementation, set it to null.
Definition at line 561 of file callback.h.
References ns3::CallbackBase::m_impl.
Referenced by ns3::AcousticModemEnergyModel::AcousticModemEnergyModel(), ns3::AcousticModemEnergyModelHelper::AcousticModemEnergyModelHelper(), ns3::lorawan::LoraRadioEnergyModel::LoraRadioEnergyModel(), ns3::lorawan::LoraRadioEnergyModelPhyListener::LoraRadioEnergyModelPhyListener(), ns3::UanPhyGen::UanPhyGen(), ns3::WifiRadioEnergyModel::WifiRadioEnergyModel(), ns3::WifiRadioEnergyModelHelper::WifiRadioEnergyModelHelper(), ns3::WifiRadioEnergyModelPhyListener::WifiRadioEnergyModelPhyListener(), ns3::Ipv4EndPoint::~Ipv4EndPoint(), ns3::Ipv6EndPoint::~Ipv6EndPoint(), ns3::NetDeviceQueue::~NetDeviceQueue(), ns3::AcousticModemEnergyModel::DoDispose(), ns3::Icmpv4L4Protocol::DoDispose(), ns3::Icmpv6L4Protocol::DoDispose(), ns3::lorawan::LoraRadioEnergyModel::DoDispose(), ns3::MockNetDevice::DoDispose(), ns3::SpectrumWifiPhy::DoDispose(), ns3::SubscriberStationNetDevice::DoDispose(), ns3::TcpL4Protocol::DoDispose(), ns3::UanPhyGen::DoDispose(), ns3::UdpL4Protocol::DoDispose(), ns3::WifiRadioEnergyModel::DoDispose(), NullifyCallbackTestCase::DoRun(), and ns3::FdReader::Stop().
|
inline |
Functor with varying numbers of arguments.
uargs | The arguments to the callback |
Definition at line 572 of file callback.h.
References ns3::Callback< R, UArgs >::DoPeekImpl().
|
friend |
Definition at line 424 of file callback.h.