[Ns-developers] [ns3] trace path documentation
Mathieu Lacage
mathieu.lacage at sophia.inria.fr
Thu Apr 17 15:53:18 PDT 2008
hi tom,
On Wed, 2008-04-16 at 07:48 -0700, Tom Henderson wrote:
> >> Thinking more about this and other issues lead me to re-consider this
> >> problem in light of the larger problem of trying to explain in a
> >> sensible and consistent way how to set and get attributes in objects or
> >> across the helper API. The issue we face in the current code and in what
> >> you propose is that different attributes get a different treatment
> >> because of implementation details (which make a lot of sense if you know
> >> how the implementation works but which are pretty weird for a user). For
> >> example, if I want to deal with a double:
> >>
> >> object->SetAttribute ("MyDouble", Double (10.0));
> >> Double v = object->GetAttribute ("MyDouble");
> >> double value = v.Get ();
> >>
> >> but, if I want to deal with a Vector:
> >>
> >> Vector v = Vector (0.0, 0.0, 0.0);
> >> object->SetAttribute ("MyVector", vector);
> >> v = Object->GetAttribute ("MyVector");
> >>
> >> The issue, here, is that you have to wrap the value you want to set or
> >> get with a Double but not with a Vector.
> >>
> >> The only way to make the two classes of attributes behave the same is to
> >> _always_ request that you use a 'wrapper' class to set or get an
> >> attribute:
> >>
> >> object->SetAttribute ("MyDouble", DoubleAttribute (10.0));
> >> object->SetAttribute ("MyVector", VectorAttribute (v));
> >> DoubleAttribute v = object->GetAttribute ("MyDouble");
> >> double doubleV = v.Get ();
> >> VectorAttribute vec = object->GetAttribute ("MyVector);
> >> Vector vectorV = vec.Get ();
> >>
> >> The above code is certainly verbose but it is at least very consistent
> >> and avoids the problem you originally complained about. Would there be
> >> complaints if I implemented that ?
> >
> >
> > No objections from me, but maybe DoubleAttr is good enough name and shorter
> > to type?...
>
> I agree with this change to the proposal and Gustavo's proposed shortening.
I have implemented that (the naming pattern is now DoubleValue rather
than DoubleAttr) in ns-3-doc and fixed the doxygen to play nice with
this change. I believe that ns-3-doc is ready to be merged.
regards,
Mathieu
More information about the Ns-developers
mailing list