<< Back to man.ChinaUnix.net

11.              TimeTicks Class

Object Modeling Technique (OMT) view of the SNMP++ TimeTicks Class


11.1.   The TimeTicks Class

The SNMP++ TimeTicks provides benefits where SMI timeticks are needed. SMI timeticks are defined with the storage capabilities of an unsigned long integer. In addition to being an unsigned long int, SMI timeticks are treated as a distinct type. For this reason, the SNMP++ TimeTicks class has all the functionality and behavior of an unsigned long int, but is a separate class. Anything that can be done with an unsigned long integer can be done with a TimeTicks object. The TimeTicks class has additional behavior when interfacing with other SNMP++ classes like the Vb class. When used with the Vb class, TimeTicks objects can be set into ( Vb::set) and gotten out of ( Vb::get) of Vb objects. This allows the developer to get all the functionality of unsigned long and provide a one-to-one mapping to SMI timeticks.

11.2.  Overview of TimeTicks Class Member Functions

TimeTicks Class Member Functions

Description

Constructors

 

     TimeTicks::TimeTicks( void);

Constructs an empty TimeTicks object.

     TimeTicks::TimeTicks( const unsigned long i );

Construct a TimeTicks object using an unsigned long.

     TimeTicks:;TimeTicks(  const TimeTicks &t);

Construct a TimeTicks object using another TimeTicks object.

Destructor

 

     TimeTicks::~TimeTicks( );

Destroy a TimeTicks object.

Overloaded Operators

 

      TimeTicks& operator =( const TimeTicks &t);

Overloaded assignment operator.

      char * get_printable();

Formats for output, in the form DD Days, HH:MM:SS.hh

      operator unsigned long();

Gives unsigned long behavior to TimeTicks

11.3.  Special Features

When printing out a TimeTicks object using TimeTicks::get_printable(), the value is formatted automatically to a “DD days, HH:MM:SS.hh” format where DD are the number of days, HH are the number of hours ( 24 hour clock), MM are the minutes, SS are the seconds and hh are the hundredths of a second. 

11.4.   Some TimeTicks Class Examples

// TimeTicks Examples

#include timetick.h

void timeticks_example()

{

    TimeTicks tt;                                     // create an un-initialized timeticks instance

    TimeTicks tt1( (unsigned long) 57);         // create a timeticks using a number

    TimeTicks tt2( tt1);                               // create a timeticks using another instance

 

    tt = 192;                                                  // overloaded assignment to a number

    tt2 = tt;                                                   // overloaded assignment to another timeticks

 

    cout << tt.get_printable();               // print out in DD days, HH:MM:SS.hh

    cout << ( unsigned long) tt;               // print out unsigned long int value

 

     

};  // end timeticks example