[Ns-bugs] [Bug 385] Add a generic "sequence number" class

code@nsnam.ece.gatech.edu code at nsnam.ece.gatech.edu
Mon Nov 30 00:52:02 PST 2009


http://www.nsnam.org/bugzilla/show_bug.cgi?id=385


Fabian Mauchle <f1mauchl at hsr.ch> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |f1mauchl at hsr.ch




--- Comment #12 from Fabian Mauchle <f1mauchl at hsr.ch>  2009-11-30 03:52:01 EDT ---
> The other simplification is in operator <=.  Your version is shorter and more
> efficient, but I think it a bit cryptic.  Or maybe it's just me...
Yes, my operator <= is in deed a bit cryptic.

> while I return a signed
> type that can be used to represent a negative difference.
If I use a Sequence<uint8_t> I expect it to behave exactly like an uint8_t
value (expect for the <, <=, >, >= operators), which is always positive. To get
a negative result, you can either use a Sequence<int8_t> or cast the result to
an int8_t.

> It is easy to trace a number, but this overloads the same operators as a
> sequence number class would.  It would be wonderful to be able to:
> 
>   .AddTraceSource ("SequenceNumber",
>                    "My sequence number to trace.",
>                    MakeTraceSourceAccessor (&MyObject::m_sequence))
> 
>   ...
> 
>   TracedValue<uint32_t> m_sequence
I'm not very used to traced values (I've never used them so far), but I tried
the above with a TracedValue<Sequence<uint32_t> > and it seems to work. The
only odd thing is that I can't directly assign an int value:

Sequence<uint32_t> a = 10; //works
Sequence<uint32_t> b = (Sequence<uint32_t>)10; //works, but not needed
TracedValue<Sequence<uint32_t> > c = 10 //doesn't work
TracedValue<Sequence<uint32_t> > d = (Sequence<uint32_t>)10; //works

-- 
Configure bugmail: http://www.nsnam.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the Ns-bugs mailing list