31template <
class A,
class B>
33operator<<(std::ostream& os,
const std::pair<A, B>& p)
35 os <<
"(" << p.first <<
"," << p.second <<
")";
52template <
class A,
class B>
59 typedef typename std::invoke_result_t<
decltype(&A::Get), A>
first_type;
61 typedef typename std::invoke_result_t<
decltype(&B::Get), B>
second_type;
63 typedef typename std::pair<first_type, second_type>
result_type;
90 result_type
Get()
const;
95 void Set(
const result_type& value);
103 template <
typename T>
148template <
class A,
class B>
163template <
class A,
class B>
174template <
class A,
class B>
187template <
typename A,
typename B,
typename T1>
211template <
class A,
class B>
235template <
class A,
class B>
237 : m_firstchecker(nullptr),
238 m_secondchecker(nullptr)
242template <
class A,
class B>
245 : m_firstchecker(firstchecker),
246 m_secondchecker(secondchecker)
250template <
class A,
class B>
255 m_firstchecker = firstchecker;
256 m_secondchecker = secondchecker;
259template <
class A,
class B>
263 return std::make_pair(m_firstchecker, m_secondchecker);
268template <
class A,
class B>
275template <
class A,
class B>
276Ptr<const AttributeChecker>
281 acchecker->SetCheckers(firstchecker, secondchecker);
285template <
class A,
class B>
289 std::string pairName;
290 std::string underlyingType;
292 std::string first_type_name =
typeid(
typename T::value_type::first_type).name();
293 std::string second_type_name =
typeid(
typename T::value_type::second_type).name();
295 std::ostringstream oss;
296 oss <<
"ns3::PairValue<" << first_type_name <<
", " << second_type_name <<
">";
297 pairName = oss.str();
301 std::ostringstream oss;
302 oss <<
typeid(
typename T::value_type).name();
303 underlyingType = oss.str();
309template <
class A,
class B>
317 p->m_value = std::make_pair(
DynamicCast<A>(m_value.first->Copy()),
323template <
class A,
class B>
333 std::istringstream iss(value);
335 auto first = pchecker->GetCheckers().first->CreateValidValue(
StringValue(value));
348 auto second = pchecker->GetCheckers().second->CreateValidValue(
StringValue(value));
360 m_value = std::make_pair(firstattr, secondattr);
364template <
class A,
class B>
368 std::ostringstream oss;
369 oss << m_value.first->SerializeToString(checker);
371 oss << m_value.second->SerializeToString(checker);
376template <
class A,
class B>
380 return std::make_pair(m_value.first->Get(), m_value.second->Get());
383template <
class A,
class B>
390template <
class A,
class B>
399template <
typename A,
typename B,
typename T1>
Attribute helper (ATTRIBUTE_ )macros definition.
Represent the type of an attribute.
Hold a value for an Attribute.
AttributeChecker implementation for PairValue.
virtual void SetCheckers(Ptr< const AttributeChecker > firstchecker, Ptr< const AttributeChecker > secondchecker)=0
Set the individual AttributeChecker for each pair entry.
std::pair< Ptr< const AttributeChecker >, Ptr< const AttributeChecker > > checker_pair_type
Type holding an AttributeChecker for each member of a pair.
virtual checker_pair_type GetCheckers() const =0
Get the pair of checkers for each pair entry.
AttributeValue implementation for Pair.
PairValue(const result_type &value)
Construct this PairValue from a std::pair.
std::pair< first_type, second_type > result_type
Type returned by Get or passed in Set.
result_type Get() const
Get the stored value as a std::pair.
bool GetAccessor(T &value) const
Access the Pair value as type T.
std::invoke_result_t< decltype(&A::Get), A > first_type
Type of abscissa (first entry of pair).
std::pair< Ptr< A >, Ptr< B > > value_type
Type of value stored in the PairValue.
value_type m_value
The stored Pair instance.
std::string SerializeToString(Ptr< const AttributeChecker > checker) const override
void Set(const result_type &value)
Set the value.
std::invoke_result_t< decltype(&B::Get), B > second_type
Type of ordinal (second entry of pair).
bool DeserializeFromString(std::string value, Ptr< const AttributeChecker > checker) override
Ptr< AttributeValue > Copy() const override
Smart pointer class similar to boost::intrusive_ptr.
Hold variables of type string.
Internal checker class templated to each AttributeChecker for each entry in the pair.
Ptr< const AttributeChecker > m_secondchecker
The second checker.
Ptr< const AttributeChecker > m_firstchecker
The first checker.
void SetCheckers(Ptr< const AttributeChecker > firstchecker, Ptr< const AttributeChecker > secondchecker) override
Set the individual AttributeChecker for each pair entry.
ns3::PairChecker::checker_pair_type GetCheckers() const override
Get the pair of checkers for each pair entry.
PairChecker()
Default c'tor.
Ptr< const AttributeAccessor > MakePairAccessor(T1 a1)
Create an AttributeAccessor for std::pair<>.
Ptr< AttributeChecker > MakePairChecker()
Make a PairChecker without abscissa and ordinate AttributeCheckers.
Ptr< const AttributeAccessor > MakeAccessorHelper(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< AttributeChecker > MakeSimpleAttributeChecker(std::string name, std::string underlying)
A simple string-based attribute checker.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
ns3::StringValue attribute value declarations.