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>
178 const U *value =
dynamic_cast<const U *
> (&val);
183 T *obj =
dynamic_cast<T *
> (object);
188 return DoSet (obj, value);
204 U *value =
dynamic_cast<U *
> (&val);
209 const T *obj =
dynamic_cast<const T *
> (object);
214 return DoGet (obj, value);
226 virtual bool DoSet (T *
object,
const U *v)
const = 0;
235 virtual bool DoGet (
const T *
object, U *v)
const = 0;
252 template <
typename V,
typename T,
typename U>
254 Ptr<const AttributeAccessor>
265 MemberVariable (U T::*memberVariable)
267 m_memberVariable (memberVariable)
270 virtual bool DoSet (T *
object,
const V *v)
const {
272 bool ok = v->GetAccessor (tmp);
277 (
object->*m_memberVariable) = tmp;
280 virtual bool DoGet (
const T *
object, V *v)
const {
281 v->Set (object->*m_memberVariable);
284 virtual bool HasGetter (
void)
const {
287 virtual bool HasSetter (
void)
const {
291 U T::*m_memberVariable;
309 template <
typename V,
typename T,
typename U>
311 Ptr<const AttributeAccessor>
322 MemberMethod (U (T::*getter)(
void)
const)
327 virtual bool DoSet (T *
object,
const V *v)
const {
330 virtual bool DoGet (
const T *
object, V *v)
const {
331 v->
Set ((object->*m_getter)());
334 virtual bool HasGetter (
void)
const {
337 virtual bool HasSetter (
void)
const {
340 U (T::*m_getter)(void)
const;
359 template <
typename V,
typename T,
typename U>
361 Ptr<const AttributeAccessor>
372 MemberMethod (
void (T::*setter)(U))
377 virtual bool DoSet (T *
object,
const V *v)
const {
379 bool ok = v->GetAccessor (tmp);
384 (
object->*m_setter)(tmp);
387 virtual bool DoGet (
const T *
object, V *v)
const {
390 virtual bool HasGetter (
void)
const {
393 virtual bool HasSetter (
void)
const {
396 void (T::*m_setter)(U);
419 template <
typename W,
typename T,
typename U,
typename V>
421 Ptr<const AttributeAccessor>
423 V (T::*getter)(
void)
const)
437 MemberMethod (
void (T::*setter)(U),
438 V (T::*getter)(
void)
const)
444 virtual bool DoSet (T *
object,
const W *v)
const {
446 bool ok = v->GetAccessor (tmp);
451 (
object->*m_setter)(tmp);
454 virtual bool DoGet (
const T *
object, W *v)
const {
455 v->
Set ((object->*m_getter)());
458 virtual bool HasGetter (
void)
const {
461 virtual bool HasSetter (
void)
const {
464 void (T::*m_setter)(U);
465 V (T::*m_getter)(void)
const;
475 template <
typename W,
typename T,
typename U,
typename V>
477 Ptr<const AttributeAccessor>
479 void (T::*setter)(U))
481 return DoMakeAccessorHelperTwo<W> (setter, getter);
502 template <
typename W,
typename T,
typename U,
typename V>
504 Ptr<const AttributeAccessor>
506 V (T::*getter)(
void)
const)
520 MemberMethod (
bool (T::*setter)(U),
521 V (T::*getter)(
void)
const)
527 virtual bool DoSet (T *
object,
const W *v)
const {
529 bool ok = v->GetAccessor (tmp);
534 ok = (
object->*m_setter)(tmp);
537 virtual bool DoGet (
const T *
object, W *v)
const {
538 v->
Set ((object->*m_getter)());
541 virtual bool HasGetter (
void)
const {
544 virtual bool HasSetter (
void)
const {
547 bool (T::*m_setter)(U);
548 V (T::*m_getter)(void)
const;
558 template <
typename W,
typename T,
typename U,
typename V>
560 Ptr<const AttributeAccessor>
562 bool (T::*setter)(U))
564 return DoMakeAccessorHelperTwo<W> (setter, getter);
568 template <
typename V,
typename T1>
570 Ptr<const AttributeAccessor>
573 return DoMakeAccessorHelperOne<V> (a1);
576 template <
typename V,
typename T1,
typename T2>
578 Ptr<const AttributeAccessor>
581 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...
Anchor the ns-3 type and attribute system.
virtual bool Get(const ObjectBase *object, AttributeValue &val) const
Get the value of the underlying member into the AttributeValue.
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.
virtual bool Set(ObjectBase *object, const AttributeValue &val) const
Set the underlying member to the argument AttributeValue.
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 DoGet(const T *object, U *v) const =0
Getter implementation.