A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::StructValue< T, Descriptors > Class Template Reference

AttributeValue implementation for structures. More...

#include "struct.h"

Inheritance diagram for ns3::StructValue< T, Descriptors >:
Collaboration diagram for ns3::StructValue< T, Descriptors >:

Public Types

using result_type = T
 The represented structure type.
using tuple_type = typename internal::StructValueTraits<T, Descriptors...>::tuple_type
 Tuple of the values returned by the field AttributeValue objects.
using value_type = typename internal::StructValueTraits<T, Descriptors...>::value_type
 Tuple of the field AttributeValue objects.

Public Member Functions

 StructValue ()=default
 Construct a StructValue containing default-initialized field values.
 StructValue (const result_type &value)
 Construct a StructValue from a structure.
Ptr< AttributeValue > Copy () const override
result_type Get () const
 Get the stored fields as a structure.
template<typename U>
bool GetAccessor (U &value) const
 Set the given variable to the structure represented by this object.
void Set (const result_type &value)
 Set the stored fields from a structure.

Static Public Attributes

static constexpr std::size_t field_count
 Number of represented structure fields.

Private Types

using Base = typename Traits::base_type
 TupleValue type used to store the structure fields.
using Traits = internal::StructValueTraits<T, Descriptors...>
 Traits describing the constructor and fields.

Detailed Description

template<typename T, typename... Descriptors>
class ns3::StructValue< T, Descriptors >

AttributeValue implementation for structures.

The fields of the structure are stored internally as a tuple of AttributeValue objects. StructField instances associate every structure field with the AttributeValue type used to represent it and specify how to access it.

struct Data
{
uint16_t count;
double value;
};
using DataValue =
AttributeValue implementation for structures.
Definition struct.h:144
Describe a structure field and the AttributeValue used to represent it.
Definition struct.h:227

Getter and setter methods can be used for private fields. In this case, the represented type must be default constructible because Get() reconstructs it by invoking each setter on a default-constructed instance.

using DataValue =
StructValue()=default
Construct a StructValue containing default-initialized field values.

A constructor function can be used when fields have getters but no setters. The StructConstructor descriptor, when present, must precede the StructField descriptors and identify a static member or free factory function that accepts all field values in order and returns the structure.

using DataValue =
Describe a function that constructs a structure from its field values.
Definition struct.h:262

Get() constructs the represented structure by using, in order of priority, direct aggregate or constructor initialization when all fields are data members, the provided constructor function, or default construction followed by the field setters. If a data member is not directly assignable from the value returned by its AttributeValue, GetAccessor() performs the conversion.

Template Parameters
TThe structure represented by this AttributeValue.
DescriptorsAn optional StructConstructor followed by StructField types describing the structure fields in declaration order.
See also
AttributeValue

Definition at line 143 of file struct.h.

Member Typedef Documentation

◆ Base

template<typename T, typename... Descriptors>
using ns3::StructValue< T, Descriptors >::Base = typename Traits::base_type
private

TupleValue type used to store the structure fields.

Definition at line 201 of file struct.h.

◆ result_type

template<typename T, typename... Descriptors>
using ns3::StructValue< T, Descriptors >::result_type = T

The represented structure type.

Definition at line 147 of file struct.h.

◆ Traits

template<typename T, typename... Descriptors>
using ns3::StructValue< T, Descriptors >::Traits = internal::StructValueTraits<T, Descriptors...>
private

Traits describing the constructor and fields.

Definition at line 199 of file struct.h.

◆ tuple_type

template<typename T, typename... Descriptors>
using ns3::StructValue< T, Descriptors >::tuple_type = typename internal::StructValueTraits<T, Descriptors...>::tuple_type

Tuple of the values returned by the field AttributeValue objects.

Definition at line 149 of file struct.h.

◆ value_type

template<typename T, typename... Descriptors>
using ns3::StructValue< T, Descriptors >::value_type = typename internal::StructValueTraits<T, Descriptors...>::value_type

Tuple of the field AttributeValue objects.

Definition at line 151 of file struct.h.

Constructor & Destructor Documentation

◆ StructValue() [1/2]

template<typename T, typename... Descriptors>
ns3::StructValue< T, Descriptors >::StructValue ( )
default

Construct a StructValue containing default-initialized field values.

Referenced by Copy().

Here is the caller graph for this function:

◆ StructValue() [2/2]

template<typename T, typename... Fields>
ns3::StructValue< T, Fields >::StructValue ( const result_type & value)

Construct a StructValue from a structure.

Parameters
valueValue with which to construct this object.

Definition at line 622 of file struct.h.

References Set().

Here is the call graph for this function:

Member Function Documentation

◆ Copy()

template<typename T, typename... Fields>
Ptr< AttributeValue > ns3::StructValue< T, Fields >::Copy ( ) const
override
Returns
a deep copy of this class, wrapped into an Attribute object.

Definition at line 629 of file struct.h.

References StructValue(), ns3::Create(), and Get().

Here is the call graph for this function:

◆ Get()

template<typename T, typename... Fields>
StructValue< T, Fields... >::result_type ns3::StructValue< T, Fields >::Get ( ) const

Get the stored fields as a structure.

Returns
the structure containing the stored field values

Definition at line 636 of file struct.h.

References ns3::internal::StructValueTraitsBase< T, nullptr, Fields... >::Construct().

Referenced by Copy(), StructValueTestCase::DoRun(), and GetAccessor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetAccessor()

template<typename T, typename... Fields>
template<typename U>
bool ns3::StructValue< T, Fields >::GetAccessor ( U & value) const

Set the given variable to the structure represented by this object.

Template Parameters
UThe type of the given variable.
Parameters
valueThe variable to set.
Returns
true if the given variable was set

Definition at line 651 of file struct.h.

References Get().

Here is the call graph for this function:

◆ Set()

template<typename T, typename... Fields>
void ns3::StructValue< T, Fields >::Set ( const result_type & value)

Set the stored fields from a structure.

Parameters
valuethe structure containing the field values to store

Definition at line 643 of file struct.h.

References ns3::internal::StructValueTraitsBase< T, nullptr, Fields... >::Read().

Referenced by StructValue().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ field_count

template<typename T, typename... Descriptors>
std::size_t ns3::StructValue< T, Descriptors >::field_count
staticconstexpr
Initial value:
=
static constexpr std::size_t field_count
Number of represented structure fields.
Definition struct.h:154
Select the StructValue implementation when no constructor function is provided.
Definition struct.h:405

Number of represented structure fields.

Definition at line 154 of file struct.h.


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