Photon C++ Client API
5.0.7.3
|
Public Member Functions | |
JTime (int time=GETTIMEMS()) | |
~JTime (void) | |
JTime (const JTime &toCopy) | |
JTime & | operator= (const JTime &toCopy) |
JTime & | operator= (int time) |
JTime & | operator+= (const JTime &time) |
JTime & | operator+= (int time) |
JTime & | operator-= (const JTime &time) |
JTime & | operator-= (int time) |
bool | operator< (const JTime &time) const |
bool | operator> (const JTime &time) const |
bool | operator<= (const JTime &time) const |
bool | operator>= (const JTime &time) const |
bool | operator== (const JTime &time) const |
bool | operator!= (const JTime &time) const |
operator int (void) const | |
bool | overflowed (const JTime &time) const |
virtual JString & | toString (JString &retStr, bool withTypes=false) const |
virtual JString & | toString (JString &retStr, bool withTypes=false) const=0 |
JString | toString (bool withTypes=false) const |
Public Member Functions inherited from Base | |
virtual | ~Base (void)=0 |
Public Member Functions inherited from LoggingBase< Base > | |
virtual | ~LoggingBase (void)=0 |
Public Member Functions inherited from ToString | |
virtual | ~ToString (void) |
virtual JString | typeToString (void) const |
JString | toString (bool withTypes=false) const |
Related Functions | |
(Note that these are not member functions.) | |
int & | operator+= (int &Lsh, const JTime &Rsh) |
int & | operator-= (int &Lsh, const JTime &Rsh) |
JTime | operator+ (const JTime &Lsh, const JTime &Rsh) |
JTime | operator+ (const JTime &Lsh, int Rsh) |
JTime | operator+ (int Lsh, const JTime &Rsh) |
JTime | operator- (const JTime &Lsh, const JTime &Rsh) |
JTime | operator- (const JTime &Lsh, int Rsh) |
JTime | operator- (int Lsh, const JTime &Rsh) |
bool | operator== (const JTime &Lsh, int Rsh) |
bool | operator== (int Lsh, const JTime &Rsh) |
bool | operator!= (const JTime &Lsh, int Rsh) |
bool | operator!= (int Lsh, const JTime &Rsh) |
bool | operator< (const JTime &Lsh, int Rsh) |
bool | operator< (int Lsh, const JTime &Rsh) |
bool | operator> (const JTime &Lsh, int Rsh) |
bool | operator> (int Lsh, const JTime &Rsh) |
bool | operator<= (const JTime &Lsh, int Rsh) |
bool | operator<= (int Lsh, const JTime &Rsh) |
bool | operator>= (const JTime &Lsh, int Rsh) |
bool | operator>= (int Lsh, const JTime &Rsh) |
Additional Inherited Members | |
Static Public Member Functions inherited from LoggingBase< Base > | |
static void | setListener (const BaseListener *pBaseListener) |
static int | getDebugOutputLevel (void) |
static bool | setDebugOutputLevel (int debugLevel) |
static const LogFormatOptions & | getLogFormatOptions (void) |
static void | setLogFormatOptions (const LogFormatOptions &options) |
The JTime class is a container class for millisecond timestamps, which accounts for overflows when comparing two instances against each other.
The intended usage of this class is to compare 32 bit integer millisecond timestamps, which only differ in relatively small amounts of ms (a few seconds up to at max a few hours) from each other. 32bit timestamps have the advantage over 64 bit ones, that they need less bytes to store their information, which is of critical value in some situations. However 32 bit milliseconds timestamps overflow every about 49 days. Arithmetical calculations don't react well to those overflows for unsigned integers, but they continue to work fine for signed integers. However when comparing two timestamps, one from shortly before an overflow, one from shortly after, even signed integers won't work: the timestamp INT_MIN is one millisecond LATER than INT_MAX, but when comparing these two as integers, INT_MIN is smaller than INT_MAX. JTime approaches this issue by introducing an overflow threshold of 24 hours. If time a is bigger than time b, but not bigger than time b + 24 hours, than and only than, JTime will also consider it as bigger. This way code like if(timestamp1 < timestamp2) will also work, when between these two timestamps an overflow has happened. The downside is, that this class won't work when comparing 2 timestamps, that differ by more than 24 hours.
JTime | ( | int | time = GETTIMEMS() | ) |
Constructor: Creates an JTime instance.
time | the time in milliseconds to initialize the instance with - defaults to the current timestamp at the time of the call as returned by GETTIMEMS() |
~JTime | ( | void | ) |
Destructor.
operator=.
Makes a deep copy of its right operand into its left operand.
This overwrites old data in the left operand.
JTime & operator= | ( | int | time | ) |
operator=.
Makes a deep copy of its right operand into its left operand.
This overwrites old data in the left operand.
JTime & operator+= | ( | int | time | ) |
operator+=.
Adds the right time to the left time.
JTime & operator-= | ( | int | time | ) |
operator-=.
Subtracts the right time from the left time.
bool operator< | ( | const JTime & | time | ) | const |
operator<.
bool operator> | ( | const JTime & | time | ) | const |
operator>.
bool operator<= | ( | const JTime & | time | ) | const |
operator<=.
bool operator>= | ( | const JTime & | time | ) | const |
operator>=.
bool operator== | ( | const JTime & | time | ) | const |
operator==.
bool operator!= | ( | const JTime & | time | ) | const |
operator==.
operator int | ( | void | ) | const |
operator int.
bool overflowed | ( | const JTime & | time | ) | const |
retStr | reference to a string, to store the return-value in; the information, which is generated by this function, will be attached at the end of any eventually existing previous content of the string |
withTypes | set to true, to include type information in the generated string |
Implements ToString.
toString |
retStr | reference to a string, to store the return-value in; the information, which is generated by this function, will be attached at the end of any eventually existing previous content of the string |
withTypes | set to true, to include type information in the generated string |
JString toString |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
withTypes | set to true, to include type information in the generated string |
|
related |
operator+=.
Adds the right operand to the left operand.
|
related |
operator-=.
Subtracts the right operand from the left operand.
operator+.
Adds its right operand to its left operand and returns the result as a new JTime instance.
operator+.
Adds its right operand to its left operand and returns the result as a new JTime instance.
operator+.
Adds its right operand to its left operand and returns the result as a new JTime instance.
operator-.
Subtracts its right operand from its left operand and returns the result as a new JTime instance.
operator-.
Subtracts its right operand from its left operand and returns the result as a new JTime instance.
operator-.
Subtracts its right operand from its left operand and returns the result as a new JTime instance.
|
related |
operator==.
|
related |
operator==.
|
related |
operator!=.
|
related |
operator!=.
|
related |
operator<. The return value indicates the lexicographic relation between the operands.
|
related |
operator<. The return value indicates the lexicographic relation between the operands.
|
related |
operator>. The return value indicates the lexicographic relation between the operands.
|
related |
operator>. The return value indicates the lexicographic relation between the operands.
|
related |
operator<=. The return value indicates the lexicographic relation between the operands.
|
related |
operator<=. The return value indicates the lexicographic relation between the operands.
|
related |
operator>=. The return value indicates the lexicographic relation between the operands.
|
related |
operator>=. The return value indicates the lexicographic relation between the operands.