# Clock Class Reference

An abstract Clock class. More...

`#include <Clock.hh>`

Inheritance diagram for Clock:

[legend]

List of all members.

## Public Member Functions
| Clock (const std::string newName)
| The Clock default constructor.
const std::string | getName () const
| Get the clock name.
virtual double | getResolution ()=0
| Get the clock resolution in nano-seconds.
virtual uint64_t | getCurrentTicksValue ()=0
| Get the current ticks value.
virtual uint64_t | getDeltaTicks (const uint64_t previousTicks)
| Get the delta between current ticks value and the one provided as argument.
virtual double | tick2NanoSecond (const uint64_t ticks)=0
| Convert a number of ticks into a double value representing nanoseconds.
virtual double | getDeltaNanoSecond (const uint64_t firstTicks, const uint64_t secondTicks)
| Get delta between the provided ticks values in nano-seconds.
virtual double | getDeltaNanoSecond (const uint64_t previousTicks)
| Get delta between current ticks value and the one provided as argument as nano-second value.
virtual | ~Clock ()
## Static Public Member Functions
static Clock * | getBestClock ()
| Retrieve the best possible clock.
## Protected Attributes
std::string | name

## Detailed Description

An abstract Clock class.

Clock abstraction which tries to use high-resolution system clock in order to be able to help user to profile it's application using simple clock API. Derived class will use effective clock API like POSIX clock_xxxx functions: http://www.opengroup.org/onlinepubs/000095399/functions/clock_getres.html or other hardware assisted clock like Pentium TSC.

Definition at line 40 of file Clock.hh.

## Constructor & Destructor Documentation

Clock | ( | const std::string | newName | ) |

The Clock default constructor.

Parameters:

  `[in]` | newName | the clock name

Definition at line 23 of file Clock.cc.

References Clock::name.

~Clock | ( |  | ) | `[virtual]`

Definition at line 43 of file Clock.cc.

## Member Function Documentation

const std::string getName | ( |  | ) | const`[inline]`

Get the clock name.

Returns:
  the clock name

Definition at line 52 of file Clock.hh.

virtual double getResolution | ( |  | ) | `[pure virtual]`

Get the clock resolution in nano-seconds.

Returns:
  the clock resolution in nano-seconds

Implemented in PosixClock, TSCClock, WinClock, and WinPerfClock.

virtual uint64_t getCurrentTicksValue | ( |  | ) | `[pure virtual]`

Get the current ticks value.

Returns:
  the current ticks value

Implemented in PosixClock, TSCClock, WinClock, and WinPerfClock.

Referenced by Clock::getDeltaTicks().

uint64_t getDeltaTicks | ( | const uint64_t | previousTicks | ) | `[virtual]`

Get the delta between current ticks value and the one provided as argument.

Parameters:

  `[in]` | previousTicks | a previous ticks value

Returns:
  the delta tick value

Definition at line 29 of file Clock.cc.

References Clock::getCurrentTicksValue().

Referenced by Clock::getDeltaNanoSecond().

Here is the call graph for this function:

virtual double tick2NanoSecond | ( | const uint64_t | ticks | ) | `[pure virtual]`

Convert a number of ticks into a double value representing nanoseconds.

Parameters:

  `[in]` | ticks | the number of tick to convert

Returns:
  the nano-seconds value

Implemented in PosixClock, TSCClock, WinClock, and WinPerfClock.

Referenced by Clock::getDeltaNanoSecond().

double getDeltaNanoSecond | ( | const uint64_t | firstTicks,
|  | const uint64_t | secondTicks |
| ) |  |  | `[virtual]`

Get delta between the provided ticks values in nano-seconds.

Parameters:

  `[in]` | firstTicks | the first tick value
  `[in]` | secondTicks | the second (later) tick value

Returns:
  the delta time between the two ticks value in nano-seconds.

Definition at line 33 of file Clock.cc.

References Clock::tick2NanoSecond().

Here is the call graph for this function:

double getDeltaNanoSecond | ( | const uint64_t | previousTicks | ) | `[virtual]`

Get delta between current ticks value and the one provided as argument as nano-second value.

Parameters:

  `[in]` | previousTicks |

Definition at line 38 of file Clock.cc.

References Clock::getDeltaTicks(), and Clock::tick2NanoSecond().

Here is the call graph for this function:

Clock * getBestClock | ( |  | ) | `[static]`

Retrieve the best possible clock.

Returns:
  the obtained clock

Definition at line 37 of file ClockFactory.cc.

## Member Data Documentation

std::string name`[protected]`

Definition at line 100 of file Clock.hh.

Referenced by Clock::Clock().

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

- Clock.hh
- Clock.cc
- ClockFactory.cc