A Discrete-Event Network Simulator
API
ns3::CallbackImpl< R, UArgs > Class Template Reference

CallbackImpl class with varying numbers of argument types. More...

#include "callback.h"

+ Inheritance diagram for ns3::CallbackImpl< R, UArgs >:
+ Collaboration diagram for ns3::CallbackImpl< R, UArgs >:

Public Member Functions

 CallbackImpl (std::function< R(UArgs...)> func, const CallbackComponentVector &components)
 Constructor. More...
 
const CallbackComponentVectorGetComponents () const
 Get the vector of callback components. More...
 
const std::function< R(UArgs...)> & GetFunction () const
 Get the stored function. More...
 
std::string GetTypeid () const override
 Get the name of this object type. More...
 
bool IsEqual (Ptr< const CallbackImplBase > other) const override
 Equality test. More...
 
operator() (UArgs... uargs) const
 Function call operator. More...
 
- Public Member Functions inherited from ns3::CallbackImplBase
virtual ~CallbackImplBase ()
 Virtual destructor. More...
 
- Public Member Functions inherited from ns3::SimpleRefCount< CallbackImplBase >
 SimpleRefCount ()
 Default constructor. More...
 
 SimpleRefCount (const SimpleRefCount &o[[maybe_unused]])
 Copy constructor. More...
 
uint32_t GetReferenceCount () const
 Get the reference count of the object. More...
 
SimpleRefCountoperator= (const SimpleRefCount &o[[maybe_unused]])
 Assignment operator. More...
 
void Ref () const
 Increment the reference count. More...
 
void Unref () const
 Decrement the reference count. More...
 

Static Public Member Functions

static std::string DoGetTypeid ()
 Get the name of this object type. More...
 

Private Attributes

std::vector< std::shared_ptr< CallbackComponentBase > > m_components
 Stores the original callable object and the bound arguments, if any. More...
 
std::function< R(UArgs...)> m_func
 Stores the callable object associated with this callback (as a lambda) More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from ns3::CallbackImplBase
static std::string Demangle (const std::string &mangled)
 
template<typename T >
static std::string GetCppTypeid ()
 Helper to get the C++ typeid as a string. More...
 

Detailed Description

template<typename R, typename... UArgs>
class ns3::CallbackImpl< R, UArgs >

CallbackImpl class with varying numbers of argument types.

Template Parameters
R[explicit] The return type of the Callback.
UArgs[explicit] The types of any arguments to the Callback.

Definition at line 241 of file callback.h.

Constructor & Destructor Documentation

◆ CallbackImpl()

template<typename R , typename... UArgs>
ns3::CallbackImpl< R, UArgs >::CallbackImpl ( std::function< R(UArgs...)>  func,
const CallbackComponentVector components 
)
inline

Constructor.

Parameters
functhe callable object
componentsthe callback components (callable object and bound arguments)

Definition at line 250 of file callback.h.

Member Function Documentation

◆ DoGetTypeid()

template<typename R , typename... UArgs>
static std::string ns3::CallbackImpl< R, UArgs >::DoGetTypeid ( )
inlinestatic

Get the name of this object type.

Returns
The object type as a string.

Definition at line 328 of file callback.h.

Referenced by ns3::Callback< R, UArgs >::Assign(), and ns3::CallbackImpl< R, UArgs >::GetTypeid().

+ Here is the caller graph for this function:

◆ GetComponents()

template<typename R , typename... UArgs>
const CallbackComponentVector& ns3::CallbackImpl< R, UArgs >::GetComponents ( ) const
inline

Get the vector of callback components.

Returns
A const reference to the vector of callback components.

Definition at line 269 of file callback.h.

References ns3::CallbackImpl< R, UArgs >::m_components.

◆ GetFunction()

template<typename R , typename... UArgs>
const std::function<R(UArgs...)>& ns3::CallbackImpl< R, UArgs >::GetFunction ( ) const
inline

Get the stored function.

Returns
A const reference to the stored function.

Definition at line 260 of file callback.h.

References ns3::CallbackImpl< R, UArgs >::m_func.

◆ GetTypeid()

template<typename R , typename... UArgs>
std::string ns3::CallbackImpl< R, UArgs >::GetTypeid ( ) const
inlineoverridevirtual

Get the name of this object type.

Returns
The object type as a string.

Implements ns3::CallbackImplBase.

Definition at line 322 of file callback.h.

References ns3::CallbackImpl< R, UArgs >::DoGetTypeid().

+ Here is the call graph for this function:

◆ IsEqual()

template<typename R , typename... UArgs>
bool ns3::CallbackImpl< R, UArgs >::IsEqual ( Ptr< const CallbackImplBase other) const
inlineoverridevirtual

Equality test.

Parameters
[in]otherCallback Ptr
Returns
true if we are equal

Implements ns3::CallbackImplBase.

Definition at line 285 of file callback.h.

References ns3::CallbackImpl< R, UArgs >::m_components, and ns3::PeekPointer().

+ Here is the call graph for this function:

◆ operator()()

template<typename R , typename... UArgs>
R ns3::CallbackImpl< R, UArgs >::operator() ( UArgs...  uargs) const
inline

Function call operator.

Parameters
uargsThe arguments to the Callback.
Returns
Callback value

Definition at line 280 of file callback.h.

References ns3::CallbackImpl< R, UArgs >::m_func.

Member Data Documentation

◆ m_components

template<typename R , typename... UArgs>
std::vector<std::shared_ptr<CallbackComponentBase> > ns3::CallbackImpl< R, UArgs >::m_components
private

Stores the original callable object and the bound arguments, if any.

Definition at line 351 of file callback.h.

Referenced by ns3::CallbackImpl< R, UArgs >::GetComponents(), and ns3::CallbackImpl< R, UArgs >::IsEqual().

◆ m_func

template<typename R , typename... UArgs>
std::function<R(UArgs...)> ns3::CallbackImpl< R, UArgs >::m_func
private

Stores the callable object associated with this callback (as a lambda)

Definition at line 348 of file callback.h.

Referenced by ns3::CallbackImpl< R, UArgs >::GetFunction(), and ns3::CallbackImpl< R, UArgs >::operator()().


The documentation for this class was generated from the following file: