Callback template class. More...
#include <callback.h>
Public Member Functions | |
Callback () | |
template<typename FUNCTOR > | |
Callback (FUNCTOR const &functor, bool, bool) | |
template<typename OBJ_PTR , typename MEM_PTR > | |
Callback (OBJ_PTR const &objPtr, MEM_PTR mem_ptr) | |
Callback (Ptr< CallbackImpl< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 > > const &impl) | |
template<typename T > | |
Callback< R, T2, T3, T4, T5, T6, T7, T8, T9 > | Bind (T a) |
bool | IsNull (void) const |
void | Nullify (void) |
R | operator() (void) const |
R | operator() (T1 a1) const |
R | operator() (T1 a1, T2 a2) const |
R | operator() (T1 a1, T2 a2, T3 a3) const |
R | operator() (T1 a1, T2 a2, T3 a3, T4 a4) const |
R | operator() (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) const |
R | operator() (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) const |
R | operator() (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7) const |
R | operator() (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7, T8 a8) const |
R | operator() (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7, T8 a8, T9 a9) const |
bool | IsEqual (const CallbackBase &other) const |
bool | CheckType (const CallbackBase &other) const |
void | Assign (const CallbackBase &other) |
Private Member Functions | |
CallbackImpl< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 > * | DoPeekImpl (void) const |
bool | DoCheckType (Ptr< const CallbackImplBase > other) const |
void | DoAssign (Ptr< const CallbackImplBase > other) |
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 :
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ #include "ns3/callback.h" #include "ns3/assert.h" #include <iostream> using namespace ns3; static double CbOne (double a, double b) { std::cout << "invoke cbOne a=" << a << ", b=" << b << std::endl; return a; } class MyCb { public: int CbTwo (double a) { std::cout << "invoke cbTwo a=" << a << std::endl; return -5; } }; int main (int argc, char *argv[]) { // return type: double // first arg type: double // second arg type: double Callback<double, double, double> one; // build callback instance which points to cbOne function one = MakeCallback (&CbOne); // this is not a null callback NS_ASSERT (!one.IsNull ()); // invoke cbOne function through callback instance double retOne; retOne = one (10.0, 20.0); // return type: int // first arg type: double Callback<int, double> two; MyCb cb; // build callback instance which points to MyCb::cbTwo two = MakeCallback (&MyCb::CbTwo, &cb); // this is not a null callback NS_ASSERT (!two.IsNull ()); // invoke MyCb::cbTwo through callback instance int retTwo; retTwo = two (10.0); two = MakeNullCallback<int, double> (); // invoking a null callback is just like // invoking a null function pointer: // it will crash. //int retTwoNull = two (20.0); NS_ASSERT (two.IsNull ()); return 0; }
Definition at line 380 of file callback.h.
ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::Callback | ( | ) | [inline] |
Definition at line 382 of file callback.h.
ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::Callback | ( | FUNCTOR const & | functor, | |
bool | , | |||
bool | ||||
) | [inline] |
Definition at line 387 of file callback.h.
ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::Callback | ( | OBJ_PTR const & | objPtr, | |
MEM_PTR | mem_ptr | |||
) | [inline] |
Definition at line 392 of file callback.h.
ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::Callback | ( | Ptr< CallbackImpl< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 > > const & | impl | ) | [inline] |
Definition at line 396 of file callback.h.
void ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::Assign | ( | const CallbackBase & | other | ) | [inline] |
Callback<R,T2,T3,T4,T5,T6,T7,T8,T9> ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::Bind | ( | T | a | ) | [inline] |
Definition at line 401 of file callback.h.
Referenced by ns3::TracedCallback< T1, T2, T3, T4, T5, T6, T7, T8 >::Connect(), and ns3::TracedCallback< T1, T2, T3, T4, T5, T6, T7, T8 >::Disconnect().
bool ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::CheckType | ( | const CallbackBase & | other | ) | const [inline] |
Definition at line 452 of file callback.h.
void ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::DoAssign | ( | Ptr< const CallbackImplBase > | other | ) | [inline, private] |
Definition at line 476 of file callback.h.
Referenced by ns3::Callback< void, int8_t >::Assign().
bool ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::DoCheckType | ( | Ptr< const CallbackImplBase > | other | ) | const [inline, private] |
Definition at line 462 of file callback.h.
Referenced by ns3::Callback< void, int8_t >::CheckType(), and ns3::Callback< void, int8_t >::DoAssign().
CallbackImpl<R,T1,T2,T3,T4,T5,T6,T7,T8,T9>* ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::DoPeekImpl | ( | void | ) | const [inline, private] |
Definition at line 459 of file callback.h.
Referenced by ns3::Callback< void, int8_t >::IsNull(), and ns3::Callback< void, int8_t >::operator()().
bool ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::IsEqual | ( | const CallbackBase & | other | ) | const [inline] |
Definition at line 448 of file callback.h.
Referenced by ns3::operator!=().
bool ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::IsNull | ( | void | ) | const [inline] |
Definition at line 410 of file callback.h.
Referenced by ns3::UdpSocketImpl::ForwardIcmp(), ns3::Ipv4EndPoint::ForwardIcmp(), ns3::Ipv4EndPoint::ForwardUp(), ns3::WifiNetDevice::ForwardUp(), ns3::EmuNetDevice::ForwardUp(), ns3::DcaTxop::GotAck(), ns3::AttributeObjectTest::InvokeCbValue(), ns3::WifiNetDevice::LinkDown(), ns3::WifiNetDevice::LinkUp(), ns3::DcaTxop::MissedAck(), ns3::DcaTxop::MissedCts(), ns3::Socket::NotifyConnectionFailed(), ns3::Socket::NotifyConnectionRequest(), ns3::Socket::NotifyConnectionSucceeded(), ns3::Socket::NotifyDataRecv(), ns3::Socket::NotifyDataSent(), ns3::PointToPointNetDevice::NotifyLinkUp(), ns3::EmuNetDevice::NotifyLinkUp(), ns3::CsmaNetDevice::NotifyLinkUp(), ns3::Socket::NotifyNewConnectionCreated(), ns3::Socket::NotifySend(), ns3::Packet::PrintTags(), ns3::SimpleNetDevice::Receive(), ns3::NqstaWifiMac::Receive(), ns3::PointToPointNetDevice::Receive(), ns3::CsmaNetDevice::Receive(), ns3::BridgeNetDevice::ReceiveFromDevice(), ns3::NqapWifiMac::SetLinkUpCallback(), ns3::YansWifiPhyStateHelper::SwitchFromRxEndError(), ns3::Ns2ExtWifiPhyStateHelper::SwitchFromRxEndError(), ns3::YansWifiPhyStateHelper::SwitchFromRxEndOk(), ns3::Ns2ExtWifiPhyStateHelper::SwitchFromRxEndOk(), and ns3::Ipv4EndPoint::~Ipv4EndPoint().
void ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::Nullify | ( | void | ) | [inline] |
Definition at line 413 of file callback.h.
R ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::operator() | ( | T1 | a1, | |
T2 | a2, | |||
T3 | a3, | |||
T4 | a4, | |||
T5 | a5, | |||
T6 | a6, | |||
T7 | a7, | |||
T8 | a8, | |||
T9 | a9 | |||
) | const [inline] |
Definition at line 444 of file callback.h.
R ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::operator() | ( | T1 | a1, | |
T2 | a2, | |||
T3 | a3, | |||
T4 | a4, | |||
T5 | a5, | |||
T6 | a6, | |||
T7 | a7, | |||
T8 | a8 | |||
) | const [inline] |
Definition at line 441 of file callback.h.
R ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::operator() | ( | T1 | a1, | |
T2 | a2, | |||
T3 | a3, | |||
T4 | a4, | |||
T5 | a5, | |||
T6 | a6, | |||
T7 | a7 | |||
) | const [inline] |
Definition at line 438 of file callback.h.
R ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::operator() | ( | T1 | a1, | |
T2 | a2, | |||
T3 | a3, | |||
T4 | a4, | |||
T5 | a5, | |||
T6 | a6 | |||
) | const [inline] |
Definition at line 435 of file callback.h.
R ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::operator() | ( | T1 | a1, | |
T2 | a2, | |||
T3 | a3, | |||
T4 | a4, | |||
T5 | a5 | |||
) | const [inline] |
Definition at line 432 of file callback.h.
R ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::operator() | ( | T1 | a1, | |
T2 | a2, | |||
T3 | a3, | |||
T4 | a4 | |||
) | const [inline] |
Definition at line 429 of file callback.h.
R ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::operator() | ( | T1 | a1, | |
T2 | a2, | |||
T3 | a3 | |||
) | const [inline] |
Definition at line 426 of file callback.h.
R ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::operator() | ( | T1 | a1, | |
T2 | a2 | |||
) | const [inline] |
Definition at line 423 of file callback.h.
R ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::operator() | ( | T1 | a1 | ) | const [inline] |
Definition at line 420 of file callback.h.
R ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::operator() | ( | void | ) | const [inline] |
Definition at line 417 of file callback.h.