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>
179 const U *value =
dynamic_cast<const U *
> (&val);
184 T *obj =
dynamic_cast<T *
> (object);
189 return DoSet (obj, value);
205 U *value =
dynamic_cast<U *
> (&val);
210 const T *obj =
dynamic_cast<const T *
> (object);
215 return DoGet (obj, value);
227 virtual bool DoSet (T *
object,
const U *v)
const = 0;
236 virtual bool DoGet (
const T *
object, U *v)
const = 0;
253 template <
typename V,
typename T,
typename U>
255 Ptr<const AttributeAccessor>
266 MemberVariable (U T::*memberVariable)
268 m_memberVariable (memberVariable)
271 virtual bool DoSet (T *
object,
const V *v)
const {
273 bool ok = v->GetAccessor (tmp);
278 (
object->*m_memberVariable) = tmp;
281 virtual bool DoGet (
const T *
object, V *v)
const {
282 v->Set (object->*m_memberVariable);
285 virtual bool HasGetter (
void)
const {
288 virtual bool HasSetter (
void)
const {
292 U T::*m_memberVariable;
310 template <
typename V,
typename T,
typename U>
312 Ptr<const AttributeAccessor>
323 MemberMethod (U (T::*getter)(
void)
const)
328 virtual bool DoSet (T *
object,
const V *v)
const {
333 virtual bool DoGet (
const T *
object, V *v)
const {
334 v->Set ((object->*m_getter)());
337 virtual bool HasGetter (
void)
const {
340 virtual bool HasSetter (
void)
const {
343 U (T::*m_getter)(void)
const;
362 template <
typename V,
typename T,
typename U>
364 Ptr<const AttributeAccessor>
375 MemberMethod (
void (T::*setter)(U))
380 virtual bool DoSet (T *
object,
const V *v)
const {
382 bool ok = v->GetAccessor (tmp);
387 (
object->*m_setter)(tmp);
390 virtual bool DoGet (
const T *
object, V *v)
const {
395 virtual bool HasGetter (
void)
const {
398 virtual bool HasSetter (
void)
const {
401 void (T::*m_setter)(U);
424 template <
typename W,
typename T,
typename U,
typename V>
426 Ptr<const AttributeAccessor>
428 V (T::*getter)(
void)
const)
442 MemberMethod (
void (T::*setter)(U),
443 V (T::*getter)(
void)
const)
449 virtual bool DoSet (T *
object,
const W *v)
const {
451 bool ok = v->GetAccessor (tmp);
456 (
object->*m_setter)(tmp);
459 virtual bool DoGet (
const T *
object, W *v)
const {
460 v->
Set ((object->*m_getter)());
463 virtual bool HasGetter (
void)
const {
466 virtual bool HasSetter (
void)
const {
469 void (T::*m_setter)(U);
470 V (T::*m_getter)(void)
const;
480 template <
typename W,
typename T,
typename U,
typename V>
482 Ptr<const AttributeAccessor>
484 void (T::*setter)(U))
486 return DoMakeAccessorHelperTwo<W> (setter, getter);
507 template <
typename W,
typename T,
typename U,
typename V>
509 Ptr<const AttributeAccessor>
511 V (T::*getter)(
void)
const)
525 MemberMethod (
bool (T::*setter)(U),
526 V (T::*getter)(
void)
const)
532 virtual bool DoSet (T *
object,
const W *v)
const {
534 bool ok = v->GetAccessor (tmp);
539 ok = (
object->*m_setter)(tmp);
542 virtual bool DoGet (
const T *
object, W *v)
const {
543 v->
Set ((object->*m_getter)());
546 virtual bool HasGetter (
void)
const {
549 virtual bool HasSetter (
void)
const {
552 bool (T::*m_setter)(U);
553 V (T::*m_getter)(void)
const;
563 template <
typename W,
typename T,
typename U,
typename V>
565 Ptr<const AttributeAccessor>
567 bool (T::*setter)(U))
569 return DoMakeAccessorHelperTwo<W> (setter, getter);
573 template <
typename V,
typename T1>
575 Ptr<const AttributeAccessor>
578 return DoMakeAccessorHelperOne<V> (a1);
581 template <
typename V,
typename T1,
typename T2>
583 Ptr<const AttributeAccessor>
586 return DoMakeAccessorHelperTwo<V> (a1, a2);
Smart pointer class similar to boost::intrusive_ptr.
Hold a value for an Attribute.
Ptr< const AttributeAccessor > MakeAccessorHelper(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
#define NS_UNUSED(x)
Mark a local variable as unused.
Anchor the ns-3 type and attribute system.
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...
ns3::AttributeValue, ns3::AttributeAccessor and ns3::AttributeChecker declarations.
virtual bool DoSet(T *object, const U *v) const =0
Setter implementation.
allow setting and getting the value of an attribute.
TypeTraits< typename TypeTraits< T >::ReferencedType >::NonConstType Result
The non-const, non reference type.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Inspect a type to deduce its features.
Basic functionality for accessing class attributes via class data members, or get functor/set methods...
The non-const and non-reference type equivalent to T.
AccessorHelper()
Constructor.
Ptr< const AttributeAccessor > DoMakeAccessorHelperOne(U T::*memberVariable)
MakeAccessorHelper implementation for a class data member.
ns3::TypeTraits introspection declaration and template implementation.
virtual bool Set(ObjectBase *object, const AttributeValue &val) const
Set the underlying member to the argument AttributeValue.
virtual bool DoGet(const T *object, U *v) const =0
Getter implementation.
virtual bool Get(const ObjectBase *object, AttributeValue &val) const
Get the value of the underlying member into the AttributeValue.
NS_UNUSED and NS_UNUSED_GLOBAL macro definitions.