WOscTimeTag Class Reference

#include <WOscTimeTag.h>

Inherited by WOscBundle, and WOscQueueItem.

List of all members.

Public Types

enum  Constants { TIME_TAG_SIZE = 8 }

Public Member Functions

 WOscTimeTag ()
 WOscTimeTag (const char *rawTimeTag)
 WOscTimeTag (const WOscTimeTag &rhs)
void SetToCurrentTime (const WOscSystemTime *systemTime=NULL)
void SetToImmediateTime ()
void SetToLargestTimeTag ()
void SetToSmallestTimeTag ()
WOscTimeTag operator+ (const WOscTimeTag &rhs) const
WOscTimeTag operator+= (const WOscTimeTag &rhs)
WOscTimeTag operator= (const WOscTimeTag &rhs)
WOscTimeTag operator- (const WOscTimeTag &rhs) const
WOscTimeTag operator-= (const WOscTimeTag &rhs)
bool operator< (const WOscTimeTag &rhs) const
bool operator<= (const WOscTimeTag &rhs) const
bool operator== (const WOscTimeTag &rhs) const
bool operator!= (const WOscTimeTag &rhs) const
bool operator> (const WOscTimeTag &rhs) const
bool operator>= (const WOscTimeTag &rhs) const
const char * ToCharArray () const
void WriteToCharArray (char *buffer) const
void InitFromCharArray (const char *buffer)
uint64_t GetRawTimeTag () const

Static Public Member Functions

static WOscTimeTag GetCurrentTime (const WOscSystemTime *systemTime=NULL)
static WOscTimeTag GetImmediateTime ()
static WOscTimeTag GetLargestTimeTag ()
static WOscTimeTag GetSmallestTimeTag ()

Friends

class WOscSystemTime

Detailed Description

Definition of time in an OSC system. The OSC-specification ( OSC specifications ) states: Time tags are represented by a 64 bit fixed point number. The first 32 bits specify the number of seconds since midnight on January 1, 1900, and the last 32 bits specify fractional parts of a second to a precision of about 200 picoseconds. This is the rep- resentation used by Internet NTP timestamps. The time tag value consisting of 63 zero bits followed by a one in the least signifigant bit is a special case meaning "immediately."

Remarks:
This is one of the platform (compiler/processor/operating-system) dependent parts of the library. WOscTimeTag is affected regarding the number- representation (32/64 datatypes supported) and the endianness (big- endian or little-endian). Both can be switched by preprocessor-defines.
See also:
WOscSystemTime
Examples:

WOscClient.cpp, and WOscServer.cpp.

Definition at line 87 of file WOscTimeTag.h.


Member Enumeration Documentation

Time-tag related constants.

Remarks:
Use TIME_TAG_SIZE when referring to char-buffers related with the WOscTimeTag.
Enumerator:
TIME_TAG_SIZE 

buffer size for char-arrayed timetags.

Reimplemented in WOscBundle.

Definition at line 126 of file WOscTimeTag.h.

00127     {
00128         TIME_TAG_SIZE = 8, /**< buffer size for char-arrayed timetags.*/
00129     };


Constructor & Destructor Documentation

WOscTimeTag::WOscTimeTag (  ) 

Constructor Initializes the time-tag to immediate time.

Definition at line 96 of file WOscTimeTag.cpp.

00097 {
00098     m_timeTag = 1;
00099 }

WOscTimeTag::WOscTimeTag ( const char *  rawTimeTag  ) 

Construct an OSC-time tag from a raw OSC (network) byte- stream (buffer). The OSC (network) buffer has to be big-endian

Parameters:
rawTimeTag Buffer containing the raw time-tag
Remarks:
The argument buffer has to have a minimum length of WOscTimeTag::Constants::TIME_TAG_SIZE. Smaller lengths may produce runtime errors.

Definition at line 113 of file WOscTimeTag.cpp.

References InitFromCharArray().

00114 {
00115     InitFromCharArray(rawTimeTag);
00116 }

WOscTimeTag::WOscTimeTag ( const WOscTimeTag rhs  ) 

Copy constructor. Initializes the current time-tag with the data from the referenced.

Parameters:
rhs Reference of time-tag to be copied.

Definition at line 124 of file WOscTimeTag.cpp.

00125 {
00126     m_timeTag = rhs.m_timeTag;
00127 }


Member Function Documentation

WOscTimeTag WOscTimeTag::GetCurrentTime ( const WOscSystemTime systemTime = NULL  )  [static]

Returns the current system time. A optional system-time object can be passed, which implements the system specific system-time-query.

Parameters:
systemTime Pointer to system time object (optional). If not specified, The system time gets initialized with the library default system time.
Returns:
Time-tag representing the current system time.

Definition at line 141 of file WOscTimeTag.cpp.

References WOscSystemTime::GetSystemTime().

Referenced by WOscReceiver::ManagePriorityQueue().

00141                                                                                    {
00142     if ( systemTime == NULL ){
00143         /* get library default */
00144         WOscSystemTime time;
00145         return time.GetSystemTime();
00146     }else
00147         return systemTime->GetSystemTime();
00148 }

WOscTimeTag WOscTimeTag::GetImmediateTime (  )  [static]

Returns the "immediate" time-tag. Immediate implies the LSB set to one.

Returns:
Immediate time-tag.

Definition at line 157 of file WOscTimeTag.cpp.

Referenced by GetSmallestTimeTag(), WOscBundleParser::GetTimeTag(), and SetToImmediateTime().

00158 {
00159     WOscTimeTag retTag;
00160     retTag.m_timeTag = 1;
00161     return retTag;
00162 }

WOscTimeTag WOscTimeTag::GetLargestTimeTag (  )  [static]

Returns the largest possible time-tag. I.e. all bits set to one.

Returns:
Largest possible time-tag.

Definition at line 171 of file WOscTimeTag.cpp.

Referenced by WOscPriorityQueue::GetEarliestTimeTag(), WOscSystemTime::GetSystemTime(), and SetToLargestTimeTag().

00172 {
00173     WOscTimeTag retTag;
00174     retTag.m_timeTag = ULONG_LONG_MAX;
00175     return retTag;
00176 }

WOscTimeTag WOscTimeTag::GetSmallestTimeTag (  )  [static]

Returns the "immediate" time-tag. Immediate implies the LSB set to one.

Returns:
Immediate time-tag.

Definition at line 185 of file WOscTimeTag.cpp.

References GetImmediateTime().

Referenced by SetToSmallestTimeTag().

00186 {
00187     return GetImmediateTime();
00188 }

void WOscTimeTag::InitFromCharArray ( const char *  buffer  ) 

Initializes an OSC time tag from a byte stream (big endian ordered). The byte stream buffer has to have a minimum length of TIME_TAG_SIZE.

Parameters:
buffer Pointer to buffer with initialization data.
Remarks:
The byte stream buffer has to have a minimum length of TIME_TAG_SIZE.

Definition at line 479 of file WOscTimeTag.cpp.

Referenced by WOscTimeTag().

00480 {
00481     m_timeTag = WOscUtil::BufferTo<uint64_t>(buffer);
00482 }

bool WOscTimeTag::operator!= ( const WOscTimeTag rhs  )  const

Is not equal operator. Returns true if the right time-tag is different from the left.

Parameters:
rhs Right-hand side.
Returns:
True if the right time-tag is different from the left. False else.

Definition at line 391 of file WOscTimeTag.cpp.

00392 {
00393     return (m_timeTag != rhs.m_timeTag);
00394 }

WOscTimeTag WOscTimeTag::operator+ ( const WOscTimeTag rhs  )  const

Add operator. Adds the right-hand time-tag to the left-hand time-tag and returns the result without modifying the left-hand time-tag.

Parameters:
rhs Right-hand time-tag reference to be added to the left one.
Returns:
Left-hand time-tag plus right-hand time-tag.

Definition at line 252 of file WOscTimeTag.cpp.

00253 {
00254     WOscTimeTag retTag;
00255     retTag.m_timeTag = m_timeTag + rhs.m_timeTag;
00256     return retTag;
00257 }

WOscTimeTag WOscTimeTag::operator+= ( const WOscTimeTag rhs  ) 

Add and assign operator. Adds the right-hand time-tag to the left-hand time-tag, stores the result in the left-hand time-tag and returns the result.

Parameters:
rhs Right-hand time-tag reference to be added to the left one.
Returns:
Left-hand time-tag plus right-hand time-tag.

Definition at line 288 of file WOscTimeTag.cpp.

00289 {
00290     m_timeTag =+ rhs.m_timeTag;
00291     return *this;
00292 }

WOscTimeTag WOscTimeTag::operator- ( const WOscTimeTag rhs  )  const

Subtract operator. Subtracts the right-hand time-tag from the left-hand time-tag and returns the result without modifying the left-hand time-tag.

Parameters:
rhs Right-hand time-tag reference to be subtracted from the left one.
Returns:
Left-hand time-tag minus right-hand time-tag.

Definition at line 305 of file WOscTimeTag.cpp.

00306 {
00307     WOscTimeTag retTag;
00308     retTag.m_timeTag = m_timeTag - rhs.m_timeTag;
00309     return retTag;
00310 }

WOscTimeTag WOscTimeTag::operator-= ( const WOscTimeTag rhs  ) 

Subtract and assign operator. Subtracts the right-hand time-tag from the left-hand time-tag, stores the result in the left-hand time-tag and returns the result.

Parameters:
rhs Right-hand time-tag reference to be subtracted from the left one.
Returns:
Left-hand time-tag minus right-hand time-tag.

Definition at line 324 of file WOscTimeTag.cpp.

00325 {
00326     m_timeTag -= rhs.m_timeTag;
00327     return *this;
00328 }

bool WOscTimeTag::operator< ( const WOscTimeTag rhs  )  const

Smaller or equal comparison operator. Returns true if the left time-tag is smaller (older) than the right.

Parameters:
rhs Right-hand side.
Returns:
True if the left time-tag is smaller (older) than the right. False else.

Definition at line 342 of file WOscTimeTag.cpp.

00343 {
00344     return (m_timeTag < rhs.m_timeTag);
00345 }

bool WOscTimeTag::operator<= ( const WOscTimeTag rhs  )  const

Smaller or equal comparison operator. Returns true if the left time-tag is smaller (older) or equal (same time) than the right.

Parameters:
rhs Right-hand side.
Returns:
True if the left time-tag is smaller (older) or equal (same time) than the right. False else.

Definition at line 359 of file WOscTimeTag.cpp.

00360 {
00361     return (m_timeTag <= rhs.m_timeTag);
00362 }

WOscTimeTag WOscTimeTag::operator= ( const WOscTimeTag rhs  ) 

Assignment operator. Assigns the right-hand time-tag to the left-hand time-tag and returns it.

Parameters:
rhs Right-hand time-tag reference to be assigned to the left one.
Returns:
Left-hand time-tag value which equals now the right-hand time-tag.

Definition at line 270 of file WOscTimeTag.cpp.

00271 {
00272     m_timeTag = rhs.m_timeTag;
00273     return *this;
00274 }

bool WOscTimeTag::operator== ( const WOscTimeTag rhs  )  const

Is equal operator. Returns true if the right time-tag is equal to the left.

Parameters:
rhs Right-hand side.
Returns:
True if the right time-tag is equal to the left. False else.

Definition at line 375 of file WOscTimeTag.cpp.

00376 {
00377     return (m_timeTag == rhs.m_timeTag);
00378 }

bool WOscTimeTag::operator> ( const WOscTimeTag rhs  )  const

Bigger comparison operator. Returns true if the right time-tag is smaller (older) than the left.

Parameters:
rhs Right-hand side.
Returns:
True if the right time-tag is smaller (older) than the left. False else.

Definition at line 408 of file WOscTimeTag.cpp.

00409 {
00410     return (m_timeTag > rhs.m_timeTag);
00411 }

bool WOscTimeTag::operator>= ( const WOscTimeTag rhs  )  const

Bigger or equal comparison operator. Returns true if the right time-tag is smaller (older) or equal (same time) than the left.

Parameters:
rhs Right-hand side.
Returns:
True if the right time-tag is smaller (older) or equal (same time) than the left. False else.

Definition at line 425 of file WOscTimeTag.cpp.

00426 {
00427     return (m_timeTag >= rhs.m_timeTag);
00428 }

void WOscTimeTag::SetToCurrentTime ( const WOscSystemTime systemTime = NULL  ) 

Sets this time-tag to the current system time. A optional system-time object can be passed, which implements the system specific system-time-query.

Parameters:
systemTime Pointer to system time object (optional). If not specified, The system time gets initialized with the library default system time.
See also:
WOscTimeTag::getCurrentTime(const WOscSystemTime* systemTime)

Definition at line 203 of file WOscTimeTag.cpp.

References WOscSystemTime::GetSystemTime().

00204 {
00205     *this = systemTime->GetSystemTime();
00206 }

void WOscTimeTag::SetToImmediateTime (  ) 

Sets this time tag to immediate time.

See also:
WOscTimeTag::getImmediateTime()

Definition at line 214 of file WOscTimeTag.cpp.

References GetImmediateTime().

00215 {
00216     *this = GetImmediateTime();
00217 }

void WOscTimeTag::SetToLargestTimeTag (  ) 

Sets this time tag to the biggest time-tag possible.

See also:
WOscTimeTag::getLargestTimeTag()

Definition at line 225 of file WOscTimeTag.cpp.

References GetLargestTimeTag().

00226 {
00227     *this = GetLargestTimeTag();
00228 }

void WOscTimeTag::SetToSmallestTimeTag (  ) 

Sets this time tag to the smallest time-tag possible.

See also:
WOscTimeTag::getSmallestTimeTag()

Definition at line 236 of file WOscTimeTag.cpp.

References GetSmallestTimeTag().

00237 {
00238     *this = GetSmallestTimeTag();
00239 }

const char * WOscTimeTag::ToCharArray (  )  const

Returns a new char array of size TIME_TAG_SIZE filled with the network aligned (big endian) timetag.

The caller has to free the allocated memory.

Returns:
The allocated char array filled with the network aligned (big endian) timetag.
Remarks:
The caller has to free the allocated memory.

Definition at line 444 of file WOscTimeTag.cpp.

00445 {
00446     char* buffer = new char[sizeof(uint64_t)];
00447     WOscUtil::FillBufferWith(buffer, m_timeTag);
00448     return buffer;
00449 }

void WOscTimeTag::WriteToCharArray ( char *  buffer  )  const

Fill the given buffer with the network char array representation of an OSC time tag.

Parameters:
buffer Caller supplied buffer with a minimum size of TIME_TAG_SIZE.
Remarks:
The byte stream buffer has to have a minimum length of TIME_TAG_SIZE.

Definition at line 461 of file WOscTimeTag.cpp.

00462 {
00463     WOscUtil::FillBufferWith(buffer, m_timeTag);
00464 }


The documentation for this class was generated from the following files:
Generated on Sat Oct 23 03:05:59 2010 for WOscLib by  doxygen 1.6.3