AttributeValue implementation for structures. More...
#include "struct.h"
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. | |
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.
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.
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.
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.
| T | The structure represented by this AttributeValue. |
| Descriptors | An optional StructConstructor followed by StructField types describing the structure fields in declaration order. |
|
private |
TupleValue type used to store the structure fields.
| using ns3::StructValue< T, Descriptors >::result_type = T |
|
private |
| using ns3::StructValue< T, Descriptors >::tuple_type = typename internal::StructValueTraits<T, Descriptors...>::tuple_type |
Tuple of the values returned by the field AttributeValue objects.
| using ns3::StructValue< T, Descriptors >::value_type = typename internal::StructValueTraits<T, Descriptors...>::value_type |
Tuple of the field AttributeValue objects.
|
default |
Construct a StructValue containing default-initialized field values.
Referenced by Copy().
| ns3::StructValue< T, Fields >::StructValue | ( | const result_type & | value | ) |
Construct a StructValue from a structure.
| value | Value with which to construct this object. |
Definition at line 622 of file struct.h.
References Set().
|
override |
Definition at line 629 of file struct.h.
References StructValue(), ns3::Create(), and Get().
| StructValue< T, Fields... >::result_type ns3::StructValue< T, Fields >::Get | ( | ) | const |
Get the stored fields as a structure.
Definition at line 636 of file struct.h.
References ns3::internal::StructValueTraitsBase< T, nullptr, Fields... >::Construct().
Referenced by Copy(), StructValueTestCase::DoRun(), and GetAccessor().
| bool ns3::StructValue< T, Fields >::GetAccessor | ( | U & | value | ) | const |
Set the given variable to the structure represented by this object.
| U | The type of the given variable. |
| value | The variable to set. |
Definition at line 651 of file struct.h.
References Get().
| void ns3::StructValue< T, Fields >::Set | ( | const result_type & | value | ) |
Set the stored fields from a structure.
| value | the 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().
|
staticconstexpr |
Number of represented structure fields.