20 #ifndef ATTRIBUTE_ACCESSOR_HELPER_H
21 #define ATTRIBUTE_ACCESSOR_HELPER_H
69 template <
typename V,
typename T1>
71 Ptr<const AttributeAccessor>
115 template <
typename V,
typename T1,
typename T2>
117 Ptr<const AttributeAccessor>
140 template <
typename T>
158 template <
typename T,
typename U>
180 const U *value =
dynamic_cast<const U *
> (&val);
185 T *obj =
dynamic_cast<T *
> (
object);
190 return DoSet (obj, value);
207 U *value =
dynamic_cast<U *
> (&val);
212 const T *obj =
dynamic_cast<const T *
> (
object);
217 return DoGet (obj, value);
229 virtual bool DoSet (T *
object,
const U *v)
const = 0;
238 virtual bool DoGet (
const T *
object, U *v)
const = 0;
255 template <
typename V,
typename T,
typename U>
268 MemberVariable (U T::*memberVariable)
270 m_memberVariable (memberVariable)
274 virtual bool DoSet (T *
object,
const V *v)
const
277 bool ok = v->GetAccessor (tmp);
282 (
object->*m_memberVariable) = tmp;
285 virtual bool DoGet (
const T *
object, V *v)
const
287 v->Set (
object->*m_memberVariable);
290 virtual bool HasGetter (
void)
const
294 virtual bool HasSetter (
void)
const
299 U T::*m_memberVariable;
317 template <
typename V,
typename T,
typename U>
319 Ptr<const AttributeAccessor>
330 MemberMethod (U (T::*getter)(
void)
const)
336 virtual bool DoSet ([[maybe_unused]] T *
object, [[maybe_unused]]
const V *v)
const
340 virtual bool DoGet (
const T *
object, V *v)
const
345 virtual bool HasGetter (
void)
const
349 virtual bool HasSetter (
void)
const
353 U (T::*m_getter)(void)
const;
372 template <
typename V,
typename T,
typename U>
374 Ptr<const AttributeAccessor>
385 MemberMethod (
void (T::*setter)(U))
391 virtual bool DoSet (T *
object,
const V *v)
const
394 bool ok = v->GetAccessor (tmp);
399 (
object->*m_setter)(tmp);
402 virtual bool DoGet ([[maybe_unused]]
const T *
object, [[maybe_unused]] V *v)
const
406 virtual bool HasGetter (
void)
const
410 virtual bool HasSetter (
void)
const
414 void (T::*m_setter)(U);
437 template <
typename W,
typename T,
typename U,
typename V>
439 Ptr<const AttributeAccessor>
441 V (T::*getter)(
void)
const)
455 MemberMethod (
void (T::*setter)(U),
456 V (T::*getter)(
void)
const)
463 virtual bool DoSet (T *
object,
const W *v)
const
466 bool ok = v->GetAccessor (tmp);
471 (
object->*m_setter)(tmp);
474 virtual bool DoGet (
const T *
object, W *v)
const
479 virtual bool HasGetter (
void)
const
483 virtual bool HasSetter (
void)
const
487 void (T::*m_setter)(U);
488 V (T::*m_getter)(void)
const;
498 template <
typename W,
typename T,
typename U,
typename V>
500 Ptr<const AttributeAccessor>
502 void (T::*setter)(U))
504 return DoMakeAccessorHelperTwo<W> (setter, getter);
525 template <
typename W,
typename T,
typename U,
typename V>
527 Ptr<const AttributeAccessor>
529 V (T::*getter)(
void)
const)
543 MemberMethod (
bool (T::*setter)(U),
544 V (T::*getter)(
void)
const)
551 virtual bool DoSet (T *
object,
const W *v)
const
554 bool ok = v->GetAccessor (tmp);
559 ok = (
object->*m_setter)(tmp);
562 virtual bool DoGet (
const T *
object, W *v)
const
567 virtual bool HasGetter (
void)
const
571 virtual bool HasSetter (
void)
const
575 bool (T::*m_setter)(U);
576 V (T::*m_getter)(void)
const;
586 template <
typename W,
typename T,
typename U,
typename V>
588 Ptr<const AttributeAccessor>
590 bool (T::*setter)(U))
592 return DoMakeAccessorHelperTwo<W> (setter, getter);
596 template <
typename V,
typename T1>
598 Ptr<const AttributeAccessor>
601 return DoMakeAccessorHelperOne<V> (a1);
604 template <
typename V,
typename T1,
typename T2>
606 Ptr<const AttributeAccessor>
609 return DoMakeAccessorHelperTwo<V> (a1, a2);
ns3::AttributeValue, ns3::AttributeAccessor and ns3::AttributeChecker declarations.
Basic functionality for accessing class attributes via class data members, or get functor/set methods...
virtual bool Set(ObjectBase *object, const AttributeValue &val) const
Set the underlying member to the argument AttributeValue.
AccessorHelper()
Constructor.
virtual bool Get(const ObjectBase *object, AttributeValue &val) const
Get the value of the underlying member into the AttributeValue.
virtual bool DoGet(const T *object, U *v) const =0
Getter implementation.
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 > DoMakeAccessorHelperTwo(void(T::*setter)(U), V(T::*getter)(void) const)
MakeAccessorHelper implementation with a class get functor method and a class set method returning vo...
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 > DoMakeAccessorHelperOne(U T::*memberVariable)
MakeAccessorHelper implementation for a class data member.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
The non-const and non-reference type equivalent to T.
TypeTraits< typename TypeTraits< T >::ReferencedType >::NonConstType Result
The non-const, non reference type.
Inspect a type to deduce its features.
ns3::TypeTraits introspection declaration and template implementation.