[Ns-developers] NS3 Time objects
Gustavo Carneiro
gjcarneiro at gmail.com
Thu Nov 2 10:54:11 PST 2006
On 11/2/06, Mathieu Lacage <Mathieu.Lacage at sophia.inria.fr> wrote:
>
> hi gustavo,
>
> On Thu, 2006-11-02 at 10:54 +0000, Gustavo Carneiro wrote:
> > OK, let's finish this discussion, then; I do not wish to slow down
> NS-3
> > development.
>
> You are not slowing the development. This kind of discussion is
> necessary to fix and improve what we have and what we want to get. I
> think that both you and George have helped fix my original proposal into
> something much better. I really think that this sort of iterative
> discussion/implementation process is the way to go even though it takes
> time and a lot of efforts.
Thanks; but it's just that I really wanted to use NS-3 for some
simulations in 2-3 months for my phd, even if it's alpha by then :P [ else
I'll have to use NS-2, nooo!!! :( ]
I would be fine with this. However, I have tried to actually implement
> the template thing I suggested yesterday. An not-too-simplistic
> implementation is attached to this email. I suspect you will like it a
> lot. As far as I am concerned, I do not see any downside to the approach
> so, I would be okay with pushing this new code to my personal repository
> with a bunch of extensive test cases. Help with the 128bit integer
> implementation of the HighPrecision class would be appreciated. It is
> not super hard but it is going to take time to implement and debug fully
> and my TODO list is getting longer every hour.
I do not wish to comment on implementation details that have no impact on
the interface, though I'll be happy to spend some time to help with
implementation. Here's some misc. comments:
- About the design, what you call TimeUnit<N> I believe a better name would
be TimePower<N>.
- Another item I would comment is that you implement TimeUnit<N> always as
a 128-bit number, in a separate HighPrecision class (in intent if not in
practice). If one wanted to be precise we would consider that TimeUnit<N>
would require N times the storage space of Time<1>. If we would take that
into consideration, we might as well get rid of HighPrecision and inline its
logic in the templated TimeUnit class itself, e.g.:
template <int N>
class TimeUnit
{
public:
TimeUnit ();
TimeUnit (TimeUnit const &o);
/* ... */
private:
int64_t m_high[N];
int64_t m_low[N];
};
- I still have the opinion that a simple scalar value should be a plain
double, not some fancy class;
- I still believe that standard operators + - * / should be defined, not
methods like Add Sub, etc.
- The methods ApproximateToSeconds, ApproximateToMilliSeconds,
ApproximateToMicroSeconds, and ApproximateToNanoSeconds should only be
defined for TimeUnit<1>, though I don't know whether that can be achieved
with C++ templates...
[ hm.. somehow I get the feeling looking at the code that this is already
implemented, but I don't have enough experience with templates to know for
sure ]
I hope you find my comments useful.
Regards,
--
Gustavo J. A. M. Carneiro
"The universe is always one step beyond logic."
More information about the Ns-developers
mailing list