20 #ifndef ATTRIBUTE_ACCESSOR_HELPER_H
21 #define ATTRIBUTE_ACCESSOR_HELPER_H
70 template <
typename V,
typename T1>
72 Ptr<const AttributeAccessor>
116 template <
typename V,
typename T1,
typename T2>
118 Ptr<const AttributeAccessor>
141 template <
typename T>
159 template <
typename T,
typename U>
181 const U *value =
dynamic_cast<const U *
> (&val);
186 T *obj =
dynamic_cast<T *
> (object);
191 return DoSet (obj, value);
208 U *value =
dynamic_cast<U *
> (&val);
213 const T *obj =
dynamic_cast<const T *
> (object);
218 return DoGet (obj, value);
230 virtual bool DoSet (T *
object,
const U *v)
const = 0;
239 virtual bool DoGet (
const T *
object, U *v)
const = 0;
256 template <
typename V,
typename T,
typename U>
269 MemberVariable (U T::*memberVariable)
271 m_memberVariable (memberVariable)
275 virtual bool DoSet (T *
object,
const V *v)
const
278 bool ok = v->GetAccessor (tmp);
283 (
object->*m_memberVariable) = tmp;
286 virtual bool DoGet (
const T *
object, V *v)
const
288 v->Set (object->*m_memberVariable);
291 virtual bool HasGetter (
void)
const
295 virtual bool HasSetter (
void)
const
300 U T::*m_memberVariable;
318 template <
typename V,
typename T,
typename U>
320 Ptr<const AttributeAccessor>
331 MemberMethod (U (T::*getter)(
void)
const)
337 virtual bool DoSet (T *
object,
const V *v)
const
343 virtual bool DoGet (
const T *
object, V *v)
const
345 v->Set ((object->*m_getter)());
348 virtual bool HasGetter (
void)
const
352 virtual bool HasSetter (
void)
const
356 U (T::*m_getter)(void)
const;
375 template <
typename V,
typename T,
typename U>
377 Ptr<const AttributeAccessor>
388 MemberMethod (
void (T::*setter)(U))
394 virtual bool DoSet (T *
object,
const V *v)
const
397 bool ok = v->GetAccessor (tmp);
402 (
object->*m_setter)(tmp);
405 virtual bool DoGet (
const T *
object, V *v)
const
411 virtual bool HasGetter (
void)
const
415 virtual bool HasSetter (
void)
const
419 void (T::*m_setter)(U);
442 template <
typename W,
typename T,
typename U,
typename V>
444 Ptr<const AttributeAccessor>
446 V (T::*getter)(
void)
const)
460 MemberMethod (
void (T::*setter)(U),
461 V (T::*getter)(
void)
const)
468 virtual bool DoSet (T *
object,
const W *v)
const
471 bool ok = v->GetAccessor (tmp);
476 (
object->*m_setter)(tmp);
479 virtual bool DoGet (
const T *
object, W *v)
const
481 v->
Set ((object->*m_getter)());
484 virtual bool HasGetter (
void)
const
488 virtual bool HasSetter (
void)
const
492 void (T::*m_setter)(U);
493 V (T::*m_getter)(void)
const;
503 template <
typename W,
typename T,
typename U,
typename V>
505 Ptr<const AttributeAccessor>
507 void (T::*setter)(U))
509 return DoMakeAccessorHelperTwo<W> (setter, getter);
530 template <
typename W,
typename T,
typename U,
typename V>
532 Ptr<const AttributeAccessor>
534 V (T::*getter)(
void)
const)
548 MemberMethod (
bool (T::*setter)(U),
549 V (T::*getter)(
void)
const)
556 virtual bool DoSet (T *
object,
const W *v)
const
559 bool ok = v->GetAccessor (tmp);
564 ok = (
object->*m_setter)(tmp);
567 virtual bool DoGet (
const T *
object, W *v)
const
569 v->
Set ((object->*m_getter)());
572 virtual bool HasGetter (
void)
const
576 virtual bool HasSetter (
void)
const
580 bool (T::*m_setter)(U);
581 V (T::*m_getter)(void)
const;
591 template <
typename W,
typename T,
typename U,
typename V>
593 Ptr<const AttributeAccessor>
595 bool (T::*setter)(U))
597 return DoMakeAccessorHelperTwo<W> (setter, getter);
601 template <
typename V,
typename T1>
603 Ptr<const AttributeAccessor>
606 return DoMakeAccessorHelperOne<V> (a1);
609 template <
typename V,
typename T1,
typename T2>
611 Ptr<const AttributeAccessor>
614 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.
#define NS_UNUSED(x)
Mark a local variable as unused.
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.
NS_UNUSED and NS_UNUSED_GLOBAL macro definitions.