A Discrete-Event Network Simulator
API
ns3::PairValue< A, B > Class Template Reference

Hold objects of type std::pair<A, B>. More...

#include "pair.h"

+ Inheritance diagram for ns3::PairValue< A, B >:
+ Collaboration diagram for ns3::PairValue< A, B >:

Public Types

typedef std::invoke_result_t< decltype(&A::Get), A > first_type
 Type of abscissa (first entry of pair). More...
 
typedef std::pair< first_type, second_typeresult_type
 Type returned by Get or passed in Set. More...
 
typedef std::invoke_result_t< decltype(&B::Get), B > second_type
 Type of ordinal (second entry of pair). More...
 
typedef std::pair< Ptr< A >, Ptr< B > > value_type
 Type of value stored in the PairValue. More...
 

Public Member Functions

 PairValue ()
 
 PairValue (const result_type &value)
 Construct this PairValue from a std::pair. More...
 
Ptr< AttributeValueCopy (void) const
 
bool DeserializeFromString (std::string value, Ptr< const AttributeChecker > checker)
 
result_type Get (void) const
 Get the stored value as a std::pair. More...
 
template<typename T >
bool GetAccessor (T &value) const
 Access the Pair value as type T. More...
 
std::string SerializeToString (Ptr< const AttributeChecker > checker) const
 
void Set (const result_type &value)
 Set the value. 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 Attributes

value_type m_value
 The stored Pair instance. More...
 

Detailed Description

template<class A, class B>
class ns3::PairValue< A, B >

Hold objects of type std::pair<A, B>.

AttributeValue implementation for Pair.

See also
AttributeValue

Definition at line 55 of file pair.h.

Member Typedef Documentation

◆ first_type

template<class A , class B >
typedef std::invoke_result_t<decltype(&A::Get), A> ns3::PairValue< A, B >::first_type

Type of abscissa (first entry of pair).

Definition at line 61 of file pair.h.

◆ result_type

template<class A , class B >
typedef std::pair<first_type, second_type> ns3::PairValue< A, B >::result_type

Type returned by Get or passed in Set.

Definition at line 65 of file pair.h.

◆ second_type

template<class A , class B >
typedef std::invoke_result_t<decltype(&B::Get), B> ns3::PairValue< A, B >::second_type

Type of ordinal (second entry of pair).

Definition at line 63 of file pair.h.

◆ value_type

template<class A , class B >
typedef std::pair<Ptr<A>, Ptr<B> > ns3::PairValue< A, B >::value_type

Type of value stored in the PairValue.

Definition at line 59 of file pair.h.

Constructor & Destructor Documentation

◆ PairValue() [1/2]

template<class A , class B >
ns3::PairValue< A, B >::PairValue

Definition at line 268 of file pair.h.

◆ PairValue() [2/2]

template<class A , class B >
ns3::PairValue< A, B >::PairValue ( const result_type value)

Construct this PairValue from a std::pair.

Parameters
[in]valueValue with which to construct.

Member Function Documentation

◆ Copy()

template<class A , class B >
Ptr< AttributeValue > ns3::PairValue< A, B >::Copy ( void  ) const
virtual
Returns
a deep copy of this class, wrapped into an Attribute object.

Implements ns3::AttributeValue.

Definition at line 280 of file pair.h.

◆ DeserializeFromString()

template<class A , class B >
bool ns3::PairValue< A, B >::DeserializeFromString ( std::string  value,
Ptr< const AttributeChecker checker 
)
virtual
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 292 of file pair.h.

◆ Get()

template<class A , class B >
std::pair< A, B > ns3::PairValue< A, B >::Get ( void  ) const

Get the stored value as a std::pair.

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

Returns
stored value as std::pair<A, B>.
The Pair value.

Definition at line 330 of file pair.h.

Referenced by PairValueTestCase::DoRun().

+ Here is the caller graph for this function:

◆ GetAccessor()

template<class A , class B >
template<typename T >
bool ns3::PairValue< A, B >::GetAccessor ( T &  value) const

Access the Pair value as type T.

Template Parameters
T[explicit] The type to cast to.
Parameters
[out]valueThe Pair value, as type T.
Returns
true.

Definition at line 345 of file pair.h.

◆ SerializeToString()

template<class A , class B >
std::string ns3::PairValue< A, B >::SerializeToString ( Ptr< const AttributeChecker checker) const
virtual
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 318 of file pair.h.

◆ Set()

template<class A , class B >
void ns3::PairValue< A, B >::Set ( const result_type value)

Set the value.

Parameters
[in]valueThe value to adopt.

Definition at line 337 of file pair.h.

Referenced by PairValueTestCase::DoRun().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_value

template<class A , class B >
std::pair< A, B > ns3::PairValue< A, B >::m_value
private

The stored Pair instance.

Definition at line 96 of file pair.h.


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