net.ctdp.rfdynhud.valuemanagers
Class Clock

java.lang.Object
  extended by net.ctdp.rfdynhud.valuemanagers.Clock
All Implemented Interfaces:
ManagedValue
Direct Known Subclasses:
TimeBasedClock

public abstract class Clock
extends java.lang.Object
implements ManagedValue

A Clock sets the c() member to true in implementation specific intervals

Author:
Marvin Froehlich (CTDP)

Field Summary
static long ONE_SECOND_NANOS
           
 
Constructor Summary
protected Clock()
           
 
Method Summary
 boolean c()
          Gets the current clock flag.
 boolean c(int step)
          Gets a 'multiplied' clock flag.
 boolean c2()
          This is a shortcut for c(int) with a step value of 2.
 boolean c3()
          This is a shortcut for c(int) with a step value of 3.
 long getTicks()
          Gets the number of true situations since the last call to init(long).
 void init(long nanoTime)
          Initializes/resets the ManagedValue.
protected abstract  void initImpl(long nanoTime)
          Implementation specific code for initialization.
 void update(long nanoTime, long frameCounter, boolean force)
          Invokes the implementation specific update code.
protected abstract  boolean updateImpl(long nanoTime, long frameCounter, boolean force)
          Implementation of the update method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ONE_SECOND_NANOS

public static final long ONE_SECOND_NANOS
See Also:
Constant Field Values
Constructor Detail

Clock

protected Clock()
Method Detail

initImpl

protected abstract void initImpl(long nanoTime)
Implementation specific code for initialization.

Parameters:
nanoTime - the starting time stamp

init

public final void init(long nanoTime)
Initializes/resets the ManagedValue.

Specified by:
init in interface ManagedValue
Parameters:
nanoTime - the starting time stamp

c

public final boolean c()
Gets the current clock flag.

Returns:
true, if the flag is set, false otherwise.

c

public final boolean c(int step)
Gets a 'multiplied' clock flag.

Parameters:
step - the number of clock ticks to wait for the next 'true'
Returns:
true, if the current flag is set, and ( ticks % step ) is 0.

c2

public final boolean c2()
This is a shortcut for c(int) with a step value of 2.

Returns:
true every 2 clock ticks, false otherwise.

c3

public final boolean c3()
This is a shortcut for c(int) with a step value of 3.

Returns:
true every 3 clock ticks, false otherwise.

getTicks

public final long getTicks()
Gets the number of true situations since the last call to init(long).

Returns:
the number of true situations since the last call to init(long).

updateImpl

protected abstract boolean updateImpl(long nanoTime,
                                      long frameCounter,
                                      boolean force)
Implementation of the update method.

Parameters:
nanoTime - the current timestamp in nano seconds
frameCounter - the current frame index
force - force clock to true.
Returns:
true to set the Clock flag to true.

update

public final void update(long nanoTime,
                         long frameCounter,
                         boolean force)
Invokes the implementation specific update code.

Specified by:
update in interface ManagedValue
Parameters:
nanoTime - the current timestamp in nano seconds
frameCounter - the current frame index
force - force clock to true.