Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Friends

CxUtils::Time Class Reference

A simple time structure. All time values are UTC. More...

#include <time.h>

List of all members.

Classes

class  Synchronizer
 A Time Synchronizer acts as either a timer server or a time client. More...

Public Types

typedef unsigned long long int Stamp
 Typedef to store Time Stamp.
typedef std::vector< TimeList
 Typedef for a list of Time Stamp.

Public Member Functions

 Time (const bool setCurrentTime=false)
 Constructor.
 Time (const Time &time)
 Copy constructor.
 Time (const double seconds)
virtual ~Time ()
 Destructor.
void SetCurrentTime ()
 Sets the current UTC time using CxUtils::GetSystemTime method.
void SetLocalTime ()
 Sets the current local time.
void Clear ()
Stamp ToMs () const
 Converts the time data to a value in milliseconds.
double ToSeconds () const
 Converts the time data to a value in seconds.
std::string ToString () const
 Converts time to a string format.
TimeFromString (const std::string &str)
 Reads time data from a formatted string.
Timeoperator= (const Time &time)
 Sets equal to.
Timeoperator= (const double &seconds)
Time Add (const Time &time) const
Time Subtract (const Time &time) const
bool operator== (const Time &time) const
bool operator== (const double seconds) const
bool operator== (const Stamp milliseconds) const
bool operator!= (const Time &time) const
bool operator!= (const double seconds) const
bool operator!= (const Stamp milliseconds) const
bool operator< (const Time &time) const
bool operator<= (const Time &time) const
bool operator> (const Time &time) const
bool operator>= (const Time &time) const
double operator- (const Time &time) const

Static Public Member Functions

static double DifferenceInSeconds (const Time &a, const Time &b)
static double DifferenceInMs (const Time &a, const Time &b)
static Time GetUtcTime ()
static Time GetLocalTime ()
static Stamp GetUtcTimeMs ()
static Stamp GetLocalTimeMs ()
static Time Add (const Time &t1, const Time &t2)
static Time Subtract (const Time &t1, const Time &t2)
static bool HaveExternalTime ()
static Time GetExternalTime ()

Public Attributes

volatile unsigned int mDay
 Day of the month.
volatile unsigned int mHour
 Hour of the day [0,11].
volatile unsigned int mMinute
 Minute [0,59].
volatile unsigned int mSecond
 Second [0,59].
volatile unsigned int mMilliseconds
 Milliseconds [0,999].

Friends

class Synchronizer

Detailed Description

A simple time structure. All time values are UTC.

Definition at line 60 of file time.h.


Member Typedef Documentation

typedef std::vector<Time> CxUtils::Time::List

Typedef for a list of Time Stamp.

Definition at line 65 of file time.h.

typedef unsigned long long int CxUtils::Time::Stamp

Typedef to store Time Stamp.

Definition at line 64 of file time.h.


Constructor & Destructor Documentation

Time::Time ( const bool  setCurrentTime = false )

Constructor.

Parameters:
setCurrentTimeIf true, initialized with current UTM time.

Definition at line 290 of file time.cpp.

Time::Time ( const Time time )

Copy constructor.

Definition at line 310 of file time.cpp.

CxUtils::Time::Time ( const double  seconds ) [inline]

Definition at line 68 of file time.h.

Time::~Time (  ) [virtual]

Destructor.

Definition at line 325 of file time.cpp.


Member Function Documentation

Time Time::Add ( const Time t1,
const Time t2 
) [static]
Returns:
The result of t1 + t2 in a Time object.

Definition at line 554 of file time.cpp.

Time CxUtils::Time::Add ( const Time time ) const [inline]

Definition at line 118 of file time.h.

void CxUtils::Time::Clear (  ) [inline]

Definition at line 75 of file time.h.

static double CxUtils::Time::DifferenceInMs ( const Time a,
const Time b 
) [inline, static]

Definition at line 82 of file time.h.

static double CxUtils::Time::DifferenceInSeconds ( const Time a,
const Time b 
) [inline, static]

Definition at line 81 of file time.h.

Time & Time::FromString ( const std::string &  str )

Reads time data from a formatted string.

Definition at line 449 of file time.cpp.

Time Time::GetExternalTime (  ) [static]
Returns:
The time data from any external time source (if available).

Definition at line 603 of file time.cpp.

static Time CxUtils::Time::GetLocalTime (  ) [inline, static]

Definition at line 89 of file time.h.

Time::Stamp Time::GetLocalTimeMs (  ) [static]
Returns:
The current local time in milliseconds.

Definition at line 421 of file time.cpp.

static Time CxUtils::Time::GetUtcTime (  ) [inline, static]

Definition at line 83 of file time.h.

Time::Stamp Time::GetUtcTimeMs (  ) [static]
Returns:
The current UTC time in milliseconds.

Definition at line 410 of file time.cpp.

static bool CxUtils::Time::HaveExternalTime (  ) [inline, static]

Definition at line 168 of file time.h.

bool CxUtils::Time::operator!= ( const Time time ) const [inline]

Definition at line 140 of file time.h.

bool CxUtils::Time::operator!= ( const double  seconds ) const [inline]

Definition at line 152 of file time.h.

bool CxUtils::Time::operator!= ( const Stamp  milliseconds ) const [inline]

Definition at line 156 of file time.h.

double CxUtils::Time::operator- ( const Time time ) const [inline]
Returns:
Difference in time in seconds.

Definition at line 167 of file time.h.

bool CxUtils::Time::operator< ( const Time time ) const [inline]

Definition at line 160 of file time.h.

bool CxUtils::Time::operator<= ( const Time time ) const [inline]

Definition at line 161 of file time.h.

Time & Time::operator= ( const Time time )

Sets equal to.

Definition at line 537 of file time.cpp.

Time& CxUtils::Time::operator= ( const double &  seconds ) [inline]

Definition at line 101 of file time.h.

bool CxUtils::Time::operator== ( const Time time ) const [inline]

Definition at line 120 of file time.h.

bool CxUtils::Time::operator== ( const double  seconds ) const [inline]

Definition at line 132 of file time.h.

bool CxUtils::Time::operator== ( const Stamp  milliseconds ) const [inline]

Definition at line 136 of file time.h.

bool CxUtils::Time::operator> ( const Time time ) const [inline]

Definition at line 162 of file time.h.

bool CxUtils::Time::operator>= ( const Time time ) const [inline]

Definition at line 163 of file time.h.

void Time::SetCurrentTime (  )

Sets the current UTC time using CxUtils::GetSystemTime method.

Definition at line 335 of file time.cpp.

void Time::SetLocalTime (  )

Sets the current local time.

Definition at line 350 of file time.cpp.

Time Time::Subtract ( const Time t1,
const Time t2 
) [static]
Returns:
The result of t1 - t2 in a Time object.

Definition at line 591 of file time.cpp.

Time CxUtils::Time::Subtract ( const Time time ) const [inline]

Definition at line 119 of file time.h.

Time::Stamp Time::ToMs (  ) const

Converts the time data to a value in milliseconds.

Definition at line 380 of file time.cpp.

double Time::ToSeconds (  ) const

Converts the time data to a value in seconds.

Definition at line 395 of file time.cpp.

std::string Time::ToString (  ) const

Converts time to a string format.

Definition at line 434 of file time.cpp.


Friends And Related Function Documentation

friend class Synchronizer [friend]

Definition at line 62 of file time.h.


Member Data Documentation

volatile unsigned int CxUtils::Time::mDay

Day of the month.

Definition at line 170 of file time.h.

volatile unsigned int CxUtils::Time::mHour

Hour of the day [0,11].

Definition at line 171 of file time.h.

volatile unsigned int CxUtils::Time::mMilliseconds

Milliseconds [0,999].

Definition at line 174 of file time.h.

volatile unsigned int CxUtils::Time::mMinute

Minute [0,59].

Definition at line 172 of file time.h.

volatile unsigned int CxUtils::Time::mSecond

Second [0,59].

Definition at line 173 of file time.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines