feisty meow concerns codebase  2.140
timely::time_stamp Class Reference

Represents a point in time relative to the operating system startup time. More...

#include <time_stamp.h>

Inheritance diagram for timely::time_stamp:
Collaboration diagram for timely::time_stamp:

Public Types

enum  stamp_display_style { STAMP_RELATIVE , STAMP_ABSOLUTE }
 
typedef double time_representation
 the representation of time for this universe, measured in milliseconds. More...
 

Public Member Functions

 DEFINE_CLASS_NAME ("time_stamp")
 
 time_stamp ()
 creates a time_stamp containing the current time. More...
 
 time_stamp (time_representation offset)
 creates a stamp after the current time by "offset" milliseconds. More...
 
void reset ()
 sets the stamp time back to now. More...
 
void reset (time_representation offset)
 sets the stamp forward by "offset" similar to the second constructor. More...
 
time_representation value () const
 returns the time_stamp in terms of the lower level type. More...
 
basis::astring text_form (stamp_display_style style=STAMP_RELATIVE) const
 returns a simple textual representation of the time_stamp. More...
 
virtual bool less_than (const basis::orderable &that) const
 
virtual bool equal_to (const basis::equalizable &that) const
 
- Public Member Functions inherited from basis::orderable
virtual bool operator< (const orderable &s2) const
 the virtual method for object ordering. More...
 
- Public Member Functions inherited from basis::equalizable
virtual bool operator== (const equalizable &s2) const
 the virtual method for object equality. More...
 

Static Public Member Functions

static double rolling_uptime ()
 give the OS uptime in a more durable form that handles rollovers. More...
 
static basis::astring notarize (bool add_space=true)
 a useful method for getting a textual version of the time "right now". More...
 
static void fill_timeval_ms (timeval &time_point, int milliseconds)
 returns a timeval system object that represents the "milliseconds". More...
 

Detailed Description

Represents a point in time relative to the operating system startup time.

This duration is measured in milliseconds. This class provides a handy way of measuring relative durations at the millisecond time scale. Unfortunately, operating systems that reckon their millisecond uptime in 32 bit integers will suffer from a rollover problem every 49 days or so, but this class corrects this issue.

Definition at line 37 of file time_stamp.h.

Member Typedef Documentation

◆ time_representation

the representation of time for this universe, measured in milliseconds.

Definition at line 42 of file time_stamp.h.

Member Enumeration Documentation

◆ stamp_display_style

Enumerator
STAMP_RELATIVE 
STAMP_ABSOLUTE 

Definition at line 64 of file time_stamp.h.

Constructor & Destructor Documentation

◆ time_stamp() [1/2]

timely::time_stamp::time_stamp ( )

creates a time_stamp containing the current time.

Definition at line 54 of file time_stamp.cpp.

◆ time_stamp() [2/2]

timely::time_stamp::time_stamp ( time_representation  offset)

creates a stamp after the current time by "offset" milliseconds.

negative offsets are allowed, in which case the stamp will be prior to the current time.

Definition at line 56 of file time_stamp.cpp.

References reset().

Member Function Documentation

◆ DEFINE_CLASS_NAME()

timely::time_stamp::DEFINE_CLASS_NAME ( "time_stamp"  )

◆ equal_to()

virtual bool timely::time_stamp::equal_to ( const basis::equalizable that) const
inlinevirtual

Implements basis::equalizable.

Definition at line 87 of file time_stamp.h.

◆ fill_timeval_ms()

void timely::time_stamp::fill_timeval_ms ( timeval &  time_point,
int  milliseconds 
)
static

returns a timeval system object that represents the "milliseconds".

if "milliseconds" is zero, then the returned timeval will represent zero time passing (rather than infinite duration as some functions assume).

Definition at line 141 of file time_stamp.cpp.

References FUNCDEF, and LOG.

◆ less_than()

virtual bool timely::time_stamp::less_than ( const basis::orderable that) const
inlinevirtual

Implements basis::orderable.

Definition at line 81 of file time_stamp.h.

◆ notarize()

basis::astring timely::time_stamp::notarize ( bool  add_space = true)
static

a useful method for getting a textual version of the time "right now".

this was formerly known as a very useful method called 'utility::timestamp'. that naming was fairly abusive to keep straight from the time_stamp class, so the functionality has been absorbed.

Definition at line 45 of file time_stamp.cpp.

References timely::now(), and timely::time_locus::text_form_long().

◆ reset() [1/2]

◆ reset() [2/2]

void timely::time_stamp::reset ( time_representation  offset)

sets the stamp forward by "offset" similar to the second constructor.

Definition at line 109 of file time_stamp.cpp.

◆ rolling_uptime()

double timely::time_stamp::rolling_uptime ( )
static

give the OS uptime in a more durable form that handles rollovers.

Definition at line 121 of file time_stamp.cpp.

References timely::__rollover_point.

◆ text_form()

astring timely::time_stamp::text_form ( stamp_display_style  style = STAMP_RELATIVE) const

returns a simple textual representation of the time_stamp.

if the "style" is ABSOLUTE, then the stamp is shown in H:M:S.ms form based on the system uptime. if the "style" is RELATIVE, then the stamp is shown as an offset from now.

Definition at line 61 of file time_stamp.cpp.

References basis::absolute_value(), basis::negative(), basis::SECOND_ms, and STAMP_RELATIVE.

Referenced by processes::heartbeat::text_form().

◆ value()


The documentation for this class was generated from the following files: