Main Page   Modules   Class Hierarchy   Data Structures   File List   Data Fields   Globals  

NTPTime Class Reference
[OSCL Base]

The NTPTime class represents a time value as the number of seconds since 0h (UTC) Jan. 1, 1900. More...

#include <oscl_time.h>


Public Methods

OSCL_COND_IMPORT_REF NTPTime ()
 The default constructor creates an NTPTime instance representing the current system time.

OSCL_COND_IMPORT_REF NTPTime (const NTPTime &src)
 Copy constructor to create a new NTPTime from an existing one.

OSCL_COND_IMPORT_REF NTPTime (const uint32 seconds)
 Construct an NTPTime from a uint32.

OSCL_COND_IMPORT_REF NTPTime (const int32 seconds)
 Construct an NTPTime from a int.

OSCL_COND_IMPORT_REF NTPTime (const TimeValue &t)
 Construct a NTPTime instance from a TimeValue instance.

OSCL_COND_IMPORT_REF NTPTime (const uint64 value)
 Construct a NTPTime instance from a uint64 value.

OSCL_COND_IMPORT_REF NTPTime & operator= (uint32 newval)
 The assignment operator for a 32 bit integer.

OSCL_COND_IMPORT_REF NTPTime & operator= (uint64 newval)
 The assignment operator for a 64 bit integer.

OSCL_COND_IMPORT_REF NTPTime & operator+= (uint64 val)
 The += operator is used to add a 64 bit 32.32 value to an existing NTPTime value.

OSCL_COND_IMPORT_REF NTPTime operator- (const NTPTime &ntpt) const
 The - operator allows subtraction of one NTPTime value from another. This is useful to measure an interval.

void set_from_system_time (const uint32 systemtime)
 This method converts a 32-bit system time to NTP time.

OSCL_COND_IMPORT_REF uint32 get_middle32 () const
 Grab the middle 32 bits of the 64 bit 32.32 representation.

OSCL_COND_IMPORT_REF uint32 get_upper32 () const
 This method returns the upper 32 bits of the 32.32 representation.

OSCL_COND_IMPORT_REF uint32 get_lower32 () const
 This method returns the lower 32 bits of the 32.32 representation.

int32 to_system_time () const
 This method converts the ntp time value to system time.

OSCL_COND_IMPORT_REF uint64 get_value () const
 This method returns the 32.32 ntp representation.

OSCL_IMPORT_REF int set_to_current_time ()
 This method sets the 32.32 representation to the current system time value.


Detailed Description

The NTPTime class represents a time value as the number of seconds since 0h (UTC) Jan. 1, 1900.

The NTPTime class: Conversion to/from Unix (epoch at 0h Jan. 1, 1970) amount to addition/subtraction of 2208988800. A single 64 bit value is used to represent the time. This value represents the number of seconds since 0h (UTC) Jan. 1, 1900. There is an implied binary point betweeen the upper 32 bits and lower 32 bits (this is referred to as a 32.32 fractional representation). For example a binary value of 00000000 00000000 00000000 00000011 10000000 00000000 00000000 00000000 represents 3.5 seconds since Jan 1, 1900.


Constructor & Destructor Documentation

OSCL_COND_IMPORT_REF NTPTime::NTPTime  
 

The default constructor creates an NTPTime instance representing the current system time.

OSCL_COND_IMPORT_REF NTPTime::NTPTime const NTPTime &    src
 

Copy constructor to create a new NTPTime from an existing one.

OSCL_COND_IMPORT_REF NTPTime::NTPTime const uint32    seconds
 

Construct an NTPTime from a uint32.

Parameters:
seconds  The uint32 input represents the number of seconds since Jan. 1, 1900.

OSCL_COND_IMPORT_REF NTPTime::NTPTime const int32    seconds
 

Construct an NTPTime from a int.

Parameters:
seconds  The int input represents the number of seconds since Jan. 1, 1900.

OSCL_COND_IMPORT_REF NTPTime::NTPTime const TimeValue   t
 

Construct a NTPTime instance from a TimeValue instance.

This constructor creates an NTPTime value representing the same absolute time as the TimeValue parameter.

Parameters:
t  A reference to a TimeValue object.

OSCL_COND_IMPORT_REF NTPTime::NTPTime const uint64    value
 

Construct a NTPTime instance from a uint64 value.

Parameters:
value  A 64 bit integer argument which is used as the ntp 32.32 fractional representation.


Member Function Documentation

OSCL_COND_IMPORT_REF uint32 NTPTime::get_lower32  
 

This method returns the lower 32 bits of the 32.32 representation.

OSCL_COND_IMPORT_REF uint32 NTPTime::get_middle32  
 

Grab the middle 32 bits of the 64 bit 32.32 representation.

OSCL_COND_IMPORT_REF uint32 NTPTime::get_upper32  
 

This method returns the upper 32 bits of the 32.32 representation.

OSCL_COND_IMPORT_REF uint64 NTPTime::get_value  
 

This method returns the 32.32 ntp representation.

OSCL_COND_IMPORT_REF NTPTime& NTPTime::operator+= uint64    val
 

The += operator is used to add a 64 bit 32.32 value to an existing NTPTime value.

Parameters:
val  The 64 bit 32.32 value to add to this object's value.

OSCL_COND_IMPORT_REF NTPTime NTPTime::operator- const NTPTime &    ntpt const
 

The - operator allows subtraction of one NTPTime value from another. This is useful to measure an interval.

Parameters:
ntpt  A reference to the NTPTime object to be subracted from this one.

OSCL_COND_IMPORT_REF NTPTime& NTPTime::operator= uint64    newval
 

The assignment operator for a 64 bit integer.

Parameters:
newval  A 64 bit value which represents the 32.32 fractional representation of the ntp time.

OSCL_COND_IMPORT_REF NTPTime& NTPTime::operator= uint32    newval
 

The assignment operator for a 32 bit integer.

Parameters:
newval  A 32 bit integer representing the upper 32 bits of the 32.32 NTP time (e.g. the number of whole seconds since Jan 1, 1900 UTC).

void NTPTime::set_from_system_time const uint32    systemtime
 

This method converts a 32-bit system time to NTP time.

This method sets the value of the NTPTime instance to the absolute time represented by the 32 bit input argument.

Parameters:
systemtime  This 32-bit value is interpreted as the number of seconds since the unix epoch Jan. 1 1970.

OSCL_IMPORT_REF int NTPTime::set_to_current_time  
 

This method sets the 32.32 representation to the current system time value.

int32 NTPTime::to_system_time  
 

This method converts the ntp time value to system time.

This method returns a 32 bit value representing the same absolute time as the NTP time value, but expressed as whole seconds since the unix epoch. The fractional part of the ntp value is discarded.


The documentation for this class was generated from the following file:
OSCL API
Posting Version: OPENCORE_20090310