20 #ifndef ATTRIBUTE_ACCESSOR_HELPER_H
21 #define ATTRIBUTE_ACCESSOR_HELPER_H
68 template <
typename V,
typename T1>
70 Ptr<const AttributeAccessor>
114 template <
typename V,
typename T1,
typename T2>
116 Ptr<const AttributeAccessor>
139 template <
typename T>
157 template <
typename T,
typename U>
177 const U *value =
dynamic_cast<const U *
> (&val);
182 T *obj =
dynamic_cast<T *
> (object);
187 return DoSet (obj, value);
203 U *value =
dynamic_cast<U *
> (&val);
208 const T *obj =
dynamic_cast<const T *
> (object);
213 return DoGet (obj, value);
225 virtual bool DoSet (T *
object,
const U *v)
const = 0;
234 virtual bool DoGet (
const T *
object, U *v)
const = 0;
251 template <
typename V,
typename T,
typename U>
253 Ptr<const AttributeAccessor>
264 MemberVariable (U T::*memberVariable)
266 m_memberVariable (memberVariable)
269 virtual bool DoSet (T *
object,
const V *v)
const {
271 bool ok = v->GetAccessor (tmp);
276 (
object->*m_memberVariable) = tmp;
279 virtual bool DoGet (
const T *
object, V *v)
const {
280 v->Set (object->*m_memberVariable);
283 virtual bool HasGetter (
void)
const {
286 virtual bool HasSetter (
void)
const {
290 U T::*m_memberVariable;
308 template <
typename V,
typename T,
typename U>
310 Ptr<const AttributeAccessor>
321 MemberMethod (U (T::*getter)(
void)
const)
326 virtual bool DoSet (T *
object,
const V *v)
const {
329 virtual bool DoGet (
const T *
object, V *v)
const {
330 v->
Set ((object->*m_getter)());
333 virtual bool HasGetter (
void)
const {
336 virtual bool HasSetter (
void)
const {
339 U (T::*m_getter)(void)
const;
358 template <
typename V,
typename T,
typename U>
360 Ptr<const AttributeAccessor>
371 MemberMethod (
void (T::*setter)(U))
376 virtual bool DoSet (T *
object,
const V *v)
const {
378 bool ok = v->GetAccessor (tmp);
383 (
object->*m_setter)(tmp);
386 virtual bool DoGet (
const T *
object, V *v)
const {
389 virtual bool HasGetter (
void)
const {
392 virtual bool HasSetter (
void)
const {
395 void (T::*m_setter)(U);
418 template <
typename W,
typename T,
typename U,
typename V>
420 Ptr<const AttributeAccessor>
422 V (T::*getter)(
void)
const)
436 MemberMethod (
void (T::*setter)(U),
437 V (T::*getter)(
void)
const)
443 virtual bool DoSet (T *
object,
const W *v)
const {
445 bool ok = v->GetAccessor (tmp);
450 (
object->*m_setter)(tmp);
453 virtual bool DoGet (
const T *
object, W *v)
const {
454 v->
Set ((object->*m_getter)());
457 virtual bool HasGetter (
void)
const {
460 virtual bool HasSetter (
void)
const {
463 void (T::*m_setter)(U);
464 V (T::*m_getter)(void)
const;
474 template <
typename W,
typename T,
typename U,
typename V>
476 Ptr<const AttributeAccessor>
478 void (T::*setter)(U))
480 return DoMakeAccessorHelperTwo<W> (setter, getter);
501 template <
typename W,
typename T,
typename U,
typename V>
503 Ptr<const AttributeAccessor>
505 V (T::*getter)(
void)
const)
519 MemberMethod (
bool (T::*setter)(U),
520 V (T::*getter)(
void)
const)
526 virtual bool DoSet (T *
object,
const W *v)
const {
528 bool ok = v->GetAccessor (tmp);
533 ok = (
object->*m_setter)(tmp);
536 virtual bool DoGet (
const T *
object, W *v)
const {
537 v->
Set ((object->*m_getter)());
540 virtual bool HasGetter (
void)
const {
543 virtual bool HasSetter (
void)
const {
546 bool (T::*m_setter)(U);
547 V (T::*m_getter)(void)
const;
557 template <
typename W,
typename T,
typename U,
typename V>
559 Ptr<const AttributeAccessor>
561 bool (T::*setter)(U))
563 return DoMakeAccessorHelperTwo<W> (setter, getter);
567 template <
typename V,
typename T1>
569 Ptr<const AttributeAccessor>
572 return DoMakeAccessorHelperOne<V> (a1);
575 template <
typename V,
typename T1,
typename T2>
577 Ptr<const AttributeAccessor>
580 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.
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.
Type trait reference values.
AccessorHelper()
Constructor.
Ptr< const AttributeAccessor > DoMakeAccessorHelperOne(U T::*memberVariable)
MakeAccessorHelper implementation for a class data member.
virtual bool DoGet(const T *object, U *v) const =0
Getter implementation.