give attribute power to Callback.
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Fri, 17 Oct 2008 14:15:52 +0200
changeset 3763e46e361a4262
parent 3762 622a33a8820c
child 3764 64f1310350e4
give attribute power to Callback.
src/core/attribute-accessor-helper.h
src/core/attribute-helper.h
src/core/attribute-test.cc
src/core/boolean.h
src/core/callback.cc
src/core/callback.h
src/core/config.h
src/core/enum.cc
src/core/enum.h
src/core/pointer.h
src/core/string.cc
src/core/wscript
     1.1 --- a/src/core/attribute-accessor-helper.h	Fri Oct 17 13:11:39 2008 +0200
     1.2 +++ b/src/core/attribute-accessor-helper.h	Fri Oct 17 14:15:52 2008 +0200
     1.3 @@ -48,6 +48,12 @@
     1.4  
     1.5  namespace ns3 {
     1.6  
     1.7 +template <typename T>
     1.8 +struct AccessorTrait
     1.9 +{
    1.10 +  typedef typename TypeTraits<typename TypeTraits<T>::ReferencedType>::NonConstType Result;
    1.11 +};
    1.12 +
    1.13  template <typename T, typename U>
    1.14  class AccessorHelper : public AttributeAccessor
    1.15  {
    1.16 @@ -100,7 +106,13 @@
    1.17  	{}
    1.18      private:
    1.19        virtual bool DoSet (T *object, const V *v) const {
    1.20 -	(object->*m_memberVariable) = U (v->Get ());
    1.21 +        typename AccessorTrait<U>::Result tmp;
    1.22 +        bool ok = v->GetAccessor (tmp);
    1.23 +        if (!ok)
    1.24 +          {
    1.25 +            return false;
    1.26 +          }
    1.27 +	(object->*m_memberVariable) = tmp;
    1.28  	return true;
    1.29        }
    1.30        virtual bool DoGet (const T *object, V *v) const {
    1.31 @@ -163,7 +175,13 @@
    1.32  	{}
    1.33      private:
    1.34        virtual bool DoSet (T *object, const V *v) const {
    1.35 -	(object->*m_setter) (U (v->Get ()));
    1.36 +        typename AccessorTrait<U>::Result tmp;
    1.37 +        bool ok = v->GetAccessor (tmp);
    1.38 +        if (!ok)
    1.39 +          {
    1.40 +            return false;
    1.41 +          }
    1.42 +	(object->*m_setter) (tmp);
    1.43  	return true;
    1.44        }
    1.45        virtual bool DoGet (const T *object, V *v) const {
    1.46 @@ -196,7 +214,13 @@
    1.47  	{}
    1.48      private:
    1.49        virtual bool DoSet (T *object, const W *v) const {
    1.50 -	(object->*m_setter) (v->Get ());
    1.51 +        typename AccessorTrait<U>::Result tmp;
    1.52 +        bool ok = v->GetAccessor (tmp);
    1.53 +        if (!ok)
    1.54 +          {
    1.55 +            return false;
    1.56 +          }
    1.57 +	(object->*m_setter) (tmp);
    1.58  	return true;
    1.59        }
    1.60        virtual bool DoGet (const T *object, W *v) const {
    1.61 @@ -239,7 +263,13 @@
    1.62  	{}
    1.63      private:
    1.64        virtual bool DoSet (T *object, const W *v) const {
    1.65 -	bool ok = (object->*m_setter) (v->Get ());
    1.66 +        typename AccessorTrait<U>::Result tmp;
    1.67 +        bool ok = v->GetAccessor (tmp);
    1.68 +        if (!ok)
    1.69 +          {
    1.70 +            return false;
    1.71 +          }
    1.72 +	ok = (object->*m_setter) (tmp);
    1.73          return ok;
    1.74        }
    1.75        virtual bool DoGet (const T *object, W *v) const {
     2.1 --- a/src/core/attribute-helper.h	Fri Oct 17 13:11:39 2008 +0200
     2.2 +++ b/src/core/attribute-helper.h	Fri Oct 17 14:15:52 2008 +0200
     2.3 @@ -117,6 +117,11 @@
     2.4      name##Value (const type &value);					\
     2.5      void Set (const type &value);					\
     2.6      type Get (void) const;						\
     2.7 +    template <typename T>                                               \
     2.8 +    bool GetAccessor (T &value) const {                                 \
     2.9 +      value = T (m_value);                                              \
    2.10 +      return true;                                                      \
    2.11 +    }                                                                   \
    2.12      virtual Ptr<AttributeValue> Copy (void) const;                      \
    2.13      virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const; \
    2.14      virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker); \
    2.15 @@ -220,17 +225,6 @@
    2.16      return MakeSimpleAttributeChecker<type##Value,type##Checker> (#type "Value", name); \
    2.17    }									\
    2.18  
    2.19 -
    2.20 -/**
    2.21 - * \ingroup AttributeHelper
    2.22 - * \param type the name of the class
    2.23 - *
    2.24 - * This macro implements the conversion operators to and from
    2.25 - * instances of type Attribute. Typically invoked from xxx.cc.
    2.26 - */
    2.27 -#define ATTRIBUTE_CONVERTER_IMPLEMENT(type)
    2.28 -
    2.29 -
    2.30  /**
    2.31   * \ingroup AttributeHelper
    2.32   * \param type the name of the class
    2.33 @@ -251,7 +245,6 @@
    2.34   */
    2.35  #define ATTRIBUTE_HELPER_CPP(type)                                      \
    2.36    ATTRIBUTE_CHECKER_IMPLEMENT (type);					\
    2.37 -  ATTRIBUTE_CONVERTER_IMPLEMENT (type);					\
    2.38    ATTRIBUTE_VALUE_IMPLEMENT (type);
    2.39  
    2.40  
     3.1 --- a/src/core/attribute-test.cc	Fri Oct 17 13:11:39 2008 +0200
     3.2 +++ b/src/core/attribute-test.cc	Fri Oct 17 14:15:52 2008 +0200
     3.3 @@ -29,6 +29,7 @@
     3.4  #include "double.h"
     3.5  #include "object-vector.h"
     3.6  #include "traced-value.h"
     3.7 +#include "callback.h"
     3.8  #include "trace-source-accessor.h"
     3.9  #include "pointer.h"
    3.10  
    3.11 @@ -71,9 +72,13 @@
    3.12    void NotifySourceValue (ValueClassTest old, ValueClassTest n) {
    3.13      m_gotValue = n;
    3.14    }
    3.15 +  void NotifyCallbackValue (int8_t a) {
    3.16 +    m_gotCbValue = a;
    3.17 +  }
    3.18    int64_t m_got1;
    3.19    double m_got2;
    3.20    ValueClassTest m_gotValue;
    3.21 +  int16_t m_gotCbValue;
    3.22  };
    3.23  
    3.24  class Derived : public Object
    3.25 @@ -171,6 +176,10 @@
    3.26                       PointerValue (),
    3.27                       MakePointerAccessor (&AttributeObjectTest::m_ptr),
    3.28                       MakePointerChecker<Derived> ())
    3.29 +      .AddAttribute ("Callback", "help text",
    3.30 +                     CallbackValue (),
    3.31 +                     MakeCallbackAccessor (&AttributeObjectTest::m_cbValue),
    3.32 +                     MakeCallbackChecker ())
    3.33        ;
    3.34          
    3.35      return tid;
    3.36 @@ -187,6 +196,13 @@
    3.37      m_cb (a,b,c);
    3.38    }
    3.39  
    3.40 +  void InvokeCbValue (int8_t a) {
    3.41 +    if (!m_cbValue.IsNull ())
    3.42 +      {
    3.43 +        m_cbValue (a);
    3.44 +      }
    3.45 +  }
    3.46 +
    3.47  private:
    3.48    void DoSetTestB (bool v) {
    3.49      m_boolTestA = v;
    3.50 @@ -224,6 +240,7 @@
    3.51    RandomVariable m_random;
    3.52    std::vector<Ptr<Derived> > m_vector1;
    3.53    std::vector<Ptr<Derived> > m_vector2;
    3.54 +  Callback<void,int8_t> m_cbValue;
    3.55    TracedValue<int8_t> m_intSrc1;
    3.56    TracedValue<int8_t> m_intSrc2;
    3.57    TracedCallback<double, int, float> m_cb;
    3.58 @@ -492,6 +509,21 @@
    3.59    derived = ptr.Get<Derived> ();
    3.60    NS_TEST_ASSERT (derived != 0);
    3.61  
    3.62 +  p = CreateObject<AttributeObjectTest> ();
    3.63 +  NS_TEST_ASSERT (p != 0);
    3.64 +  m_gotCbValue = 1;
    3.65 +  p->InvokeCbValue (2);
    3.66 +  CallbackValue cbValue = MakeCallback (&AttributeTest::NotifyCallbackValue, this);
    3.67 +  NS_TEST_ASSERT_EQUAL (m_gotCbValue, 1);
    3.68 +  NS_TEST_ASSERT (p->SetAttributeFailSafe ("Callback", 
    3.69 +                                           cbValue));
    3.70 +  p->InvokeCbValue (2);
    3.71 +  NS_TEST_ASSERT_EQUAL (m_gotCbValue, 2);
    3.72 +  NS_TEST_ASSERT (p->SetAttributeFailSafe ("Callback", 
    3.73 +                                           CallbackValue (MakeNullCallback<void,int8_t> ())));
    3.74 +  p->InvokeCbValue (3);
    3.75 +  NS_TEST_ASSERT_EQUAL (m_gotCbValue, 2);
    3.76 +  
    3.77    return result;
    3.78  }
    3.79  
     4.1 --- a/src/core/boolean.h	Fri Oct 17 13:11:39 2008 +0200
     4.2 +++ b/src/core/boolean.h	Fri Oct 17 14:15:52 2008 +0200
     4.3 @@ -42,6 +42,8 @@
     4.4    BooleanValue (bool value);
     4.5    void Set (bool value);
     4.6    bool Get (void) const;
     4.7 +  template <typename T>
     4.8 +  bool GetAccessor (T &v) const;
     4.9    
    4.10    operator bool () const;
    4.11  
    4.12 @@ -52,6 +54,13 @@
    4.13    bool m_value;
    4.14  };
    4.15  
    4.16 +template <typename T>
    4.17 +bool BooleanValue::GetAccessor (T &v) const
    4.18 +{
    4.19 +  v = T (m_value);
    4.20 +  return true;
    4.21 +}
    4.22 +
    4.23  std::ostream & operator << (std::ostream &os, const BooleanValue &value);
    4.24  
    4.25  ATTRIBUTE_CHECKER_DEFINE (Boolean);
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/src/core/callback.cc	Fri Oct 17 14:15:52 2008 +0200
     5.3 @@ -0,0 +1,38 @@
     5.4 +#include "callback.h"
     5.5 +
     5.6 +namespace ns3 {
     5.7 +
     5.8 +CallbackValue::CallbackValue ()
     5.9 +  : m_value ()
    5.10 +{}
    5.11 +CallbackValue::CallbackValue (const CallbackBase &base)
    5.12 +  : m_value (base)
    5.13 +{}
    5.14 +CallbackValue::~CallbackValue ()
    5.15 +{}
    5.16 +void 
    5.17 +CallbackValue::Set (CallbackBase base)
    5.18 +{
    5.19 +  m_value = base;
    5.20 +}
    5.21 +Ptr<AttributeValue> 
    5.22 +CallbackValue::Copy (void) const
    5.23 +{
    5.24 +  return Create<CallbackValue> (m_value);
    5.25 +}
    5.26 +std::string 
    5.27 +CallbackValue::SerializeToString (Ptr<const AttributeChecker> checker) const
    5.28 +{
    5.29 +  std::ostringstream oss;
    5.30 +  oss << PeekPointer (m_value.GetImpl ());
    5.31 +  return oss.str ();
    5.32 +}
    5.33 +bool 
    5.34 +CallbackValue::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker)
    5.35 +{
    5.36 +  return false;
    5.37 +}
    5.38 +
    5.39 +ATTRIBUTE_CHECKER_IMPLEMENT (Callback);
    5.40 +
    5.41 +} // namespace ns3
     6.1 --- a/src/core/callback.h	Fri Oct 17 13:11:39 2008 +0200
     6.2 +++ b/src/core/callback.h	Fri Oct 17 14:15:52 2008 +0200
     6.3 @@ -25,6 +25,8 @@
     6.4  #include "fatal-error.h"
     6.5  #include "empty.h"
     6.6  #include "type-traits.h"
     6.7 +#include "attribute.h"
     6.8 +#include "attribute-helper.h"
     6.9  #include <typeinfo>
    6.10  
    6.11  namespace ns3 {
    6.12 @@ -399,7 +401,11 @@
    6.13      return static_cast<CallbackImpl<R,T1,T2,T3,T4,T5,T6> *> (PeekPointer (m_impl));
    6.14    }
    6.15    bool DoCheckType (Ptr<const CallbackImplBase> other) const {
    6.16 -    if (dynamic_cast<const CallbackImpl<R,T1,T2,T3,T4,T5,T6> *> (PeekPointer (other)) != 0)
    6.17 +    if (other != 0 && dynamic_cast<const CallbackImpl<R,T1,T2,T3,T4,T5,T6> *> (PeekPointer (other)) != 0)
    6.18 +      {
    6.19 +        return true;
    6.20 +      }
    6.21 +    else if (other == 0)
    6.22        {
    6.23          return true;
    6.24        }
    6.25 @@ -753,9 +759,45 @@
    6.26      Create<BoundFunctorCallbackImpl<R (*) (TX,T1,T2,T3,T4,T5),R,TX,T1,T2,T3,T4,T5> > (fnPtr, a);
    6.27    return Callback<R,T1,T2,T3,T4,T5> (impl);
    6.28  }
    6.29 +} // namespace ns3
    6.30  
    6.31 +namespace ns3 {
    6.32  
    6.33 -}; // namespace ns3
    6.34 +class CallbackValue : public AttributeValue
    6.35 +{
    6.36 +public:
    6.37 +  CallbackValue ();
    6.38 +  CallbackValue (const CallbackBase &base);
    6.39 +  virtual ~CallbackValue ();
    6.40 +  void Set (CallbackBase base);
    6.41 +  template <typename T>
    6.42 +  bool GetAccessor (T &value) const;
    6.43 +  virtual Ptr<AttributeValue> Copy (void) const;
    6.44 +  virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const;
    6.45 +  virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker);
    6.46 +private:
    6.47 +  CallbackBase m_value;
    6.48 +};
    6.49 +
    6.50 +ATTRIBUTE_ACCESSOR_DEFINE(Callback);
    6.51 +ATTRIBUTE_CHECKER_DEFINE (Callback);
    6.52 +
    6.53 +} // namespace ns3
    6.54 +
    6.55 +namespace ns3 {
    6.56 +
    6.57 +template <typename T>
    6.58 +bool CallbackValue::GetAccessor (T &value) const
    6.59 +{
    6.60 +  if (value.CheckType (m_value))
    6.61 +    {
    6.62 +      value.Assign (m_value);
    6.63 +      return true;
    6.64 +    }
    6.65 +  return false;
    6.66 +}
    6.67 +
    6.68 +} // namespace ns3
    6.69  
    6.70  
    6.71  #endif /* CALLBACK_H */
     7.1 --- a/src/core/config.h	Fri Oct 17 13:11:39 2008 +0200
     7.2 +++ b/src/core/config.h	Fri Oct 17 14:15:52 2008 +0200
     7.3 @@ -17,8 +17,8 @@
     7.4   *
     7.5   * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
     7.6   */
     7.7 -#ifndef NS3_CONFIG_H
     7.8 -#define NS3_CONFIG_H
     7.9 +#ifndef CONFIG_H
    7.10 +#define CONFIG_H
    7.11  
    7.12  #include "ptr.h"
    7.13  #include <string>
    7.14 @@ -139,4 +139,4 @@
    7.15  
    7.16  } // namespace ns3
    7.17  
    7.18 -#endif /* NS3_CONFIG_H */
    7.19 +#endif /* CONFIG_H */
     8.1 --- a/src/core/enum.cc	Fri Oct 17 13:11:39 2008 +0200
     8.2 +++ b/src/core/enum.cc	Fri Oct 17 14:15:52 2008 +0200
     8.3 @@ -39,7 +39,6 @@
     8.4  {
     8.5    return m_v;
     8.6  }
     8.7 -
     8.8  Ptr<AttributeValue>
     8.9  EnumValue::Copy (void) const
    8.10  {
     9.1 --- a/src/core/enum.h	Fri Oct 17 13:11:39 2008 +0200
     9.2 +++ b/src/core/enum.h	Fri Oct 17 14:15:52 2008 +0200
     9.3 @@ -41,6 +41,8 @@
     9.4    EnumValue (int v);
     9.5    void Set (int v);
     9.6    int Get (void) const;
     9.7 +  template <typename T>
     9.8 +  bool GetAccessor (T &v) const;
     9.9  
    9.10    virtual Ptr<AttributeValue> Copy (void) const;
    9.11    virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const;
    9.12 @@ -50,6 +52,13 @@
    9.13    int m_v;
    9.14  };
    9.15  
    9.16 +template <typename T>
    9.17 +bool EnumValue::GetAccessor (T &v) const
    9.18 +{
    9.19 +  v = T (m_v);
    9.20 +  return true;
    9.21 +}
    9.22 +
    9.23  class EnumChecker : public AttributeChecker
    9.24  {
    9.25  public:
    10.1 --- a/src/core/pointer.h	Fri Oct 17 13:11:39 2008 +0200
    10.2 +++ b/src/core/pointer.h	Fri Oct 17 14:15:52 2008 +0200
    10.3 @@ -51,6 +51,9 @@
    10.4    Ptr<T> Get (void) const;
    10.5  
    10.6    template <typename T>
    10.7 +  bool GetAccessor (Ptr<T> &v) const;
    10.8 +
    10.9 +  template <typename T>
   10.10    operator Ptr<T> () const;
   10.11  
   10.12    virtual Ptr<AttributeValue> Copy (void) const;
   10.13 @@ -61,23 +64,6 @@
   10.14    Ptr<Object> m_value;
   10.15  };
   10.16  
   10.17 -template <typename T, typename U>
   10.18 -Ptr<const AttributeAccessor>
   10.19 -MakePointerAccessor (Ptr<U> T::*memberVariable);
   10.20 -template <typename T, typename U>
   10.21 -Ptr<const AttributeAccessor>
   10.22 -MakePointerAccessor (void (T::*setter) (Ptr<U>));
   10.23 -template <typename T, typename U>
   10.24 -Ptr<const AttributeAccessor>
   10.25 -MakePointerAccessor (Ptr<U> (T::*getter) (void) const);
   10.26 -template <typename T, typename U>
   10.27 -Ptr<const AttributeAccessor>
   10.28 -MakePointerAccessor (void (T::*setter) (Ptr<U>),
   10.29 -		     Ptr<U> (T::*getter) (void) const);
   10.30 -template <typename T, typename U>
   10.31 -Ptr<const AttributeAccessor>
   10.32 -MakePointerAccessor (Ptr<U> (T::*getter) (void) const,
   10.33 -		     void (T::*setter) (Ptr<U>));
   10.34  
   10.35  class PointerChecker : public AttributeChecker 
   10.36  {
   10.37 @@ -142,57 +128,8 @@
   10.38    }
   10.39  };
   10.40  
   10.41 -/********************************************************
   10.42 - *              The Accessor associated to 
   10.43 - *               PointerValue
   10.44 - ********************************************************/
   10.45 -
   10.46 -template <typename T, typename U>
   10.47 -class PointerAccessor : public AttributeAccessor
   10.48 -{
   10.49 -public:
   10.50 -  virtual ~PointerAccessor () {}
   10.51 -  virtual bool Set (ObjectBase * object, const AttributeValue &val) const {
   10.52 -      T *obj = dynamic_cast<T *> (object);
   10.53 -      if (obj == 0)
   10.54 -        {
   10.55 -          return false;
   10.56 -        }
   10.57 -      const PointerValue *value = dynamic_cast<const PointerValue *> (&val);
   10.58 -      if (value == 0)
   10.59 -        {
   10.60 -          return false;
   10.61 -        }
   10.62 -      Ptr<U> ptr = dynamic_cast<U*> (PeekPointer (value->GetObject ()));
   10.63 -      if (ptr == 0)
   10.64 -        {
   10.65 -          return false;
   10.66 -        }
   10.67 -      DoSet (obj, ptr);
   10.68 -      return true;
   10.69 -    }
   10.70 -  virtual bool Get (const ObjectBase * object, AttributeValue &val) const {
   10.71 -      const T *obj = dynamic_cast<const T *> (object);
   10.72 -      if (obj == 0)
   10.73 -        {
   10.74 -          return false;
   10.75 -        }
   10.76 -      PointerValue *value = dynamic_cast<PointerValue *> (&val);
   10.77 -      if (value == 0)
   10.78 -        {
   10.79 -          return false;
   10.80 -        }
   10.81 -      value->Set (DoGet (obj));
   10.82 -      return true;
   10.83 -    }
   10.84 -private:
   10.85 -  virtual void DoSet (T *object, Ptr<U> value) const = 0;
   10.86 -  virtual Ptr<U> DoGet (const T *object) const = 0;
   10.87 -};
   10.88 -
   10.89  } // namespace internal
   10.90  
   10.91 -
   10.92  template <typename T>
   10.93  PointerValue::PointerValue (const Ptr<T> &object)
   10.94  {
   10.95 @@ -220,112 +157,21 @@
   10.96    return Get<T> ();
   10.97  }
   10.98  
   10.99 -
  10.100 -template <typename T, typename U>
  10.101 -Ptr<const AttributeAccessor>
  10.102 -MakePointerAccessor (Ptr<U> T::*memberVariable)
  10.103 +template <typename T>
  10.104 +bool 
  10.105 +PointerValue::GetAccessor (Ptr<T> &v) const
  10.106  {
  10.107 -  struct MemberVariable : public internal::PointerAccessor<T,U>
  10.108 -  {
  10.109 -    Ptr<U> T::*m_memberVariable;
  10.110 -    virtual void DoSet (T *object, Ptr<U> value) const {
  10.111 -      (object->*m_memberVariable) = value;
  10.112 +  Ptr<T> ptr = dynamic_cast<T*> (PeekPointer (m_value));
  10.113 +  if (ptr == 0)
  10.114 +    {
  10.115 +      return false;
  10.116      }
  10.117 -    virtual Ptr<U> DoGet (const T *object) const {
  10.118 -      return object->*m_memberVariable;
  10.119 -    }
  10.120 -    virtual bool HasGetter (void) const {
  10.121 -      return true;
  10.122 -    }
  10.123 -    virtual bool HasSetter (void) const {
  10.124 -      return true;
  10.125 -    }
  10.126 -  } *spec = new MemberVariable ();
  10.127 -  spec->m_memberVariable = memberVariable;
  10.128 -  return Ptr<const AttributeAccessor> (spec, false);
  10.129 +  v = ptr;
  10.130 +  return true;
  10.131  }
  10.132  
  10.133 -template <typename T, typename U>
  10.134 -Ptr<const AttributeAccessor>
  10.135 -MakePointerAccessor (void (T::*setter) (Ptr<U>))
  10.136 -{
  10.137 -  struct MemberMethod : public internal::PointerAccessor<T,U>
  10.138 -  {
  10.139 -    void (T::*m_setter) (Ptr<U>);
  10.140 -    virtual void DoSet (T *object, Ptr<U> value) const {
  10.141 -      (object->*m_setter) (value);
  10.142 -    }
  10.143 -    virtual Ptr<U> DoGet (const T *object) const {
  10.144 -      return 0;
  10.145 -      //return (object->*m_getter) ();
  10.146 -    }
  10.147 -    virtual bool HasGetter (void) const {
  10.148 -      return false;
  10.149 -    }
  10.150 -    virtual bool HasSetter (void) const {
  10.151 -      return true;
  10.152 -    }
  10.153 -  } *spec = new MemberMethod ();
  10.154 -  spec->m_setter = setter;
  10.155 -  return Ptr<const AttributeAccessor> (spec, false);
  10.156 -}
  10.157  
  10.158 -template <typename T, typename U>
  10.159 -Ptr<const AttributeAccessor>
  10.160 -MakePointerAccessor (Ptr<U> (T::*getter) (void) const)
  10.161 -{
  10.162 -  struct MemberMethod : public internal::PointerAccessor<T,U>
  10.163 -  {
  10.164 -    Ptr<U> (T::*m_getter) (void) const;
  10.165 -    virtual void DoSet (T *object, Ptr<U> value) const {
  10.166 -      //(object->*m_setter) (value);
  10.167 -    }
  10.168 -    virtual Ptr<U> DoGet (const T *object) const {
  10.169 -      return (object->*m_getter) ();
  10.170 -    }
  10.171 -    virtual bool HasGetter (void) const {
  10.172 -      return true;
  10.173 -    }
  10.174 -    virtual bool HasSetter (void) const {
  10.175 -      return false;
  10.176 -    }
  10.177 -  } *spec = new MemberMethod ();
  10.178 -  spec->m_getter = getter;
  10.179 -  return Ptr<const AttributeAccessor> (spec, false);
  10.180 -}
  10.181 -template <typename T, typename U>
  10.182 -Ptr<const AttributeAccessor>
  10.183 -MakePointerAccessor (void (T::*setter) (Ptr<U>),
  10.184 -		     Ptr<U> (T::*getter) (void) const)
  10.185 -{
  10.186 -  return MakePointerAccessor (getter, setter);
  10.187 -}
  10.188 -template <typename T, typename U>
  10.189 -Ptr<const AttributeAccessor>
  10.190 -MakePointerAccessor (Ptr<U> (T::*getter) (void) const,
  10.191 -		     void (T::*setter) (Ptr<U>))
  10.192 -{
  10.193 -  struct MemberMethod : public internal::PointerAccessor<T,U>
  10.194 -  {
  10.195 -    void (T::*m_setter) (Ptr<U>);
  10.196 -    Ptr<U> (T::*m_getter) (void) const;
  10.197 -    virtual void DoSet (T *object, Ptr<U> value) const {
  10.198 -      (object->*m_setter) (value);
  10.199 -    }
  10.200 -    virtual Ptr<U> DoGet (const T *object) const {
  10.201 -      return (object->*m_getter) ();
  10.202 -    }
  10.203 -    virtual bool HasGetter (void) const {
  10.204 -      return true;
  10.205 -    }
  10.206 -    virtual bool HasSetter (void) const {
  10.207 -      return true;
  10.208 -    }
  10.209 -  } *spec = new MemberMethod ();
  10.210 -  spec->m_setter = setter;
  10.211 -  spec->m_getter = getter;
  10.212 -  return Ptr<const AttributeAccessor> (spec, false);
  10.213 -}
  10.214 +ATTRIBUTE_ACCESSOR_DEFINE (Pointer);
  10.215  
  10.216  template <typename T>
  10.217  Ptr<AttributeChecker>
    11.1 --- a/src/core/string.cc	Fri Oct 17 13:11:39 2008 +0200
    11.2 +++ b/src/core/string.cc	Fri Oct 17 14:15:52 2008 +0200
    11.3 @@ -3,7 +3,6 @@
    11.4  namespace ns3 {
    11.5  
    11.6  ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME (String, "std::string");
    11.7 -ATTRIBUTE_CONVERTER_IMPLEMENT (String);
    11.8  ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME (std::string, String);
    11.9  
   11.10  } // namespace ns3
    12.1 --- a/src/core/wscript	Fri Oct 17 13:11:39 2008 +0200
    12.2 +++ b/src/core/wscript	Fri Oct 17 14:15:52 2008 +0200
    12.3 @@ -72,6 +72,7 @@
    12.4          'traced-callback.cc',
    12.5          'trace-source-accessor.cc',
    12.6          'config.cc',
    12.7 +        'callback.cc',
    12.8          ]
    12.9      core.uselib = 'RT'
   12.10