Bug 123 - SetInterfaceId is too easy to forget
SetInterfaceId is too easy to forget
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: core
pre-release
All All
: P3 normal
Assigned To: ns-bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-01-02 03:08 UTC by Mathieu Lacage
Modified: 2008-07-01 13:32 UTC (History)
1 user (show)

See Also:


Attachments
Add CreateObject to create subclasses of the Object base class (90.77 KB, text/x-patch)
2008-01-02 03:10 UTC, Mathieu Lacage
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mathieu Lacage 2008-01-02 03:08:15 UTC
if you want to implement a new subclass of the Object base class which provides a new InterfaceId, you need to make sure you call SetInterfaceId from your object's constructor but it is too easy to forget this which results in very-hard-to-debug problems.
Comment 1 Mathieu Lacage 2008-01-02 03:10:45 UTC
Created attachment 101 [details]
Add CreateObject to create subclasses of the Object base class

The new CreateObject method introduced here calls SetInterfaceId directly, hence making the extra call to SetInterfaceId from an object's constructor useless.
Comment 2 Gustavo J. A. M. Carneiro 2008-01-02 09:29:52 UTC
I hate the fact that this ruins my python bindings. :-(

I have a suggestion: why not make the Object::Object constructor require an InterfaceId argument, and make this base constructor call AddInterfaceId?  This way if you forget the InterfaceId you get a compile time error, and it's easy to fix the code.
Comment 3 Mathieu Lacage 2008-01-02 09:39:46 UTC
(In reply to comment #2)
> I hate the fact that this ruins my python bindings. :-(

I am willing to make a patch for your bindings to ease integration of this patch. Would you mind explain what exactly in this patch makes the automatically-generated bindings cry ?

> I have a suggestion: why not make the Object::Object constructor require an
> InterfaceId argument, and make this base constructor call AddInterfaceId?  This
> way if you forget the InterfaceId you get a compile time error, and it's easy
> to fix the code.

The problem with the approach you suggest is that it is going to require you to propagate the interface id from a subclass up to the base class: if there are 2 or 3 intermeditate classes, this is a lot of work.

Another problem is that this patch is the base of a larger set of patches which aim at improving/adding features to the Object framework.
Comment 4 Tom Henderson 2008-02-02 18:55:27 UTC
fixed by ns-3-object