[Ns-developers] [ns3] trace path documentation

Tom Henderson tomh at tomh.org
Sun Apr 20 22:43:54 PDT 2008


Mathieu Lacage wrote:
> 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. 
> 

Mathieu, I have looked this repo over and I think it really starts to 
show the benefits of moving over to this attribute system, in terms of 
documenting the system.  I also think that the ConfigStore class will be 
widely used and will be a key feature of ns-3, but I agree with putting 
it into src/contrib for now until we get more feedback on the details 
that people find most useful.

I am fine with the naming change (*Attr or *Attribute -> *Value).  So I 
agree that it seems ready to be merged.

Tom


More information about the Ns-developers mailing list