19 #ifndef ATTRIBUTE_ACCESSOR_HELPER_H
20 #define ATTRIBUTE_ACCESSOR_HELPER_H
68 template <
typename V,
typename T1>
111 template <
typename V,
typename T1,
typename T2>
132 template <
typename T>
149 template <
typename T,
typename U>
172 const U* value =
dynamic_cast<const U*
>(&val);
173 if (value ==
nullptr)
177 T* obj =
dynamic_cast<T*
>(
object);
182 return DoSet(obj, value);
199 U* value =
dynamic_cast<U*
>(&val);
200 if (value ==
nullptr)
204 const T* obj =
dynamic_cast<const T*
>(
object);
209 return DoGet(obj, value);
221 virtual bool DoSet(T*
object,
const U* v)
const = 0;
230 virtual bool DoGet(
const T*
object, U* v)
const = 0;
246 template <
typename V,
typename T,
typename U>
258 MemberVariable(U T::*memberVariable)
260 m_memberVariable(memberVariable)
265 bool DoSet(T*
object,
const V* v)
const override
268 bool ok = v->GetAccessor(tmp);
273 (
object->*m_memberVariable) = tmp;
277 bool DoGet(
const T*
object, V* v)
const override
279 v->Set(
object->*m_memberVariable);
283 bool HasGetter()
const override
288 bool HasSetter()
const override
293 U T::*m_memberVariable;
311 template <
typename V,
typename T,
typename U>
312 inline Ptr<const AttributeAccessor>
323 MemberMethod(U (T::*getter)()
const)
330 bool DoSet(T* ,
const V* )
const override
335 bool DoGet(
const T*
object, V* v)
const override
341 bool HasGetter()
const override
346 bool HasSetter()
const override
351 U (T::*m_getter)()
const;
370 template <
typename V,
typename T,
typename U>
371 inline Ptr<const AttributeAccessor>
382 MemberMethod(
void (T::*setter)(U))
389 bool DoSet(T*
object,
const V* v)
const override
392 bool ok = v->GetAccessor(tmp);
397 (
object->*m_setter)(tmp);
401 bool DoGet(
const T* , V* )
const override
406 bool HasGetter()
const override
411 bool HasSetter()
const override
416 void (T::*m_setter)(U);
439 template <
typename W,
typename T,
typename U,
typename V>
440 inline Ptr<const AttributeAccessor>
455 MemberMethod(
void (T::*setter)(U), V (T::*getter)()
const)
463 bool DoSet(T*
object,
const W* v)
const override
466 bool ok = v->GetAccessor(tmp);
471 (
object->*m_setter)(tmp);
475 bool DoGet(
const T*
object, W* v)
const override
481 bool HasGetter()
const override
486 bool HasSetter()
const override
491 void (T::*m_setter)(U);
492 V (T::*m_getter)()
const;
502 template <
typename W,
typename T,
typename U,
typename V>
503 inline Ptr<const AttributeAccessor>
506 return DoMakeAccessorHelperTwo<W>(setter, getter);
526 template <
typename W,
typename T,
typename U,
typename V>
527 inline Ptr<const AttributeAccessor>
542 MemberMethod(
bool (T::*setter)(U), V (T::*getter)()
const)
550 bool DoSet(T*
object,
const W* v)
const override
553 bool ok = v->GetAccessor(tmp);
558 ok = (
object->*m_setter)(tmp);
562 bool DoGet(
const T*
object, W* v)
const override
568 bool HasGetter()
const override
573 bool HasSetter()
const override
578 bool (T::*m_setter)(U);
579 V (T::*m_getter)()
const;
589 template <
typename W,
typename T,
typename U,
typename V>
590 inline Ptr<const AttributeAccessor>
593 return DoMakeAccessorHelperTwo<W>(setter, getter);
596 template <
typename V,
typename T1>
597 inline Ptr<const AttributeAccessor>
600 return DoMakeAccessorHelperOne<V>(a1);
603 template <
typename V,
typename T1,
typename T2>
604 inline Ptr<const AttributeAccessor>
607 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...
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 > DoMakeAccessorHelperTwo(void(T::*setter)(U), V(T::*getter)() 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.