Task

Summary
Enumeration defining priority of a Task.
Abstract class for tasks, which are runnable classes for use with TaskManager.
Constructor, every task needs a name and priority.
Virtual destructor, exists simply to make inheritance safe.
Pure virtual, every child task must overload it’s own update(), when a task is active this is called every ‘frame.’
Virtual function, overload to define behavior when the task is started.
Virtual function, overload to define behavior when the task is killed.
Virtual function, overload to define behavior every time that the task is paused.
Virtual function, overload to define behavior every time that the task is unpaused.
Sets state of task to dead, dead tasks remove themselves from the TaskManager’s task pool.
Get the name of the task.
Get the priority of the task.
Check if task is alive or not.
Check if task is paused or not.
Pointer to a task, used since Task is abstract and will always be accessed via a pointer.

PriorityLevel

Enumeration defining priority of a Task.

Values

PRI_LOWESTLowest priority available.
PRI_LOWLower-than-usual priority.
PRI_NORMALNormal priority, suitable for most tasks.
PRI_HIGHLower-than-usual priority.
PRI_HIGHESTHighest priority available.

Task

Abstract class for tasks, which are runnable classes for use with TaskManager.

When writing a task, only update() needs to be overloaded.

Summary
Constructor, every task needs a name and priority.
Virtual destructor, exists simply to make inheritance safe.
Pure virtual, every child task must overload it’s own update(), when a task is active this is called every ‘frame.’
Virtual function, overload to define behavior when the task is started.
Virtual function, overload to define behavior when the task is killed.
Virtual function, overload to define behavior every time that the task is paused.
Virtual function, overload to define behavior every time that the task is unpaused.
Sets state of task to dead, dead tasks remove themselves from the TaskManager’s task pool.
Get the name of the task.
Get the priority of the task.
Check if task is alive or not.
Check if task is paused or not.
Pointer to a task, used since Task is abstract and will always be accessed via a pointer.

(Con/ De)structors

Task

Task(const std::string &name,  
PriorityLevel priority = PRI_NORMAL)

Constructor, every task needs a name and priority.

Parameters

nameName for task, must be unique!
priorityOptional argument for desired priority for the Task, controls order in which tasks are run by the TaskManager.  Default Priority is PRI_NORMAL

~Task

virtual ~Task()

Virtual destructor, exists simply to make inheritance safe.

Control

update

virtual void update(scalar timeDelta)=0

Pure virtual, every child task must overload it’s own update(), when a task is active this is called every ‘frame.’

Parameters

timeDeltaThe time elapsed between frames, possibly fixed via Application::setFixedUpdateStep.

onStart

virtual void onStart()

Virtual function, overload to define behavior when the task is started.

onKill

virtual void onKill()

Virtual function, overload to define behavior when the task is killed.

onPause

virtual void onPause()

Virtual function, overload to define behavior every time that the task is paused.

Note

Children of onPause should call Task::onPause to let the task know it’s been paused.

onUnpause

virtual void onUnpause()

Virtual function, overload to define behavior every time that the task is unpaused.

Note

Children of onUnpause should call Task::onUnpause to let the task know it’s been paused.

kill

void kill()

Sets state of task to dead, dead tasks remove themselves from the TaskManager’s task pool.

Accessors

getName

std::string getName() const

Get the name of the task.

Return

Name of task.

getPriority

uint getPriority() const

Get the priority of the task.

Return

priority of task.

isAlive

bool isAlive() const

Check if task is alive or not.

Return

true if task is alive, false if task has been killed

isPaused

bool isPaused() const

Check if task is paused or not.

Return

true iff task is paused

TaskPtr

Pointer to a task, used since Task is abstract and will always be accessed via a pointer.

TaskManager class, maintains a list of Tasks and manages their status, handles adding, deleting, pausing, and unpausing tasks.
Task(const std::string &name,  
PriorityLevel priority = PRI_NORMAL)
Constructor, every task needs a name and priority.
virtual ~Task()
Virtual destructor, exists simply to make inheritance safe.
virtual void update(scalar timeDelta)=0
Pure virtual, every child task must overload it’s own update(), when a task is active this is called every ‘frame.’
virtual void onStart()
Virtual function, overload to define behavior when the task is started.
virtual void onKill()
Virtual function, overload to define behavior when the task is killed.
virtual void onPause()
Virtual function, overload to define behavior every time that the task is paused.
virtual void onUnpause()
Virtual function, overload to define behavior every time that the task is unpaused.
void kill()
Sets state of task to dead, dead tasks remove themselves from the TaskManager’s task pool.
std::string getName() const
Get the name of the task.
uint getPriority() const
Get the priority of the task.
bool isAlive() const
Check if task is alive or not.
bool isPaused() const
Check if task is paused or not.
void setFixedUpdateStep(bool enable,  
scalar fixedStep,  
scalar maxStep = )
Sets a fixed timestep to be used in calls to the current State’s update method.