[Ns-developers] Bug 215 Name Container

Gustavo Carneiro gjcarneiro at gmail.com
Tue Dec 2 06:43:30 PST 2008


2008/12/2 <craigdo at ee.washington.edu>

>
> > > but in C and assembler you would probably see
> > >
> > >  copy (destination, source)  or
> > >  assign (identifier, value)
> >
> > Precisely.  I was more thinking of simple variable assignment:
> >
> >     foo = 3;
> >
> > > That is exactly what I did in this case.
> >
> > That is precisely what you did _not_ do in this case :-)
>
> That's odd.  I know it's been a long time, but I do seem to recall that
> really is what I did :-)
>
> [ ... ]
>
> > >From your example:
> >
> >    NameList::Add (devices.Get (3), "Node 3/eth0");
> >
> > What do you call identifier, and what do you call value, in this case?
>
> Isn't this perfectly clear given what I have written just a few lines up?
>
>  copy (destination, source)  or
>  assign (identifier, value)
>   NameList::Add (devices.Get (3), "Node 3/eth0");
>
> I think of conceptually _Add_ing an association of the name "Node 3/eth0"
> with/to the object returned from devices.Get (3).
>
> Abstractly, you can think of assigning a value -- the string "Node 3/etho0"
> -- to an object _identified_ by the pointer returned from the devices
> container.


So, for you the NetDevice object is an identifier, and the string "Node
3/eth0" is a value?!  I find this rather counterintuitive.


>
>
> At this point, I would generally come up with more analogies with common
> functions to try and uncover where we're not connecting, but you don't
> really want me to write more words to explain my position, do you :-)
>
> So, I'll just leave with:
>
> objectname = "Node 3/eth0";
> strcpy (object.name, "Node 3/eth0");
> assign (object.name, "Node 3/eth0);
> assign (devices.Get (3), "Node 3/eth0");


If you want something that resembles assign (devices.Get (3), "Node
3/eth0"), then I think what makes sense is a method in the object class:

  devices.Get (3)->SetName ("Node 3/eth0")

But this is not what happens here.

Actually I was expecting NameList to be a simple wrapper around std::map<
std::string, Ptr<Object> >.  If that were so, it would so much clearer that
what you would do with NameList::Add would be

NameList::Add (std::string name, Ptr<Object> object)
{
   m_map[name] = object;
}

Lookup operation would be logaritmic time and would be little more than
returning the expression m_map[name].

I was surprised to see in the code that it is just a vector of object/name
pairs, which is very inneficient for lookup operations.  And lookup will be
by far the most common operation.

Anyway, I guess we think completely differently.  But, well, if I am the
only one that finds your way of thinking strange, then just ignore me :-)

-- 
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert


More information about the Ns-developers mailing list