[Ns-developers] using TypeId for Header/Trailer (and helpers)
Tom Henderson
tomh at tomh.org
Thu Mar 20 06:35:49 PDT 2008
Mathieu Lacage wrote:
> hi,
>
> I have just pushed code in http://code.nsnam.org/mathieu/ns-3-param
> which makes the Header and Trailer classes use a TypeId to replace the
> previously-used adhoc uid. There is no change in functionality but the
> result is a net drop in number of lines of code in the packet metadata
> implementation which I think is a great thing. The other rationale for
> this change is to help gustavo's python bindings to allow them to get
> more information about a packet's headers and trailers and to allow
> python-based headers and trailers.
>
> To get there, I had to split the TypeId functionality from the
> src/core/object.h header to src/core/type-id.h and I added TypeId powers
> to src/core/object-base.h. Another very nice side-effect of this change
> is that the header src/core/object.h has become readable again, as well
> as its implementation src/core/object.cc
>
> Finaly, the last nice thing about this refactoring is that, if we want
> to, we can re-use the ObjectBase (src/core/object-base.h) as a base
> class for all the classes in src/helper/*. ObjectBase merely provides
> TypeId/Attribute powers to its subclasses without requesting these
> subclasses to support reference counting and/or object aggregation.
>
> I was originally planning to make this change post-release but the code
> turned out to be pretty clean reasonably quickly and helped me to fix a
> bunch of bugs here and there in the wifi, and packet code.
>
> So, I would like to merge this branch back into ns-3-dev as soon as
> possible because I see little downsides to do so and many upsides. Are
> there any comments about this ?
>
> Mathieu
>
I agree that there are several benefits and no perceived downsides, so I
would suggest also to merge it. Splitting these features into separate
classes and headers does improve readability, as you mention.
Should the boolean versions of SetAttribute and GetAttribute have
symmetric (FailSafe) names?
Tom
More information about the Ns-developers
mailing list