Xfce Foundation Classes
Main Page | Index | Namespace List | Alphabetical List | Class List | File List

# Xfc::G::Timer Class Reference

A GTimer C++ wrapper interface. More...

`#include <xfc/glib/timer.hh>`

Inheritance diagram for Xfc::G::Timer:

List of all members.

## Public Member Functions

Constructors

- Timer ()
    Constructs a new timer, and starts timing (that is, start() is implicitly called for you).
- ~Timer ()
    Destructor.

Accessors

- GTimer * g_timer () const
    Get a pointer to the GTimer object.
- operator GTimer * () const
    Conversion operator; Safely converts a G::Timer object into a GTimer pointer.

Methods

- void start ()
    Marks a start time, so that future calls to elapsed() will report the time since start() was called.
- void stop ()
    Marks an end time, so calls to elapsed() will return the difference between this end time and the start time.
- void reset ()
    Reset an already started timer to zero.
- void resume ()
    Resumes a timer that has previously been stopped with stop().
- double elapsed (unsigned long *microseconds=0)
    Obtains the elapsed time.

## Detailed Description

A GTimer C++ wrapper interface.

Timer records a start time, and counts microseconds elapsed since that time. This is done somewhat differently on different platforms, and can be tricky to get exactly right, so Timer provides a portable and convenient interface.

There is not much you can do with a timer. You can construct it, start() it running, stop() it running, and reset() it to zero.

## Member Function Documentation

double Xfc::G::Timer::elapsed | ( | unsigned long * | microseconds = `0` | ) |

Obtains the elapsed time.

Parameters:

  | microseconds | The fractional part of seconds elapsed, in microseconds, or null.

Returns:
  The seconds elapsed as a floating point value, including any fractional part.

If a timer has been started but not stopped this method obtains the time since the timer was started. If timer has been stopped it obtains the elapsed time between the time it was started and the time it was stopped. The return value is the number of seconds elapsed, including any fractional part. If microseconds is non-null, it will be set to the microseconds fraction of the elapsed time. It does not contain the seconds. The microseconds out parameter is not very useful.

void Xfc::G::Timer::reset | ( |  | ) |

| Reset an already started timer to zero. It's fine to call start() on an already-started timer to reset the start time, so reset() serves no real purpose, other than to make the intentions of your code a bit clearer.

void Xfc::G::Timer::resume | ( |  | ) |

| Resumes a timer that has previously been stopped with stop(). Note stop() must be called before using this function.

void Xfc::G::Timer::start | ( |  | ) |

| Marks a start time, so that future calls to elapsed() will report the time since start() was called. When you construct a new timer this method automatically marks the start time, so there is no need to call start() immediately after constructing the timer.

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

- timer.hh

Xfce Foundation Classes

Copyright © 2004-2005 The XFC Development Team | XFC 4.3