Bug 2 - Time class a full-blown arithmetic object
: Time class a full-blown arithmetic object
Status: RESOLVED FIXED
: ns-3
simulation core
: pre-release
: PC Linux
: P1 blocker
Assigned To:
:
: api
:
:
  Show dependency treegraph
 
Reported: 2006-10-20 07:36 EDT by
Modified: 2008-07-01 13:32 EDT (History)


Attachments


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2006-10-20 07:36:39 EDT
Currently, it is not possible to do arithmetic with the Time class itself.
Instead, we ask our users to do their own calculations and then to convert
their final time into a Time object prior to invoking the simulator's Scheduler
methods.

It might make sense to add a bunch of arithmetic operators to this c++ class to
make it possible for users to use it directly to do their calculations. We
could use this to catch common overflow or underflow errors.

What is not super clear is how to handle substractions of Time objects: what
would be the type of the returned object ?

This bug comes from the ML discussion on ns-developers archived here:
http://mailman.isi.edu/pipermail/ns-developers/2006-October/002433.html
------- Comment #1 From 2006-10-23 04:32:17 EDT -------
I would like to add one extra comments:
It might be really needed to go down that route because the current way of
allowing the user to convert to various time units is sort of broken. Part of
the deal when I designed the current Time getters was that the user would see
no change in simulation behavior if we increased the internal accuracy of the
event scheduler. However; this does not work in practice: if the code was
designed to say: I want to schedule an event in 2 microseconds and if he used
Schedule (Now + 2) to do this, his code might not be notified in 2 microseconds
but in 1+epsilon microseconds due to the way time conversions are done. So, I
think that the current way of working is bad in certain cases (which ought not
to exist I should point out)

So, I guess that the priority of this item has just increased in my work queue.
------- Comment #2 From 2006-12-04 07:54:15 EDT -------
The Time class now behaves like a full C++ POD. i.e., arithmetic operators are
implemented, including +-*/.