FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
fge::TaskHandler Class Reference

Handle the tasks of an object. More...

#include <C_task.hpp>

Public Member Functions

 TaskHandler (TaskHandler const &r)=delete
 
 TaskHandler (TaskHandler &&r) noexcept
 
TaskHandleroperator= (TaskHandler const &r)=delete
 
TaskHandleroperator= (TaskHandler &&r) noexcept=delete
 
void setParentObject (fge::Object &parentObject)
 Set the parent object of the TaskHandler.
 
fge::ObjectgetParentObject () const
 
std::size_t getTaskSize () const
 
template<class T = fge::Task>
T * setMainTask (std::unique_ptr< T > &&newTask)
 Set the main task.
 
template<class T >
T * setMainTask ()
 
template<class T , class... TArgs>
T * setMainTaskAndInit (TArgs &&... args)
 
template<class T = fge::Task>
T * addSubTask (std::unique_ptr< T > &&newTask)
 Add a sub-task.
 
template<class T >
T * addSubTask ()
 
template<class T , class... TArgs>
T * addSubTaskAndInit (TArgs &&... args)
 
fge::TaskgetMainTask () const
 
fge::TaskgetActualTask () const
 
std::optional< fge::TaskTypeIndex > getActualTaskType () const
 
void popTask ()
 
void clearTasks ()
 
fge::TaskList const & getTasks () const
 
std::optional< fge::TaskTypeIndex > getLastTask () const
 
void clearLastTask ()
 
void networkRegister (fge::net::NetworkTypeHandler &netList)
 Register the network types of the tasks.
 
fge::TasksChecksum getChecksum () const
 

Public Attributes

fge::CallbackHandler< TaskHandler & > _onMainTaskChanged
 Called when the main task is changed.
 

Detailed Description

Handle the tasks of an object.

A TaskHandler is used to handle the tasks of an object. It can have multiple sub-tasks and one main task.

Member Function Documentation

◆ addSubTask()

template<class T >
T * fge::TaskHandler::addSubTask ( std::unique_ptr< T > && newTask)

Add a sub-task.

This function should be called when a task is present and a sub-task is required.

Template Parameters
TThe type of the task for convenience
Parameters
newTaskThe new task
Returns
The pointer to the new task with type T

◆ networkRegister()

void fge::TaskHandler::networkRegister ( fge::net::NetworkTypeHandler & netList)

Register the network types of the tasks.

This is a helper function that register the network type using the NetworkTypeTasks class. It should be called inside the Object::networkRegister() function.

Parameters
netListThe network type container

◆ setMainTask()

template<class T >
T * fge::TaskHandler::setMainTask ( std::unique_ptr< T > && newTask)

Set the main task.

All tasks is cleared before setting the new main task.

Template Parameters
TThe type of the task for convenience
Parameters
newTaskThe new task
Returns
The pointer to the new task with type T

◆ setParentObject()

void fge::TaskHandler::setParentObject ( fge::Object & parentObject)

Set the parent object of the TaskHandler.

All created tasks will have this object as parent.

Parameters
parentObjectThe parent object

Member Data Documentation

◆ _onMainTaskChanged

fge::CallbackHandler<TaskHandler&> fge::TaskHandler::_onMainTaskChanged

Called when the main task is changed.


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