src/core/model/nstime.h
author Peter D. Barnes, Jr. <barnes26@llnl.gov>
Wed, 14 Aug 2013 16:53:41 -0700
changeset 10172 22b4d3a7c333
parent 10171 0b3ce943b7c8
child 10176 73dfb0c88ed6
permissions -rw-r--r--
Trim trailing whitespace, doxygen comments
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
150
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 144
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
25
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
/*
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
 * Copyright (c) 2005,2006 INRIA
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
 *
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
 *
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
 * GNU General Public License for more details.
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
 *
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
 *
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
 */
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
#ifndef TIME_H
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
#define TIME_H
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
7383
c5e131450339 remove ns3/ prefix which is un-needed now that all files are in same module.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7256
diff changeset
    23
#include "assert.h"
c5e131450339 remove ns3/ prefix which is un-needed now that all files are in same module.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7256
diff changeset
    24
#include "attribute.h"
c5e131450339 remove ns3/ prefix which is un-needed now that all files are in same module.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7256
diff changeset
    25
#include "attribute-helper.h"
c5e131450339 remove ns3/ prefix which is un-needed now that all files are in same module.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7256
diff changeset
    26
#include "int64x64.h"
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
    27
#include "unused.h"
25
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    28
#include <stdint.h>
9950
9963d622b120 Change to Time::Min () and Time::Max ()
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9906
diff changeset
    29
#include <limits>
9063
32755d0516f4 Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents: 7600
diff changeset
    30
#include <cmath>
209
8b343b9727d7 fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 199
diff changeset
    31
#include <ostream>
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
    32
#include <set>
25
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
namespace ns3 {
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    35
159
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
    36
/**
7149
87514e0d866b Fix doxygen groups for some new modules
Mitch Watrous <watrous@u.washington.edu>
parents: 7083
diff changeset
    37
 * \ingroup core
3182
61fe7fe81ebd Doxygen organization
Tom Henderson <tomh@tomh.org>
parents: 2972
diff changeset
    38
 * \defgroup time Time
3222
f61c17b62fd1 bug 202: classes disappeared from doxygen output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3182
diff changeset
    39
 */
f61c17b62fd1 bug 202: classes disappeared from doxygen output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3182
diff changeset
    40
/**
f61c17b62fd1 bug 202: classes disappeared from doxygen output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3182
diff changeset
    41
 * \ingroup time
9195
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    42
 * \brief keep track of time values and allow control of global simulation resolution
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    43
 *
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    44
 * This class defines all the classic C++ arithmetic
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    45
 * operators +, -, *, /, and all the classic comparison operators:
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
    46
 * ==, !=, <, >, <=, >=. It is thus easy to add, substract, or
9890
3c64a1fbfcf9 Repair Time docs mangled by f0be2daaa38f
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9195
diff changeset
    47
 * multiply Time objects.
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
    48
 *
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
    49
 * For example:
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
    50
 * \code
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
    51
 * Time t1 = Seconds (10.0);
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
    52
 * Time t2 = Seconds (10.0);
9195
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    53
 * Time t3 = t1 * t2;
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    54
 * Time t4 = t1 / t2;
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    55
 * Time t5 = t3 * t1;
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    56
 * Time t6 = t1 / t5;
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    57
 * Time t7 = t3;
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
    58
 * \endcode
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
    59
 *
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
    60
 * You can also use the following non-member functions to manipulate
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
    61
 * any of these ns3::Time object:
9195
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    62
 *  - \ref ns3-Time-Abs ns3::Abs
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    63
 *  - \ref ns3-Time-Max ns3::Max
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    64
 *  - \ref ns3-Time-Min ns3::Min
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
    65
 *
9195
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    66
 * This class also controls
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    67
 * the resolution of the underlying time value . The default resolution
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    68
 * is nanoseconds. That is, TimeStep (1).GetNanoSeconds () will return
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    69
 * 1. It is possible to either increase or decrease the resolution and the
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    70
 * code tries really hard to make this easy.
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
    71
 *
9195
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    72
 * If your resolution is X (say, nanoseconds) and if you create Time objects 
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    73
 * with a lower resolution (say, picoseconds), don't expect that this 
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    74
 * code will return 1: PicoSeconds (1).GetPicoSeconds (). It will most 
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    75
 * likely return 0 because the Time object has only 64 bits of fractional 
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    76
 * precision which means that PicoSeconds (1) is stored as a 64-bit aproximation
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    77
 * of 1/1000 in the Time object. If you later multiply it again by the exact 
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    78
 * value 1000, the result is unlikely to be 1 exactly. It will be close to
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    79
 * 1 but not exactly 1.
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    80
 * 
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    81
 * In general, it is thus a really bad idea to try to use time objects of a
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    82
 * resolution higher than the global resolution controlled through 
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    83
 * Time::SetResolution. If you do need to use picoseconds, it's thus best
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    84
 * to switch the global resolution to picoseconds to avoid nasty surprises.
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
    85
 *
9195
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    86
 * Another important issue to keep in mind is that if you increase the
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    87
 * global resolution, you also implicitely decrease the range of your simulation.
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    88
 * i.e., the global simulation time is stored in a 64 bit integer whose interpretation
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    89
 * will depend on the global resolution so, 2^64 picoseconds which is the maximum
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    90
 * duration of your simulation if the global resolution is picoseconds 
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    91
 * is smaller than 2^64 nanoseconds which is the maximum duration of your simulation
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    92
 * if the global resolution is nanoseconds.
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
    93
 *
9195
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    94
 * Finally, don't even think about ever changing the global resolution after
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    95
 * creating Time objects: all Time objects created before the call to SetResolution
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    96
 * will contain values which are not updated to the new resolution. In practice,
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    97
 * the default value for the attributes of many models is indeed calculated
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    98
 * before the main function of the main program enters. Because of this, if you
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
    99
 * use one of these models (and it's likely), it's going to be hard to change
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
   100
 * the global simulation resolution in a way which gives reasonable results. This
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
   101
 * issue has been filed as bug 954 in the ns-3 bugzilla installation.
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   102
 */
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   103
class Time
156
3b1563e95ea7 new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 151
diff changeset
   104
{
3b1563e95ea7 new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 151
diff changeset
   105
public:
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   106
  /**
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   107
   * The unit to use to interpret a number representing time
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   108
   */
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   109
  enum Unit
7169
358f71a624d8 core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   110
  {
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   111
    S  = 0,   //!< second
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   112
    MS = 1,   //!< millisecond
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   113
    US = 2,   //!< microsecond
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   114
    NS = 3,   //!< nanosecond
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   115
    PS = 4,   //!< picosecond
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   116
    FS = 5,   //!< femtosecond
7169
358f71a624d8 core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   117
    LAST = 6
358f71a624d8 core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   118
  };
25
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   119
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   120
  inline Time &operator = (const Time &o)
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   121
  {
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   122
    m_data = o.m_data;
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   123
    return *this;
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   124
  }
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   125
  inline Time ()
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   126
    : m_data ()
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   127
  {
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   128
    if (g_markingTimes)
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   129
      {
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   130
	Mark (this);
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   131
      }
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   132
  }
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   133
  inline Time(const Time &o)
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   134
    : m_data (o.m_data)
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   135
  {
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   136
    if (g_markingTimes)
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   137
      {
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   138
	Mark (this);
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   139
      }
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   140
  }
7032
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   141
  explicit inline Time (double v)
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7169
diff changeset
   142
    : m_data (lround (v))
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   143
  {
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   144
    if (g_markingTimes)
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   145
      {
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   146
	Mark (this);
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   147
      }
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   148
  }
7032
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   149
  explicit inline Time (int v)
7036
f94c610203be a 64bit time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7033
diff changeset
   150
    : m_data (v)
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   151
  {
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   152
    if (g_markingTimes)
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   153
      {
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   154
	Mark (this);
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   155
      }
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   156
  }
7037
76d6e8e13cb3 add missing constructors
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7036
diff changeset
   157
  explicit inline Time (long int v)
7036
f94c610203be a 64bit time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7033
diff changeset
   158
    : m_data (v)
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   159
  {
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   160
    if (g_markingTimes)
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   161
      {
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   162
	Mark (this);
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   163
      }
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   164
  }
7037
76d6e8e13cb3 add missing constructors
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7036
diff changeset
   165
  explicit inline Time (long long int v)
76d6e8e13cb3 add missing constructors
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7036
diff changeset
   166
    : m_data (v)
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   167
  {
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   168
    if (g_markingTimes)
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   169
      {
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   170
	Mark (this);
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   171
      }
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   172
  }
7037
76d6e8e13cb3 add missing constructors
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7036
diff changeset
   173
  explicit inline Time (unsigned int v)
7036
f94c610203be a 64bit time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7033
diff changeset
   174
    : m_data (v)
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   175
  {
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   176
    if (g_markingTimes)
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   177
      {
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   178
	Mark (this);
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   179
      }
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   180
  }
7032
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   181
  explicit inline Time (unsigned long int v)
7036
f94c610203be a 64bit time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7033
diff changeset
   182
    : m_data (v)
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   183
  {
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   184
    if (g_markingTimes)
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   185
      {
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   186
	Mark (this);
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   187
      }
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   188
  }
7033
7adf8cfb1a20 add missing constructor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7032
diff changeset
   189
  explicit inline Time (unsigned long long int v)
7036
f94c610203be a 64bit time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7033
diff changeset
   190
    : m_data (v)
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   191
  {
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   192
    if (g_markingTimes)
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   193
      {
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   194
	Mark (this);
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   195
      }
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   196
  }
339
0ce0402e419f make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 286
diff changeset
   197
  /**
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   198
   * \brief Construct Time object from common time expressions like "1ms"
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   199
   *
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   200
   * Supported units include:
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   201
   * - `s`  (seconds)
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   202
   * - `ms` (milliseconds)
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   203
   * - `us` (microseconds)
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   204
   * - `ns` (nanoseconds)
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   205
   * - `ps` (picoseconds)
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   206
   * - `fs` (femtoseconds)
372
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
   207
   *
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
   208
   * There can be no white space between the numerical portion
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
   209
   * and the units.  Any otherwise malformed string causes a fatal error to
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
   210
   * occur.
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   211
   * \param s The string to parse into a Time
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   212
   */
7032
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   213
  explicit Time (const std::string & s);
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   214
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   215
  /**
9891
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   216
   * \brief Minimum representable Time
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   217
   */
9950
9963d622b120 Change to Time::Min () and Time::Max ()
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9906
diff changeset
   218
  static Time Min ()
9891
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   219
  {
9950
9963d622b120 Change to Time::Min () and Time::Max ()
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9906
diff changeset
   220
    return Time (std::numeric_limits<int64_t>::min ());
9891
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   221
  }
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   222
  /**
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   223
   * \brief Maximum representable Time
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   224
   */
9950
9963d622b120 Change to Time::Min () and Time::Max ()
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9906
diff changeset
   225
  static Time Max ()
9891
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   226
  {
9950
9963d622b120 Change to Time::Min () and Time::Max ()
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9906
diff changeset
   227
    return Time (std::numeric_limits<int64_t>::max ());
9891
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   228
  }
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   229
  
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   230
  /**
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   231
   *  Destructor
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   232
   */
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   233
  ~Time ()
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   234
  {
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   235
    if (g_markingTimes)
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   236
      {
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   237
        Clear (this);
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   238
      }
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   239
  }
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   240
  
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   241
  /**
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   242
   * \return true if the time is zero, false otherwise.
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   243
   */
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   244
  inline bool IsZero (void) const
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   245
  {
7036
f94c610203be a 64bit time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7033
diff changeset
   246
    return m_data == 0;
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   247
  }
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   248
  /**
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   249
   * \return true if the time is negative or zero, false otherwise.
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   250
   */
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   251
  inline bool IsNegative (void) const
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   252
  {
7036
f94c610203be a 64bit time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7033
diff changeset
   253
    return m_data <= 0;
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   254
  }
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   255
  /**
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   256
   * \return true if the time is positive or zero, false otherwise.
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   257
   */
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   258
  inline bool IsPositive (void) const
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   259
  {
7036
f94c610203be a 64bit time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7033
diff changeset
   260
    return m_data >= 0;
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   261
  }
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   262
  /**
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   263
   * \return true if the time is strictly negative, false otherwise.
372
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
   264
   */
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   265
  inline bool IsStrictlyNegative (void) const
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   266
  {
7036
f94c610203be a 64bit time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7033
diff changeset
   267
    return m_data < 0;
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   268
  }
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   269
  /**
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   270
   * \return true if the time is strictly positive, false otherwise.
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   271
   */
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   272
  inline bool IsStrictlyPositive (void) const
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   273
  {
7036
f94c610203be a 64bit time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7033
diff changeset
   274
    return m_data > 0;
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   275
  }
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   276
  /**
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   277
   *  \return -1,0,+1 if `this < o`, `this == o`, or `this > o`
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   278
   */
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   279
  inline int Compare (const Time &o) const
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   280
  {
7169
358f71a624d8 core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   281
    return (m_data < o.m_data) ? -1 : (m_data == o.m_data) ? 0 : 1;
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   282
  }
6496
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   283
372
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
   284
  /**
339
0ce0402e419f make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 286
diff changeset
   285
   * \returns an approximation in seconds of the time stored in this
0ce0402e419f make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 286
diff changeset
   286
   *          instance.
0ce0402e419f make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 286
diff changeset
   287
   */
6496
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   288
  inline double GetSeconds (void) const
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   289
  {
7040
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   290
    return ToDouble (Time::S);
6496
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   291
  }
676
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   292
339
0ce0402e419f make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 286
diff changeset
   293
  /**
0ce0402e419f make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 286
diff changeset
   294
   * \returns an approximation in milliseconds of the time stored in this
0ce0402e419f make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 286
diff changeset
   295
   *          instance.
6180
cd0d8ba00e6c coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5836
diff changeset
   296
   */
6496
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   297
  inline int64_t GetMilliSeconds (void) const
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   298
  {
7040
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   299
    return ToInteger (Time::MS);
6496
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   300
  }
339
0ce0402e419f make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 286
diff changeset
   301
  /**
0ce0402e419f make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 286
diff changeset
   302
   * \returns an approximation in microseconds of the time stored in this
0ce0402e419f make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 286
diff changeset
   303
   *          instance.
0ce0402e419f make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 286
diff changeset
   304
   */
6496
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   305
  inline int64_t GetMicroSeconds (void) const
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   306
  {
7040
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   307
    return ToInteger (Time::US);
6496
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   308
  }
339
0ce0402e419f make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 286
diff changeset
   309
  /**
0ce0402e419f make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 286
diff changeset
   310
   * \returns an approximation in nanoseconds of the time stored in this
0ce0402e419f make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 286
diff changeset
   311
   *          instance.
0ce0402e419f make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 286
diff changeset
   312
   */
6496
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   313
  inline int64_t GetNanoSeconds (void) const
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   314
  {
7040
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   315
    return ToInteger (Time::NS);
6496
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   316
  }
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   317
  /**
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   318
   * \returns an approximation in picoseconds of the time stored in this
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   319
   *          instance.
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   320
   */
6496
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   321
  inline int64_t GetPicoSeconds (void) const
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   322
  {
7040
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   323
    return ToInteger (Time::PS);
6496
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   324
  }
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   325
  /**
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   326
   * \returns an approximation in femtoseconds of the time stored in this
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   327
   *          instance.
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   328
   */
6496
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   329
  inline int64_t GetFemtoSeconds (void) const
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   330
  {
7040
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   331
    return ToInteger (Time::FS);
6496
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   332
  }
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   333
  /**
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   334
   * \returns the raw time value, in the current units
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   335
   */
6496
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   336
  inline int64_t GetTimeStep (void) const
6180
cd0d8ba00e6c coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5836
diff changeset
   337
  {
7036
f94c610203be a 64bit time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7033
diff changeset
   338
    return m_data;
339
0ce0402e419f make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 286
diff changeset
   339
  }
7032
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   340
  inline double GetDouble (void) const
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   341
  {
7036
f94c610203be a 64bit time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7033
diff changeset
   342
    return m_data;
7032
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   343
  }
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   344
  inline int64_t GetInteger (void) const
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   345
  {
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   346
    return GetTimeStep ();
339
0ce0402e419f make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 286
diff changeset
   347
  }
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   348
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   349
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   350
  /**
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   351
   * \param resolution the new resolution to use
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   352
   *
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   353
   * Change the global resolution used to convert all 
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   354
   * user-provided time values in Time objects and Time objects
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   355
   * in user-expected time units.
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   356
   */
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   357
  static void SetResolution (enum Unit resolution);
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   358
  /**
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   359
   * \returns the current global resolution.
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   360
   */
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   361
  static enum Unit GetResolution (void);
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   362
  /**
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   363
   * \param value to convert into a Time object
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   364
   * \param timeUnit the unit of the value to convert
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   365
   * \return a new Time object
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   366
   *
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   367
   * This method interprets the input value according to the input
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   368
   * unit and constructs a matching Time object.
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   369
   *
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   370
   * \sa FromDouble, ToDouble, ToInteger
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   371
   */
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   372
  inline static Time FromInteger (uint64_t value, enum Unit timeUnit)
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   373
  {
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   374
    struct Information *info = PeekInformation (timeUnit);
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   375
    if (info->fromMul)
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   376
      {
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   377
        value *= info->factor;
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   378
      }
7036
f94c610203be a 64bit time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7033
diff changeset
   379
    else
f94c610203be a 64bit time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7033
diff changeset
   380
      {
f94c610203be a 64bit time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7033
diff changeset
   381
        value /= info->factor;
f94c610203be a 64bit time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7033
diff changeset
   382
      }
f94c610203be a 64bit time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7033
diff changeset
   383
    return Time (value);
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   384
  }
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   385
  /**
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   386
   * \param timeUnit the unit of the value to return
7600
57ba46094a0d fix various doxygen errors
Vedran Miletić <rivanvx@gmail.com>
parents: 7445
diff changeset
   387
   * \return int64_t time value
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   388
   *
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   389
   * Convert the input time into an integer value according to the requested
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   390
   * time unit.
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   391
   */
7040
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   392
  inline int64_t ToInteger (enum Unit timeUnit) const
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   393
  {
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   394
    struct Information *info = PeekInformation (timeUnit);
7040
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   395
    int64_t v = m_data;
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   396
    if (info->toMul)
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   397
      {
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   398
        v *= info->factor;
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   399
      }
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   400
    else
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   401
      {
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   402
        v /= info->factor; 
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   403
      }
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   404
    return v;
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   405
  }
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   406
  /**
7040
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   407
   * \param value to convert into a Time object
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   408
   * \param timeUnit the unit of the value to convert
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   409
   * \return a new Time object
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   410
   *
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   411
   * \sa FromInteger, ToInteger, ToDouble
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   412
   */
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   413
  inline static Time FromDouble (double value, enum Unit timeUnit)
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   414
  {
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   415
    return From (int64x64_t (value), timeUnit);
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   416
  }
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   417
  /**
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   418
   * \param timeUnit the unit of the value to return
7600
57ba46094a0d fix various doxygen errors
Vedran Miletić <rivanvx@gmail.com>
parents: 7445
diff changeset
   419
   * \return double time value
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   420
   *
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   421
   * Convert the input time into a floating point value according to the requested
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   422
   * time unit.
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   423
   */
7040
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   424
  inline double ToDouble (enum Unit timeUnit) const
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   425
  {
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   426
    return To (timeUnit).GetDouble ();
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   427
  }
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   428
  static inline Time From (const int64x64_t &from, enum Unit timeUnit)
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   429
  {
7036
f94c610203be a 64bit time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7033
diff changeset
   430
    struct Information *info = PeekInformation (timeUnit);
7040
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   431
    // DO NOT REMOVE this temporary variable. It's here
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   432
    // to work around a compiler bug in gcc 3.4
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   433
    int64x64_t retval = from; 
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   434
    if (info->fromMul)
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   435
      {
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   436
        retval *= info->timeFrom;
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   437
      }
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   438
    else
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   439
      {
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   440
        retval.MulByInvert (info->timeFrom);
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   441
      }
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   442
    return Time (retval);
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   443
  }
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   444
  inline int64x64_t To (enum Unit timeUnit) const
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   445
  {
7040
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   446
    struct Information *info = PeekInformation (timeUnit);
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   447
    int64x64_t retval = int64x64_t (m_data);
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   448
    if (info->toMul)
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   449
      {
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   450
        retval *= info->timeTo;
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   451
      }
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   452
    else
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   453
      {
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   454
        retval.MulByInvert (info->timeTo);
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   455
      }
7036
f94c610203be a 64bit time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7033
diff changeset
   456
    return retval;
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   457
  }
7044
f94b264549d1 introduce implicit conversion operator
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7041
diff changeset
   458
  inline operator int64x64_t () const
f94b264549d1 introduce implicit conversion operator
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7041
diff changeset
   459
  {
f94b264549d1 introduce implicit conversion operator
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7041
diff changeset
   460
    return int64x64_t (m_data);
f94b264549d1 introduce implicit conversion operator
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7041
diff changeset
   461
  }
f94b264549d1 introduce implicit conversion operator
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7041
diff changeset
   462
  explicit inline Time (const int64x64_t &value)
7040
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   463
    : m_data (value.GetHigh ())
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   464
  {
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   465
    if (g_markingTimes)
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   466
      {
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   467
	Mark (this);
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   468
      }
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   469
  }
7040
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   470
  inline static Time From (const int64x64_t &value)
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   471
  {
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   472
    return Time (value);
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   473
  }
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   474
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   475
private:
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   476
  /**
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   477
   * How to convert between other units and the current unit
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   478
   */
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   479
  struct Information
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   480
  {
10172
22b4d3a7c333 Trim trailing whitespace, doxygen comments
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10171
diff changeset
   481
    bool toMul;                     //!< Multiply when converting To, otherwise divide  
22b4d3a7c333 Trim trailing whitespace, doxygen comments
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10171
diff changeset
   482
    bool fromMul;                   //!< Multiple when converting From, otherwise divide
22b4d3a7c333 Trim trailing whitespace, doxygen comments
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10171
diff changeset
   483
    int64_t factor;                 //!< Ratio of this unit / current unit		  
22b4d3a7c333 Trim trailing whitespace, doxygen comments
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10171
diff changeset
   484
    int64x64_t timeTo;              //!< Multiplier to convert to this unit		  
22b4d3a7c333 Trim trailing whitespace, doxygen comments
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10171
diff changeset
   485
    int64x64_t timeFrom;            //!< Multiplier to convert from this unit		  
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   486
  };
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   487
  /**
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   488
   * Current time unit, and conversion info.
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   489
   */
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   490
  struct Resolution
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   491
  {
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   492
    struct Information info[LAST];  //!<  Conversion info from current unit
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   493
    enum Time::Unit unit;           //!<  Current time unit
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   494
  };
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   495
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   496
  static inline struct Resolution *PeekResolution (void)
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   497
  {
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   498
    static struct Time::Resolution resolution = SetDefaultNsResolution ();
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   499
    return &resolution;
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   500
  }
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   501
  static inline struct Information *PeekInformation (enum Unit timeUnit)
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   502
  {
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   503
    return &(PeekResolution ()->info[timeUnit]);
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   504
  }
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   505
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   506
  static struct Resolution SetDefaultNsResolution (void);
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   507
  static void SetResolution (enum Unit unit, struct Resolution *resolution,
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   508
                             const bool convert = true);
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   509
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   510
  /**
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   511
   *  Record all instances of Time, so we can rescale them when
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   512
   *  the resolution changes.
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   513
   *
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   514
   *  \intern
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   515
   *
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   516
   *  We use a std::set so we can remove the record easily when
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   517
   *  ~Time() is called.
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   518
   *
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   519
   *  We don't use Ptr<Time>, because we would have to bloat every Time
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   520
   *  instance with SimpleRefCount<Time>.
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   521
   *
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   522
   *  Seems like this should be std::set< Time * const >, but
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   523
   *  [Stack Overflow](http://stackoverflow.com/questions/5526019/compile-errors-stdset-with-const-members)
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   524
   *  says otherwise, quoting the standard:
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   525
   *
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   526
   *  > &sect;23.1/3 states that std::set key types must be assignable
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   527
   *  > and copy constructable; clearly a const type will not be assignable.
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   528
   */
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   529
  typedef std::set< Time * > MarkedTimes;
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   530
  /**
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   531
   *  Record of outstanding Time objects which will need conversion
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   532
   *  when the resolution is set.
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   533
   *
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   534
   *  \intern
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   535
   *
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   536
   *  Use a classic static variable so we can check in Time ctors
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   537
   *  without a function call.  
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   538
   *
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   539
   *  We'd really like to initialize this here, but we don't want to require
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   540
   *  C++0x, so we init in time.cc.  To ensure that happens before first use,
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   541
   *  we add a call to StaticInit (below) to every compilation unit which
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   542
   *  includes nstime.h.
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   543
   */
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   544
  static MarkedTimes * g_markingTimes;
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   545
public:
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   546
  /**
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   547
   *  Function to force static initialization of Time
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   548
   */
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   549
  static bool StaticInit ();
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   550
private:
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   551
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   552
  /* Friend the Simulator class so it can call the private function
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   553
     ClearMarkedTimes ()
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   554
  */
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   555
  friend class Simulator;
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   556
  /**
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   557
   *  Remove all MarkedTimes.
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   558
   *
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   559
   *  \intern
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   560
   *  Has to be visible to the Simulator class, hence the friending.
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   561
   */
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   562
  static void ClearMarkedTimes ();
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   563
  /**
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   564
   *  Record a Time instance with the MarkedTimes
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   565
   */
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   566
  static void Mark (Time * const time);
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   567
  /**
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   568
   *  Remove a Time instance from the MarkedTimes, called by ~Time()
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   569
   */
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   570
  static void Clear (Time * const time);
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   571
  /**
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   572
   *  Convert existing Times to the new unit.
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   573
   */
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   574
  static void ConvertTimes (const enum Unit unit);
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   575
7032
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   576
  friend bool operator == (const Time &lhs, const Time &rhs);
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   577
  friend bool operator != (const Time &lhs, const Time &rhs);
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   578
  friend bool operator <= (const Time &lhs, const Time &rhs);
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   579
  friend bool operator >= (const Time &lhs, const Time &rhs);
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   580
  friend bool operator < (const Time &lhs, const Time &rhs);
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   581
  friend bool operator > (const Time &lhs, const Time &rhs);
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   582
  friend Time operator + (const Time &lhs, const Time &rhs);
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   583
  friend Time operator - (const Time &lhs, const Time &rhs);
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   584
  friend Time &operator += (Time &lhs, const Time &rhs);
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   585
  friend Time &operator -= (Time &lhs, const Time &rhs);
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   586
  friend Time Abs (const Time &time);
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   587
  friend Time Max (const Time &ta, const Time &tb);
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   588
  friend Time Min (const Time &ta, const Time &tb);
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   589
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   590
  
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   591
  int64_t m_data;                   //!< Virtual time value, in the current unit.
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   592
  
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   593
};  // class Time
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   594
  
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   595
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   596
// Force static initialization of Time
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   597
static bool NS_UNUSED_GLOBAL (g_TimeStaticInit) = Time::StaticInit ();
339
0ce0402e419f make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 286
diff changeset
   598
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   599
inline bool
7032
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   600
operator == (const Time &lhs, const Time &rhs)
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   601
{
7032
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   602
  return lhs.m_data == rhs.m_data;
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   603
}
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   604
inline bool
7032
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   605
operator != (const Time &lhs, const Time &rhs)
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   606
{
7032
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   607
  return lhs.m_data != rhs.m_data;
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   608
}
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   609
inline bool
7032
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   610
operator <= (const Time &lhs, const Time &rhs)
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   611
{
7032
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   612
  return lhs.m_data <= rhs.m_data;
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   613
}
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   614
inline bool
7032
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   615
operator >= (const Time &lhs, const Time &rhs)
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   616
{
7032
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   617
  return lhs.m_data >= rhs.m_data;
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   618
}
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   619
inline bool
7032
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   620
operator < (const Time &lhs, const Time &rhs)
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   621
{
7032
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   622
  return lhs.m_data < rhs.m_data;
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   623
}
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   624
inline bool
7032
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   625
operator > (const Time &lhs, const Time &rhs)
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   626
{
7032
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   627
  return lhs.m_data > rhs.m_data;
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   628
}
7032
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   629
inline Time operator + (const Time &lhs, const Time &rhs)
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   630
{
7032
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   631
  return Time (lhs.m_data + rhs.m_data);
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   632
}
7032
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   633
inline Time operator - (const Time &lhs, const Time &rhs)
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   634
{
7032
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   635
  return Time (lhs.m_data - rhs.m_data);
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   636
}
7032
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   637
inline Time &operator += (Time &lhs, const Time &rhs)
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   638
{
7032
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   639
  lhs.m_data += rhs.m_data;
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   640
  return lhs;
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   641
}
7032
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   642
inline Time &operator -= (Time &lhs, const Time &rhs)
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   643
{
7032
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   644
  lhs.m_data -= rhs.m_data;
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   645
  return lhs;
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   646
}
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   647
159
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   648
/**
9195
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
   649
 * \anchor ns3-Time-Abs
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
   650
 * \relates ns3::TimeUnit
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   651
 * Absolute value function for Time
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   652
 * \param time the input value
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   653
 * \returns the absolute value of the input value.
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   654
 */
7032
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   655
inline Time Abs (const Time &time)
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   656
{
7169
358f71a624d8 core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   657
  return Time ((time.m_data < 0) ? -time.m_data : time.m_data);
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   658
}
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   659
/**
9195
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
   660
 * \anchor ns3-Time-Max
f0be2daaa38f bug 954: back out changesets 1a2abe07b53d, 8934b7c0c1cb, and 8ef8d8bae350
Tom Henderson <tomh@tomh.org>
parents: 9187
diff changeset
   661
 * \relates ns3::TimeUnit
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   662
 * \param ta the first value
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   663
 * \param tb the seconds value
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   664
 * \returns the max of the two input values.
159
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   665
 */
7032
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   666
inline Time Max (const Time &ta, const Time &tb)
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   667
{
7169
358f71a624d8 core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   668
  return Time ((ta.m_data < tb.m_data) ? tb : ta);
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   669
}
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   670
/**
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   671
 * \param ta the first value
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   672
 * \param tb the seconds value
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   673
 * \returns the min of the two input values.
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   674
 */
7032
17d4c8f349d6 split out uint64x64 type, optimize
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6567
diff changeset
   675
inline Time Min (const Time &ta, const Time &tb)
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   676
{
7169
358f71a624d8 core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   677
  return Time ((ta.m_data > tb.m_data) ? tb : ta);
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   678
}
209
8b343b9727d7 fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 199
diff changeset
   679
143
552ff26b4224 new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
   680
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   681
/**
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   682
 * \brief Time output streamer.
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   683
 * 
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   684
 * Generates output such as "3.96ns"
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   685
 * \relates ns3::Time
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   686
 */
2409
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2408
diff changeset
   687
std::ostream& operator<< (std::ostream& os, const Time & time);
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   688
/**
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   689
 * \brief Time input streamer
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   690
 *
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   691
 * Uses the Time::Time (const std::string &) constructor
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   692
 * \relates ns3::Time
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   693
 */
2409
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2408
diff changeset
   694
std::istream& operator>> (std::istream& is, Time & time);
209
8b343b9727d7 fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 199
diff changeset
   695
159
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   696
/**
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   697
 * \brief create ns3::Time instances in units of seconds.
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   698
 *
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   699
 * For example:
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   700
 * \code
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   701
 * Time t = Seconds (2.0);
7040
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   702
 * Simulator::Schedule (Seconds (5.0), ...);
159
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   703
 * \endcode
5227
ecb08c1fc273 Fix some doxygen warnings revealed by WARN_NO_PARAMDOC=YES in doc/doxygen.conf.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 3222
diff changeset
   704
 * \param seconds seconds value
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   705
 * \relates ns3::Time
159
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   706
 */
6496
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   707
inline Time Seconds (double seconds)
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   708
{
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   709
  return Time::FromDouble (seconds, Time::S);
6496
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   710
}
156
3b1563e95ea7 new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 151
diff changeset
   711
159
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   712
/**
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   713
 * \brief create ns3::Time instances in units of milliseconds.
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   714
 *
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   715
 * For example:
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   716
 * \code
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   717
 * Time t = MilliSeconds (2);
162
5b398ac221c7 make Time relative instead of Absolute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 159
diff changeset
   718
 * Simulator::Schedule (MilliSeconds (5), ...);
159
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   719
 * \endcode
5227
ecb08c1fc273 Fix some doxygen warnings revealed by WARN_NO_PARAMDOC=YES in doc/doxygen.conf.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 3222
diff changeset
   720
 * \param ms milliseconds value
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   721
 * \relates ns3::Time
159
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   722
 */
6496
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   723
inline Time MilliSeconds (uint64_t ms)
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   724
{
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   725
  return Time::FromInteger (ms, Time::MS);
6496
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   726
}
159
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   727
/**
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   728
 * \brief create ns3::Time instances in units of microseconds.
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   729
 *
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   730
 * For example:
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   731
 * \code
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   732
 * Time t = MicroSeconds (2);
162
5b398ac221c7 make Time relative instead of Absolute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 159
diff changeset
   733
 * Simulator::Schedule (MicroSeconds (5), ...);
159
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   734
 * \endcode
5227
ecb08c1fc273 Fix some doxygen warnings revealed by WARN_NO_PARAMDOC=YES in doc/doxygen.conf.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 3222
diff changeset
   735
 * \param us microseconds value
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   736
 * \relates ns3::Time
159
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   737
 */
6496
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   738
inline Time MicroSeconds (uint64_t us)
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   739
{
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   740
  return Time::FromInteger (us, Time::US);
6496
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   741
}
159
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   742
/**
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   743
 * \brief create ns3::Time instances in units of nanoseconds.
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   744
 *
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   745
 * For example:
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   746
 * \code
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   747
 * Time t = NanoSeconds (2);
162
5b398ac221c7 make Time relative instead of Absolute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 159
diff changeset
   748
 * Simulator::Schedule (NanoSeconds (5), ...);
159
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   749
 * \endcode
5227
ecb08c1fc273 Fix some doxygen warnings revealed by WARN_NO_PARAMDOC=YES in doc/doxygen.conf.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 3222
diff changeset
   750
 * \param ns nanoseconds value
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   751
 * \relates ns3::Time
159
e2c8e211039e add doxygen dox for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 158
diff changeset
   752
 */
6496
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   753
inline Time NanoSeconds (uint64_t ns)
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   754
{
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   755
  return Time::FromInteger (ns, Time::NS);
6496
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   756
}
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   757
/**
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   758
 * \brief create ns3::Time instances in units of picoseconds.
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   759
 *
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   760
 * For example:
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   761
 * \code
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   762
 * Time t = PicoSeconds (2);
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   763
 * Simulator::Schedule (PicoSeconds (5), ...);
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   764
 * \endcode
5227
ecb08c1fc273 Fix some doxygen warnings revealed by WARN_NO_PARAMDOC=YES in doc/doxygen.conf.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 3222
diff changeset
   765
 * \param ps picoseconds value
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   766
 * \relates ns3::Time
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   767
 */
6496
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   768
inline Time PicoSeconds (uint64_t ps)
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   769
{
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   770
  return Time::FromInteger (ps, Time::PS);
6496
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   771
}
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   772
/**
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   773
 * \brief create ns3::Time instances in units of femtoseconds.
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   774
 *
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   775
 * For example:
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   776
 * \code
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   777
 * Time t = FemtoSeconds (2);
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   778
 * Simulator::Schedule (FemtoSeconds (5), ...);
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   779
 * \endcode
5227
ecb08c1fc273 Fix some doxygen warnings revealed by WARN_NO_PARAMDOC=YES in doc/doxygen.conf.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 3222
diff changeset
   780
 * \param fs femtoseconds value
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   781
 * \relates ns3::Time
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   782
 */
6496
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   783
inline Time FemtoSeconds (uint64_t fs)
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   784
{
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   785
  return Time::FromInteger (fs, Time::FS);
6496
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   786
}
681
e1696c31b6eb improve dox
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 679
diff changeset
   787
7040
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   788
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   789
/**
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   790
 * \see Seconds(double)
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   791
 * \relates ns3::Time
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   792
 */ 
7040
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   793
inline Time Seconds (int64x64_t seconds)
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   794
{
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   795
  return Time::From (seconds, Time::S);
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   796
}
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   797
/**
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   798
 * \see MilliSeconds(uint64_t)
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   799
 * \relates ns3::Time
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   800
 */ 
7040
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   801
inline Time MilliSeconds (int64x64_t ms)
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   802
{
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   803
  return Time::From (ms, Time::MS);
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   804
}
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   805
/**
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   806
 * \see MicroSeconds(uint64_t)
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   807
 * \relates ns3::Time
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   808
 */ 
7040
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   809
inline Time MicroSeconds (int64x64_t us)
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   810
{
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   811
  return Time::From (us, Time::US);
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   812
}
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   813
/**
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   814
 * \see NanoSeconds(uint64_t)
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   815
 * \relates ns3::Time
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   816
 */ 
7040
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   817
inline Time NanoSeconds (int64x64_t ns)
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   818
{
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   819
  return Time::From (ns, Time::NS);
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   820
}
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   821
/**
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   822
 * \see PicoSeconds(uint64_t)
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   823
 * \relates ns3::Time
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   824
 */ 
7040
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   825
inline Time PicoSeconds (int64x64_t ps)
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   826
{
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   827
  return Time::From (ps, Time::PS);
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   828
}
10171
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   829
/**
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   830
 * \see FemtoSeconds(uint64_t)
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   831
 * \relates ns3::Time
0b3ce943b7c8 bug 954: Changing the simulation time resolution does not work well with attributes
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9975
diff changeset
   832
 */ 
7040
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   833
inline Time FemtoSeconds (int64x64_t fs)
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   834
{
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   835
  return Time::From (fs, Time::FS);
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   836
}
444bb5c76bff get rid of Scalar and co.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7037
diff changeset
   837
681
e1696c31b6eb improve dox
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 679
diff changeset
   838
// internal function not publicly documented
6496
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   839
inline Time TimeStep (uint64_t ts)
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   840
{
7036
f94c610203be a 64bit time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7033
diff changeset
   841
  return Time (ts);
6496
ed210e7279a7 rewrite time integer support for 32bit systems.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6411
diff changeset
   842
}
156
3b1563e95ea7 new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 151
diff changeset
   843
2969
9d05d2a95dfa improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2965
diff changeset
   844
/**
9d05d2a95dfa improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2965
diff changeset
   845
 * \class ns3::TimeValue
9d05d2a95dfa improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2965
diff changeset
   846
 * \brief hold objects of type ns3::Time
9d05d2a95dfa improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2965
diff changeset
   847
 */
9d05d2a95dfa improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2965
diff changeset
   848
9d05d2a95dfa improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2965
diff changeset
   849
6514
92a84235d8f2 get rid of TimeUnit<N>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6496
diff changeset
   850
ATTRIBUTE_VALUE_DEFINE (Time);
2447
eee344085a96 convert to new helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   851
ATTRIBUTE_ACCESSOR_DEFINE (Time);
9891
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   852
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   853
/**
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   854
 * \brief Helper to make a Time checker with bounded range.
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   855
 * Both limits are inclusive
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   856
 *
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   857
 * \return the AttributeChecker 
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   858
 */
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   859
Ptr<const AttributeChecker> MakeTimeChecker (const Time min, const Time max);
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   860
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   861
/**
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   862
 * \brief Helper to make an unbounded Time checker.
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   863
 *
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   864
 * \return the AttributeChecker
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   865
 */
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   866
inline
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   867
Ptr<const AttributeChecker> MakeTimeChecker (void)
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   868
{
9950
9963d622b120 Change to Time::Min () and Time::Max ()
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9906
diff changeset
   869
  return MakeTimeChecker (Time::Min (), Time::Max ());
9891
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   870
}
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   871
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   872
/**
9975
636fcd7cad0e Revert 097891ca7dea (Change upper-bounded TimeChecker to actually do what documentation says) and fix documentation instead
Vedran Miletić <rivanvx@gmail.com>
parents: 9973
diff changeset
   873
 * \brief Helper to make a Time checker with a lower bound.
9891
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   874
 *
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   875
 * \return the AttributeChecker
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   876
 */
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   877
inline
9975
636fcd7cad0e Revert 097891ca7dea (Change upper-bounded TimeChecker to actually do what documentation says) and fix documentation instead
Vedran Miletić <rivanvx@gmail.com>
parents: 9973
diff changeset
   878
Ptr<const AttributeChecker> MakeTimeChecker (const Time min)
9891
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   879
{
9975
636fcd7cad0e Revert 097891ca7dea (Change upper-bounded TimeChecker to actually do what documentation says) and fix documentation instead
Vedran Miletić <rivanvx@gmail.com>
parents: 9973
diff changeset
   880
  return MakeTimeChecker (min, Time::Max ());
9891
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   881
}
e12094c8b31b Time attributes with enforced bounds.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9890
diff changeset
   882
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   883
2390
7e6dfae536cd add Value support to Time
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2170
diff changeset
   884
} // namespace ns3
25
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   885
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   886
#endif /* TIME_H */