8#ifndef ATTRIBUTE_ACCESSOR_HELPER_H
9#define ATTRIBUTE_ACCESSOR_HELPER_H
57template <
typename V,
typename T1>
100template <
typename V,
typename T1,
typename T2>
109#include <type_traits>
138template <
typename T,
typename U>
161 const U* value =
dynamic_cast<const U*
>(&val);
162 if (value ==
nullptr)
166 T* obj =
dynamic_cast<T*
>(
object);
171 return DoSet(obj, value);
188 U* value =
dynamic_cast<U*
>(&val);
189 if (value ==
nullptr)
193 const T* obj =
dynamic_cast<const T*
>(
object);
198 return DoGet(obj, value);
210 virtual bool DoSet(T*
object,
const U* v)
const = 0;
219 virtual bool DoGet(
const T*
object, U* v)
const = 0;
235template <
typename V,
typename T,
typename U>
247 MemberVariable(U T::*memberVariable)
249 m_memberVariable(memberVariable)
254 bool DoSet(T*
object,
const V* v)
const override
257 bool ok = v->GetAccessor(tmp);
262 (
object->*m_memberVariable) = tmp;
266 bool DoGet(
const T*
object, V* v)
const override
268 v->Set(
object->*m_memberVariable);
272 bool HasGetter()
const override
277 bool HasSetter()
const override
282 U T::*m_memberVariable;
300template <
typename V,
typename T,
typename U>
301inline Ptr<const AttributeAccessor>
312 MemberMethod(U (T::*getter)()
const)
319 bool DoSet(T* ,
const V* )
const override
324 bool DoGet(
const T*
object, V* v)
const override
330 bool HasGetter()
const override
335 bool HasSetter()
const override
340 U (T::*m_getter)()
const;
359template <
typename V,
typename T,
typename U>
360inline Ptr<const AttributeAccessor>
371 MemberMethod(
void (T::*setter)(U))
378 bool DoSet(T*
object,
const V* v)
const override
381 bool ok = v->GetAccessor(tmp);
386 (
object->*m_setter)(tmp);
390 bool DoGet(
const T* , V* )
const override
395 bool HasGetter()
const override
400 bool HasSetter()
const override
405 void (T::*m_setter)(U);
428template <
typename W,
typename T,
typename U,
typename V>
429inline Ptr<const AttributeAccessor>
444 MemberMethod(
void (T::*setter)(U), V (T::*getter)()
const)
452 bool DoSet(T*
object,
const W* v)
const override
455 bool ok = v->GetAccessor(tmp);
460 (
object->*m_setter)(tmp);
464 bool DoGet(
const T*
object, W* v)
const override
470 bool HasGetter()
const override
475 bool HasSetter()
const override
480 void (T::*m_setter)(U);
481 V (T::*m_getter)()
const;
491template <
typename W,
typename T,
typename U,
typename V>
492inline Ptr<const AttributeAccessor>
515template <
typename W,
typename T,
typename U,
typename V>
516inline Ptr<const AttributeAccessor>
531 MemberMethod(
bool (T::*setter)(U), V (T::*getter)()
const)
539 bool DoSet(T*
object,
const W* v)
const override
542 bool ok = v->GetAccessor(tmp);
547 ok = (
object->*m_setter)(tmp);
551 bool DoGet(
const T*
object, W* v)
const override
553 v->Set((
object->*m_getter)());
557 bool HasGetter()
const override
562 bool HasSetter()
const override
567 bool (T::*m_setter)(U);
568 V (T::*m_getter)()
const;
578template <
typename W,
typename T,
typename U,
typename V>
579inline Ptr<const AttributeAccessor>
585template <
typename V,
typename T1>
586inline Ptr<const AttributeAccessor>
592template <
typename V,
typename T1,
typename T2>
593inline Ptr<const AttributeAccessor>
ns3::AttributeValue, ns3::AttributeAccessor and ns3::AttributeChecker declarations.
Basic functionality for accessing class attributes via class data members, or get functor/set methods...
bool Set(ObjectBase *object, const AttributeValue &val) const override
Set the underlying member to the argument AttributeValue.
AccessorHelper()
Constructor.
virtual bool DoGet(const T *object, U *v) const =0
Getter implementation.
bool Get(const ObjectBase *object, AttributeValue &val) const override
Get the value of the underlying member into the AttributeValue.
virtual bool DoSet(T *object, const U *v) const =0
Setter implementation.
allow setting and getting the value of an attribute.
Hold a value for an Attribute.
Anchor the ns-3 type and attribute system.
Smart pointer class similar to boost::intrusive_ptr.
Ptr< const AttributeAccessor > DoMakeAccessorHelperOne(U T::*memberVariable)
MakeAccessorHelper implementation for a class data member.
Ptr< const AttributeAccessor > MakeAccessorHelper(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > DoMakeAccessorHelperTwo(void(T::*setter)(U), V(T::*getter)() const)
MakeAccessorHelper implementation with a class get functor method and a class set method returning vo...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
The non-const and non-reference type equivalent to T .
std::remove_cvref_t< T > Result
The non-const, non reference type.