The simulation kernel and models use simtime_t to represent simulation time. simtime_t is an alias to the SimTime class that is 64-bit fixed-point representation with a globally shared exponent. This group describes simtime_t, SimTime, and related types and macros.
Classes | |
class | SimTime |
int64_t-based, base-10 fixed-point simulation time. More... | |
Macros | |
#define | SIMTIME_MAX omnetpp::SimTime::getMaxTime() |
The maximum representable simulation time with the current resolution. More... | |
#define | SIMTIME_ZERO omnetpp::SimTime::ZERO |
Zero simulation time. More... | |
#define | SIMTIME_STR(t) ((t).str().c_str()) |
Convert simtime_t to a C string. More... | |
#define | SIMTIME_DBL(t) ((t).dbl()) |
Convert simtime_t to a double. This conversion incurs precision loss. More... | |
Typedefs | |
typedef SimTime | simtime_t |
Represents simulation time. More... | |
Enumerations | |
enum | SimTimeUnit |
Enum for simulation time base-10 exponents. More... | |
Functions | |
simtime_t | simTime () |
Returns the current simulation time. More... | |
const SimTime | floor (const SimTime &x) |
simtime_t version of floor(double) from math.h. More... | |
const SimTime | floor (const SimTime &x, const SimTime &unit, const SimTime &offset=SimTime()) |
Generalized version of floor(), accepting a unit and an offset: floor(x,u,off) = floor((x-off)/u)*u + off. More... | |
const SimTime | ceil (const SimTime &x) |
simtime_t version of ceil(double) from math.h. More... | |
const SimTime | ceil (const SimTime &x, const SimTime &unit, const SimTime &offset=SimTime()) |
Generalized version of ceil(), accepting a unit and an offset: ceil(x,u,off) = ceil((x-off)/u)*u + off. More... | |
const SimTime | fabs (const SimTime &x) |
Returns the absolute value of the simulation time x. More... | |
int64_t | div (const SimTime &x, const SimTime &y) |
Computes the quotient of the simulation times x and y. The quotient is the algebraic quotient with any fractional part discarded (truncated towards zero). The function internally relies on the standard C/C++ integer division (/) operation. More... | |
const SimTime | fmod (const SimTime &x, const SimTime &y) |
Computes the remainder of the division of two simulation times. More... | |
SIM_API int64_t | preciseDiv (int64_t x, const SimTime &y, int64_t &fractionNumerator, int64_t &fractionDenominator) |
Precise division of an integer and a simulation time. More... | |
Variables | |
const typedef simtime_t & | simtime_t_cref |
Constant reference to a simtime_t. More... | |
const typedef double | const_simtime_t |
This type must be used for global variables representing simulation time. More... | |
#define SIMTIME_MAX omnetpp::SimTime::getMaxTime() |
The maximum representable simulation time with the current resolution.
#define SIMTIME_ZERO omnetpp::SimTime::ZERO |
Zero simulation time.
Using SIMTIME_ZERO can be more efficient than using the 0 constant, especially in non-optimized (debug) builds, because it spares the SimTime constructor call.
#define SIMTIME_STR | ( | t | ) | ((t).str().c_str()) |
Convert simtime_t to a C string.
#define SIMTIME_DBL | ( | t | ) | ((t).dbl()) |
Convert simtime_t to a double. This conversion incurs precision loss.
enum SimTimeUnit |
Enum for simulation time base-10 exponents.
|
inline |
Returns the current simulation time.
References cSimulation::getActiveSimulation(), and cSimulation::getSimTime().
simtime_t version of floor(double) from math.h.
References getScale(), raw(), and setRaw().
simtime_t version of ceil(double) from math.h.
References getScale(), raw(), and setRaw().
Returns the absolute value of the simulation time x.
References raw().
Computes the quotient of the simulation times x and y. The quotient is the algebraic quotient with any fractional part discarded (truncated towards zero). The function internally relies on the standard C/C++ integer division (/) operation.
The handling of division by zero (i.e. when y==0) is platform dependent; on most platforms it causes a runtime error of some sort.
References raw().
Computes the remainder of the division of two simulation times.
The function internally relies on the standard C/C++ integer modulo (%) operation. This has implications regarding the sign of the result: If both operands are nonnegative then the remainder is nonnegative; if not, the sign of the remainder is implementation-defined. However, the following is always true (substitute div() for / and fmod() for %): (x/y) * y + xy == x
The handling of division by zero (i.e. when y==0) is platform dependent; on most platforms it causes a runtime error of some sort.
SIM_API int64_t omnetpp::preciseDiv | ( | int64_t | x, |
const SimTime & | y, | ||
int64_t & | fractionNumerator, | ||
int64_t & | fractionDenominator | ||
) |
Precise division of an integer and a simulation time.
The result is returned as an integer part (in the return value) and a fraction (in the fractionNumerator, fractionDenominator output parameters).
const typedef simtime_t& simtime_t_cref |
Constant reference to a simtime_t.
In many configurations (e.g. debug builds), it is more efficient to return a SimTime from a function as a const ref than by value.
const typedef double const_simtime_t |
This type must be used for global variables representing simulation time.
The normal simtime_t type (i.e. SimTime) cannot be used for static variables, because the scale exponent is only available after the configuration has been read by the simulation program. This type is simply an alias of double
.