A Discrete-Event Network Simulator
API
ns3::TupleValue< Args > Class Template Reference

Hold objects of type std::tuple<Args...>. More...

#include "tuple.h"

+ Inheritance diagram for ns3::TupleValue< Args >:
+ Collaboration diagram for ns3::TupleValue< Args >:

Public Types

typedef std::tuple< std::invoke_result_t< decltype(&Args::Get), Args >... > result_type
 Type returned by Get or passed in Set. More...
 
typedef std::tuple< Args... > value_type
 Type of value stored in the TupleValue. More...
 

Public Member Functions

 TupleValue ()
 
 TupleValue (const result_type &value)
 Construct this TupleValue from a std::tuple. More...
 
Ptr< AttributeValueCopy (void) const override
 
bool DeserializeFromString (std::string value, Ptr< const AttributeChecker > checker) override
 
result_type Get (void) const
 Get the stored values as a std::tuple. More...
 
template<typename T >
bool GetAccessor (T &value) const
 Set the given variable to the values stored by this TupleValue object. More...
 
value_type GetValue (void) const
 Get the attribute values as a tuple. More...
 
std::string SerializeToString (Ptr< const AttributeChecker > checker) const override
 
void Set (const result_type &value)
 Set the stored values. More...
 
- Public Member Functions inherited from ns3::AttributeValue
 AttributeValue ()
 
virtual ~AttributeValue ()
 
- Public Member Functions inherited from ns3::SimpleRefCount< AttributeValue >
 SimpleRefCount ()
 Default constructor. More...
 
 SimpleRefCount (const SimpleRefCount &o[[maybe_unused]])
 Copy constructor. More...
 
uint32_t GetReferenceCount (void) const
 Get the reference count of the object. More...
 
SimpleRefCountoperator= ([[maybe_unused]] const SimpleRefCount &o)
 Assignment operator. More...
 
void Ref (void) const
 Increment the reference count. More...
 
void Unref (void) const
 Decrement the reference count. More...
 

Private Member Functions

template<std::size_t... Is>
bool SetValueImpl (std::index_sequence< Is... >, const std::vector< Ptr< AttributeValue >> &values)
 Set the attribute values starting from the given values. More...
 

Private Attributes

value_type m_value
 Tuple of attribute values. More...
 

Detailed Description

template<class... Args>
class ns3::TupleValue< Args >

Hold objects of type std::tuple<Args...>.

AttributeValue implementation for Tuple.

Template Parameters
Args[explicit] The list of AttributeValues to be held by this TupleValue
See also
AttributeValue

Definition at line 69 of file tuple.h.

Member Typedef Documentation

◆ result_type

template<class... Args>
typedef std::tuple<std::invoke_result_t<decltype(&Args::Get),Args>...> ns3::TupleValue< Args >::result_type

Type returned by Get or passed in Set.

Definition at line 75 of file tuple.h.

◆ value_type

template<class... Args>
typedef std::tuple<Args...> ns3::TupleValue< Args >::value_type

Type of value stored in the TupleValue.

Definition at line 73 of file tuple.h.

Constructor & Destructor Documentation

◆ TupleValue() [1/2]

template<class... Args>
ns3::TupleValue< Args >::TupleValue

Definition at line 219 of file tuple.h.

◆ TupleValue() [2/2]

template<class... Args>
ns3::TupleValue< Args >::TupleValue ( const result_type value)

Construct this TupleValue from a std::tuple.

Parameters
[in]valueValue with which to construct.

Definition at line 225 of file tuple.h.

References ns3::Config::Set().

+ Here is the call graph for this function:

Member Function Documentation

◆ Copy()

template<class... Args>
Ptr< AttributeValue > ns3::TupleValue< Args >::Copy ( void  ) const
overridevirtual
Returns
a deep copy of this class, wrapped into an Attribute object.

Implements ns3::AttributeValue.

Definition at line 232 of file tuple.h.

References ns3::Create().

+ Here is the call graph for this function:

◆ DeserializeFromString()

template<class... Args>
bool ns3::TupleValue< Args >::DeserializeFromString ( std::string  value,
Ptr< const AttributeChecker checker 
)
overridevirtual
Parameters
[in]valueA string representation of the value
[in]checkerA pointer to the checker associated to the attribute.
Returns
true if the input string was correctly-formatted and could be successfully deserialized, false otherwise.

Upon return of this function, this AttributeValue instance contains the deserialized value. In most cases, this method will not make any use of the checker argument. However, in a very limited set of cases, the checker argument is needed to perform proper serialization. A nice example of code which needs it is the EnumValue::SerializeToString code.

Implements ns3::AttributeValue.

Definition at line 255 of file tuple.h.

◆ Get()

template<class... Args>
std::tuple< Args... > ns3::TupleValue< Args >::Get ( void  ) const

Get the stored values as a std::tuple.

This differs from the actual value stored in the object which is a tuple of Ptr<AV> where AV is a class derived from AttributeValue.

Returns
stored values as a std::tuple
The Tuple value.

Definition at line 314 of file tuple.h.

Referenced by TupleValueTestCase::DoRun().

+ Here is the caller graph for this function:

◆ GetAccessor()

template<class... Args>
template<typename T >
bool ns3::TupleValue< Args >::GetAccessor ( T &  value) const

Set the given variable to the values stored by this TupleValue object.

Access the Tuple value as type T.

Template Parameters
T[deduced] the type of the given variable (normally, the argument type of a set method or the type of a data member)
Returns
true if the given variable was set
Template Parameters
T[explicit] The type to cast to.
Parameters
[out]valueThe Tuple value, as type T.
Returns
true.

Definition at line 344 of file tuple.h.

◆ GetValue()

template<class... Args>
TupleValue< Args... >::value_type ns3::TupleValue< Args >::GetValue ( void  ) const

Get the attribute values as a tuple.

Returns
the attribute values as a tuple

Definition at line 336 of file tuple.h.

◆ SerializeToString()

template<class... Args>
std::string ns3::TupleValue< Args >::SerializeToString ( Ptr< const AttributeChecker checker) const
overridevirtual
Parameters
[in]checkerThe checker associated to the attribute
Returns
A string representation of this value.

In most cases, this method will not make any use of the checker argument. However, in a very limited set of cases, the checker argument is needed to perform proper serialization. A nice example of code which needs it is the EnumValue::SerializeToString code.

Implements ns3::AttributeValue.

Definition at line 305 of file tuple.h.

◆ Set()

template<class... Args>
void ns3::TupleValue< Args >::Set ( const result_type value)

Set the stored values.

Set the value.

Parameters
[in]valueThe value to adopt.

Definition at line 325 of file tuple.h.

Referenced by WifiPrimaryChannelsTest::DoSetup().

+ Here is the caller graph for this function:

◆ SetValueImpl()

template<class... Args>
template<std::size_t... Is>
bool ns3::TupleValue< Args >::SetValueImpl ( std::index_sequence< Is... >  ,
const std::vector< Ptr< AttributeValue >> &  values 
)
private

Set the attribute values starting from the given values.

Used by DeserializeFromString method.

Template Parameters
Is[deduced] index sequence
Parameters
valuesthe given attribute values
Returns
true if the attribute values of this object were set

Definition at line 240 of file tuple.h.

Member Data Documentation

◆ m_value

template<class... Args>
std::tuple< Args... > ns3::TupleValue< Args >::m_value
private

Tuple of attribute values.

The stored Tuple instance.

Definition at line 131 of file tuple.h.


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