This repository contains two time classes to work with in Discrete Event Simulation (DES).
This software is under the GNU - v3 licence:
Laouen Mayal Louan Belloli
- c++11 >=
- gcc
- Boost 1.57 >=
Is an extension of boost_rational<int> that allows using infinity.
Allows to work with the international standar time format hh:mm:ss:mmss and it also allows to work with smaller time units as:
- microseconds
- nanoseconds
- picoseconds
- femtoseconds
This time units are the smaller mesurable units in phisics
1 - NDTime();
2 - NDTime(const NDTime& val);
3 - NDTime(std::initializer_list<int> val);
4 - NDTime(const string val);1 Default constructor: Initialize a new NDTime with value zero as default.
2 Copy constructor: Initialize a new NDTime with the exact same value as the first parameter val.
3 Natural constructor: Initialize a new NDTime with values from {hours} to {hours, ..., femtoseconds}.
11 Parser constructor: Intializa a new NDTime parsing a string val. accepted strings are: {"inf","-inf",["hh", ..., "hh:mm:ss:mmss:mcs:nnss:ppss:ffss"]} the last format is the international standar time format extended until femtoseconds.
| Operator | Left type | Right type |
|---|---|---|
| += | NDTime | NDTime |
| -= | NDtime | NDTim |
| + | NDTime | NDTime |
| - | NDTime | NDTime |
| == | NDTime | NDTime |
| != | NDTime | NDTime |
| < | NDTime | NDTime |
| > | NDTime | NDTime |
| <= | NDTime | NDTime |
| >= | NDTime | NDTime |
| << | std::ostream | NDTime |
| >> | std::istream | NDTime |
void resetToZero();
// Resets the NDTime object to zero (i.e. 00:00:00:000:000:000:000:000)static void startDeepView();
// When deep view mode is enabled calling NDTime::startDeepView() the << operator start printing all the units from hours to femtoseconds.
// line:
std::cout << NDTime({1,1,1,1,1,1,1,1}) << std::endl;
NDTime::startDeepView();
std::cout << NDTime({1,1,1,1,1,1,1,1}) << std::endl;
// output:
01:01:01:001
01:01:01:001:001:001:001:001static void stopDeepView();
Stops deep view mode calling NDTime::stopDeepView()
// line:
NDTime::startDeepView();
std::cout << NDTime({1,1,1,1,1,1,1,1}) << std::endl;
NDTime::stopDeepView();
std::cout << NDTime({1,1,1,1,1,1,1,1}) << std::endl;
// output:
01:01:01:001:001:001:001:001
01:01:01:001static NDTime infinity();
returns a NDTime with value possitive infinitystatic NDTime minus_infinity();
returns a NDTime with value negative infinity