OpenLexocad  27.1
entt::process_adaptor< Func, Delta > Struct Template Reference

Adaptor for lambdas and functors to turn them into processes. More...

#include <entt.hpp>

Inheritance diagram for entt::process_adaptor< Func, Delta >:
entt::process< process_adaptor< Func, Delta >, Delta >

Public Member Functions

template<typename... Args>
 process_adaptor (Args &&... args)
 Constructs a process adaptor from a lambda or a functor. More...
 
void update (const Delta delta, void *data)
 Updates a process and its internal state if required. More...
 
- Public Member Functions inherited from entt::process< process_adaptor< Func, Delta >, Delta >
void tick (const Delta delta, void *data=nullptr)
 Updates a process and its internal state if required. More...
 
virtual ~process () ENTT_NOEXCEPT
 Default destructor. More...
 
void abort (const bool immediately=false) ENTT_NOEXCEPT
 Aborts a process if it's still alive. More...
 
bool alive () const ENTT_NOEXCEPT
 Returns true if a process is either running or paused. More...
 
bool dead () const ENTT_NOEXCEPT
 Returns true if a process is already terminated. More...
 
bool paused () const ENTT_NOEXCEPT
 Returns true if a process is currently paused. More...
 
bool rejected () const ENTT_NOEXCEPT
 Returns true if a process terminated with errors. More...
 

Additional Inherited Members

- Public Types inherited from entt::process< process_adaptor< Func, Delta >, Delta >
using delta_type = Delta
 Type used to provide elapsed time. More...
 
- Protected Member Functions inherited from entt::process< process_adaptor< Func, Delta >, Delta >
void succeed () ENTT_NOEXCEPT
 Terminates a process with success if it's still alive. More...
 
void fail () ENTT_NOEXCEPT
 Terminates a process with errors if it's still alive. More...
 
void pause () ENTT_NOEXCEPT
 Stops a process if it's in a running state. More...
 
void unpause () ENTT_NOEXCEPT
 Restarts a process if it's paused. More...
 

Detailed Description

template<typename Func, typename Delta>
struct entt::process_adaptor< Func, Delta >

Adaptor for lambdas and functors to turn them into processes.

Lambdas and functors can't be used directly with a scheduler for they are not properly defined processes with managed life cycles.
This class helps in filling the gap and turning lambdas and functors into full featured processes usable by a scheduler.

The signature of the function call operator should be equivalent to the following:

void(Delta delta, void *data, auto succeed, auto fail);

Where:

  • delta is the elapsed time.
  • data is an opaque pointer to user data if any, nullptr otherwise.
  • succeed is a function to call when a process terminates with success.
  • fail is a function to call when a process terminates with errors.

The signature of the function call operator of both succeed and fail is equivalent to the following:

void();

Usually users shouldn't worry about creating adaptors. A scheduler will create them internally each and avery time a lambda or a functor is used as a process.

See also
process
scheduler
Template Parameters
FuncActual type of process.
DeltaType to use to provide elapsed time.

Constructor & Destructor Documentation

◆ process_adaptor()

template<typename Func, typename Delta>
template<typename... Args>
entt::process_adaptor< Func, Delta >::process_adaptor ( Args &&...  args)
inline

Constructs a process adaptor from a lambda or a functor.

Template Parameters
ArgsTypes of arguments to use to initialize the actual process.
Parameters
argsParameters to use to initialize the actual process.

Member Function Documentation

◆ update()

template<typename Func, typename Delta>
void entt::process_adaptor< Func, Delta >::update ( const Delta  delta,
void *  data 
)
inline

Updates a process and its internal state if required.

Parameters
deltaElapsed time.
dataOptional data.

The documentation for this struct was generated from the following file: