[Ns-developers] How to Deal With Interface Revisions (was RE:Learning Bridge has been merged)

Gustavo Carneiro gjcarneiro at gmail.com
Tue Jul 22 04:55:47 PDT 2008


2008/7/21 <craigdo at ee.washington.edu>:

>
> > I am OK with your proposal, assuming deprecated APIs are not
> > removed for
> > about one year.  I think achieving one year of relative
> > stability (where it
> > doesn't compromise API cleanliness) is a good compromise between API
> > stability and maintainability.  Maintainers, do not despair,
> > one year passes
> > very quickly...
> >
> > Now I am going to preempt Mathieu's likely reply and say that the big
> > problem, in this case, is that I do not know how to make GCC emit a
> > deprecation warning for a subclass of NetDevice that doesn't
> > override the
> > virtual methods that will become pure in the future.  So this
> > is the only
> > problem I can see to that approach.  Unfortunate problem, I
> > must add... :-(
>
> Yup.  I thought that a deprecation warning could be emitted when the code
> implementing the deprecated virtual method providing compatibility is
> compiled.  This warning would hopefully trigger a user to go and read our
> API readme to find what this means -- what is going to happen, and when.
>  If
> this user maintains a net device she could go in at her leisure and
> implement the required method and forget about the warning.
>
> It would be nice to be able to emit user-defined warning text ...


This sounds nice but, again, I don't think it is possible to coerce GCC to
emit those kinds of warnings.  Deprecation warnings via
__attribute__((deprecated)) are very limited (but very useful when they
work).

Now, taking a cue from Tom's idea of using interfaces for this, I know what
can be done to mitigate the problem:

1- We define a PromiscuousNetDevice_Iface (or whatever convention we may
want for interface types) interface type, put our "promiscuity" APIs in this
interface;

2- When instantiating CsmaNetDevice, which supports promiscuous mode, it
automatically creates a CsmaProsmiscuousMode object (subclass of
PromiscuousNetDeviceIface) and aggregates it with itself;

3- Now it's easy to detect netdevices not implementing the promiscuous
mode.  Just add a unit test that iterates over all NetDevice subtypes,
create one instance of each type, and finally query the object for the
promiscuous interface.  If it is not found, emit a warning.  Put this into a
unit test, that runs on waf check, and you're good to go.  I mean, assuming
the objective is for all netdevices to implement the promiscuous interface;
I am not claiming that is a good idea, but I'll remain agnostic to avoid
confusing the issues.

-- 
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