Taskolib  1.3.3
Public Attributes | List of all members
task::Context Struct Reference

Detailed Description

A context stores information that influences the execution of steps and sequences, namely:

Message callback function

The Context contains a message_callback_function that is called once for each message that is being processed by the execution engine in the main thread. By default, this function will send the output of the Lua "print()" command and error messages to stdout (see default_message_callback()). However, message_callback_function can also be set to nullptr (to disable any special behavior) or to a custom function:

void my_message_callback(const Message& msg)
{
if (msg.get_type() == Message::Type::output)
send_to_console(msg.get_text());
else if (msg.get_type() == Message::Type::sequence_stopped_with_error)
show_alert_box(msg.get_text());
}
Context context;
context.message_callback_function = my_message_callback;
@ output
a message string that was output by a step via print()
@ sequence_stopped_with_error
a sequence has been stopped because of an error

The callback function receives a reference to the message that is being processed. If a sequence is executed in the current thread (e.g. via Sequence::execute()), the callback is executed whenever a message is generated. If the sequence is handed to an Executor for parallel execution, the callback is run whenever the main thread has received the message (i.e. typically within Executor::update()). Callbacks are never executed on the worker thread.

#include <Context.h>

Public Attributes

VariableTable variables
 A map of variables (names and values) that can be im-/exported into steps. More...
 
std::string step_setup_script = ""
 Step setup script with common functions or constants like a small library. More...
 
std::function< void(sol::state &)> step_setup_function
 An initialization function that is called on a Lua state before a step is executed. More...
 
MessageCallback message_callback_function = default_message_callback
 A callback (or "hook") function that is invoked whenever a message is processed during the execution of a sequence. More...
 

Member Data Documentation

◆ message_callback_function

MessageCallback task::Context::message_callback_function = default_message_callback

A callback (or "hook") function that is invoked whenever a message is processed during the execution of a sequence.

Referenced by task::Executor::launch_async_execution(), task::send_message(), and task::Executor::update().

◆ step_setup_function

std::function<void(sol::state&)> task::Context::step_setup_function

An initialization function that is called on a Lua state before a step is executed.

Referenced by task::Step::execute_impl().

◆ step_setup_script

std::string task::Context::step_setup_script = ""

Step setup script with common functions or constants like a small library.

Overwritten when a sequence is started.

Referenced by task::Step::execute_impl(), and task::Sequence::handle_execution().

◆ variables

VariableTable task::Context::variables

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