AppEasy Core SDK  1.5.0
Cross platform mobile and desktop app and game development SDK - The easy way to make apps
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines
CzXomlTimer Class Reference

Polled timer. More...

#include <CzTimer.h>

Inheritance diagram for CzXomlTimer:
IzXomlResource

List of all members.

Public Member Functions

void setCurrentTime (float time)
float getCurrentTime () const
void setDuration (float duration)
float getDuration () const
void setRepeatCount (int count)
int getRepeatCount () const
void setAutoDelete (bool auto_delete)
bool isAutoDelete () const
void start ()
void stop ()
void restart ()
bool isRunning () const
CzEventManagergetEventsManager ()
 CzXomlTimer ()
virtual ~CzXomlTimer ()
bool Update (float dt)
 Updates the timer.
void ProcessEventActions (unsigned int event_name)
 Process the event actions described by event_name.
void NotifyTimeout ()
void NotifyRepeat ()
int LoadFromXoml (IzXomlResource *parent, bool load_children, CzXmlNode *node)
 Creates an instance of this class from XOML.

Protected Member Functions

void addEventsManager ()

Protected Attributes

bool Running
 Timer running status.
float CurrentTime
 Current timer time.
float Duration
 Duration of timer.
int RepeatCount
 Number of times to repeat before stopping, 0 means repeat forever.
int OriginalRepeatCount
 Original number of times to repeat before stopping.
bool AutoDelete
 If set to true then this timer will de4stroy itself when it times out.
CzEventManagerEventsManager
 List of events that the timer handles.

Detailed Description

Polled timer.

Introduction

Time plays a very important role in app and game development. Time allows us to perform useful tasks such as time events, fire off events at regular intervals and stabilise animations etc..

CzXomlTimer provides a software based timer mechanism for timing events as well a static method for retrieving the current time in milliseconds. Timers will not automatically fire off events when they expire, instead they have to be polled.

Timers provide additional functionality for calculating how much time is left on the timer as well as how much time has expired since the timer was started.

Timers don't really have much of an overhead so you can create as many as you like.

Getting the Current Time

To retrieve the current time in milliseconds CzXomlTimer provides a static method:

uint64  GetCurrentTimeMs()

To retrieve the current time in UTC (universal coordinated time) CzXomlTimer provides a static method:

int64   GetCurrentTimeUTC()

Creating and Using Timers

Creating a timer is a simple case of declaring or allocating a CzXomlTimer then setting it off going. To check the timer you then poll it to check to see if it has timed out. Here's an example:

// Create a timer that expires after 10 seconds
CzXomlTimer BusyTimer;
BusyTimer.setDuration(10000);

// Check to see if the timer has timed out
if (BusyTimer.HasTimedOut())
{
}

Timers can be reset, stopped and started using Reset(), Stop() and Start().


Constructor & Destructor Documentation


Member Function Documentation

void CzXomlTimer::addEventsManager ( ) [protected]
float CzXomlTimer::getCurrentTime ( ) const [inline]
float CzXomlTimer::getDuration ( ) const [inline]
int CzXomlTimer::getRepeatCount ( ) const [inline]
bool CzXomlTimer::isAutoDelete ( ) const [inline]
bool CzXomlTimer::isRunning ( ) const [inline]
int CzXomlTimer::LoadFromXoml ( IzXomlResource parent,
bool  load_children,
CzXmlNode node 
) [virtual]

Creates an instance of this class from XOML.

LoadFromXoml is the main method used by all classes that can be instantiated from XOML mark-up. This method creates an instance of this class from the supplied XML node structure specified by node.

Parameters:
[in]parentIf non-null, the parent.
load_childrentrue to load child nodes.
[in]nodeIf non-null, the XOML markup node that defines this object
Returns:
nergative value for error. if 0 then processing of further XOML will stop.

Implements IzXomlResource.

void CzXomlTimer::ProcessEventActions ( unsigned int  event_name)

Process the event actions described by event_name.

Processes the actions list that is associated with the event named event_name (event_name is a hash of the actual event name to speed up searches)

Parameters:
event_nameName of the event as a string hash
void CzXomlTimer::restart ( ) [inline]
void CzXomlTimer::setAutoDelete ( bool  auto_delete) [inline]
void CzXomlTimer::setCurrentTime ( float  time) [inline]
void CzXomlTimer::setDuration ( float  duration) [inline]
void CzXomlTimer::setRepeatCount ( int  count) [inline]
void CzXomlTimer::start ( ) [inline]
void CzXomlTimer::stop ( ) [inline]
bool CzXomlTimer::Update ( float  dt)

Updates the timer.

Parameters:
dtThe number of seconds since physics was last updated
Returns:
false if the time should be deleted.

Member Data Documentation

bool CzXomlTimer::AutoDelete [protected]

If set to true then this timer will de4stroy itself when it times out.

float CzXomlTimer::CurrentTime [protected]

Current timer time.

float CzXomlTimer::Duration [protected]

Duration of timer.

List of events that the timer handles.

Original number of times to repeat before stopping.

int CzXomlTimer::RepeatCount [protected]

Number of times to repeat before stopping, 0 means repeat forever.

bool CzXomlTimer::Running [protected]

Timer running status.


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