EnTT 3.14.0
|
Base class for processes. More...
#include <process.hpp>
Public Types | |
using | delta_type = Delta |
Type used to provide elapsed time. | |
Public Member Functions | |
constexpr | process ()=default |
Default constructor. | |
process (const process &)=default | |
Default copy constructor. | |
process (process &&) noexcept=default | |
Default move constructor. | |
process & | operator= (const process &)=default |
Default copy assignment operator. | |
process & | operator= (process &&) noexcept=default |
Default move assignment operator. | |
virtual | ~process () |
Default destructor. | |
void | abort (const bool immediate=false) |
Aborts a process if it's still alive. | |
bool | alive () const noexcept |
Returns true if a process is either running or paused. | |
bool | finished () const noexcept |
Returns true if a process is already terminated. | |
bool | paused () const noexcept |
Returns true if a process is currently paused. | |
bool | rejected () const noexcept |
Returns true if a process terminated with errors. | |
void | tick (const Delta delta, void *data=nullptr) |
Updates a process and its internal state if required. | |
Protected Member Functions | |
void | succeed () noexcept |
Terminates a process with success if it's still alive. | |
void | fail () noexcept |
Terminates a process with errors if it's still alive. | |
void | pause () noexcept |
Stops a process if it's in a running state. | |
void | unpause () noexcept |
Restarts a process if it's paused. | |
Base class for processes.
This class stays true to the CRTP idiom. Derived classes must specify what's the intended type for elapsed times.
A process should expose publicly the following member functions whether required:
It's invoked once per tick until a process is explicitly aborted or it terminates either with or without errors. Even though it's not mandatory to declare this member function, as a rule of thumb each process should at least define it to work properly. The void *
parameter is an opaque pointer to user data (if any) forwarded directly to the process during an update.
It's invoked when the process joins the running queue of a scheduler. This happens as soon as it's attached to the scheduler if the process is a top level one, otherwise when it replaces its parent if the process is a continuation.
It's invoked in case of success, immediately after an update and during the same tick.
It's invoked in case of errors, immediately after an update and during the same tick.
It's invoked only if a process is explicitly aborted. There is no guarantee that it executes in the same tick, this depends solely on whether the process is aborted immediately or not.
Derived classes can change the internal state of a process by invoking the succeed
and fail
protected member functions and even pause or unpause the process itself.
Derived | Actual type of process that extends the class template. |
Delta | Type to use to provide elapsed time. |
Definition at line 71 of file process.hpp.
using entt::process< Derived, Delta >::delta_type = Delta |
Type used to provide elapsed time.
Definition at line 167 of file process.hpp.
|
inlinevirtual |
Default destructor.
Definition at line 191 of file process.hpp.
Aborts a process if it's still alive.
The function is idempotent and it does nothing if the process isn't alive.
immediate | Requests an immediate operation. |
Definition at line 203 of file process.hpp.
|
inlinenoexcept |
Returns true if a process is either running or paused.
Definition at line 217 of file process.hpp.
|
inlineprotectednoexcept |
Terminates a process with errors if it's still alive.
The function is idempotent and it does nothing if the process isn't alive.
Definition at line 135 of file process.hpp.
|
inlinenoexcept |
Returns true if a process is already terminated.
Definition at line 225 of file process.hpp.
|
default |
Default copy assignment operator.
|
defaultnoexcept |
Default move assignment operator.
|
inlineprotectednoexcept |
Stops a process if it's in a running state.
The function is idempotent and it does nothing if the process isn't running.
Definition at line 147 of file process.hpp.
|
inlinenoexcept |
Returns true if a process is currently paused.
Definition at line 233 of file process.hpp.
|
inlinenoexcept |
Returns true if a process terminated with errors.
Definition at line 241 of file process.hpp.
|
inlineprotectednoexcept |
Terminates a process with success if it's still alive.
The function is idempotent and it does nothing if the process isn't alive.
Definition at line 123 of file process.hpp.
Updates a process and its internal state if required.
delta | Elapsed time. |
data | Optional data. |
Definition at line 250 of file process.hpp.
|
inlineprotectednoexcept |
Restarts a process if it's paused.
The function is idempotent and it does nothing if the process isn't paused.
Definition at line 159 of file process.hpp.