[Ns-developers] ns-3.4 proposal: Object Name Service
Tom Henderson
tomh at tomh.org
Thu Jan 22 22:29:21 PST 2009
Raj Bhattacharjea wrote:
> On Wed, Jan 21, 2009 at 2:54 PM, Raj Bhattacharjea <raj.b at gatech.edu> wrote:
>> Craig has prepared a branch for an "object name service". The idea
>> grew out of the fact that people wanted to be able to refer to nodes
>> in their simulation by string names, and then extended from also
>> naming NetDevices to finally being able to name all Objects in the
>> system.
>
> Good work Craig. My comments follow.
>
> 1. I'd propose a name/parameter refactoring change like:
>
> - Names::Add (std::string, Ptr<Object>);
> + Names::NameObject(Ptr<Object>, std::string)
>
> This would follow the verb+object function naming scheme. I propose
> that all the "Add" methods are thus renamed and reordered such that
> the object being named comes first, followed by its name, followed by
> the context if necessary.
I came to a similar conclusion as Gustavo and now Craig, to prefer the
ordering that is in the current repo.
>
> 2. I propose some syntactic sugar, hiding the above API from the user;
> essentially, a new Object base class API like
> Object::AssignName(std::string); this makes things less verbose and
> leads to changes like:
>
> - Names::Add ("/Names/client", n.Get (0));
> - Names::Add ("/Names/server", n.Get (1));
> + n.Get (0)->AssignName("/Names/client");
> + n.Get (1)->AssignName("/Names/server");
>
> Patch attached
>
Originally, I thought about doing it the way you suggest (such as
Node::SetName()) but I would agree with Gustavo that this seems to
duplicate the newly proposed API without really saving any keystrokes.
Tom
More information about the Ns-developers
mailing list