25 #ifndef TASKOLIB_STEP_H_
26 #define TASKOLIB_STEP_H_
Declaration of the CommChannel struct.
Declaration of the Context and VariableValue types.
Logic to check if a timeout elapsed.
Declaration of the Timeout class.
Declaration of the VariableName class and of an associated specialization of std::hash.
A step is the main building block of a sequence.
Definition: Step.h:53
TimePoint get_time_of_last_execution() const
Return the timestamp of the last execution of this step's script.
Definition: Step.h:178
static constexpr short max_indentation_level
Maximum allowed level of indentation (or nesting of steps)
Definition: Step.h:63
bool execute_impl(Context &context, CommChannel *comm_channel, OptionalStepIndex index, TimeoutTrigger *sequence_timeout)
Execute the Lua script, throwing an exception if anything goes wrong.
Definition: Step.cc:113
Timeout get_timeout() const
Return the timeout duration for executing the script.
Definition: Step.h:188
Step & set_time_of_last_modification(TimePoint t)
Set the timestamp of the last modification of this step's script or label.
Definition: Step.cc:252
Step & set_running(bool is_running)
Set whether the step should be marked as "currently running".
Definition: Step.cc:233
short get_indentation_level() const noexcept
Return the indentation level of this step.
Definition: Step.h:144
bool is_disabled_
Definition: Step.h:276
Type get_type() const noexcept
Return the type of this step.
Definition: Step.h:191
Step & set_type(Type type)
Set the type of this step.
Definition: Step.cc:264
const std::string & get_label() const
Return the label of the step.
Definition: Step.h:153
bool is_running() const noexcept
Return whether this step is currently being executed.
Definition: Step.h:198
void copy_used_variables_from_context_to_lua(const Context &context, sol::state &lua)
Copy the variables listed in used_context_variable_names_ from the given Context into a Lua state.
Definition: Step.cc:50
Step & set_disabled(bool disable)
Set whether the step should be disabled (or possibly executed).
Definition: Step.cc:199
Type
An enum for differentiating the different types of step.
Definition: Step.h:57
@ type_end
Definition: Step.h:58
@ type_catch
Definition: Step.h:59
@ type_action
Definition: Step.h:58
@ type_if
Definition: Step.h:58
@ type_else
Definition: Step.h:58
@ type_while
Definition: Step.h:58
@ type_elseif
Definition: Step.h:58
@ type_try
Definition: Step.h:58
Step(Type type=type_action)
Construct a Step of a certain type.
Definition: Step.h:67
const std::string & get_script() const
Return the script.
Definition: Step.h:171
void copy_used_variables_from_lua_to_context(const sol::state &lua, Context &context)
Copy the variables listed in used_context_variable_names_ from a Lua state into the given Context.
Definition: Step.cc:80
TimePoint time_of_last_execution_
Definition: Step.h:271
TimePoint time_of_last_modification_
Definition: Step.h:270
Step & set_script(const std::string &script)
Set the script that should be executed when this step is run.
Definition: Step.cc:239
std::string script_
Definition: Step.h:268
Timeout timeout_
Definition: Step.h:272
Step & set_time_of_last_execution(TimePoint t)
Set the timestamp of the last execution of this step's script.
Definition: Step.cc:246
Step & set_used_context_variable_names(const VariableNames &used_context_variable_names)
Set the names of the variables that should be im-/exported from/to the script.
Definition: Step.cc:271
Type type_
Definition: Step.h:273
Step & set_indentation_level(short level)
Set the indentation level of this step.
Definition: Step.cc:211
TimePoint get_time_of_last_modification() const
Return the timestamp of the last modification of this step's script or label.
Definition: Step.h:185
bool is_disabled() const noexcept
Return whether this step is currently disabled.
Definition: Step.h:201
VariableNames used_context_variable_names_
Definition: Step.h:269
bool execute(Context &context, CommChannel *comm_channel=nullptr, OptionalStepIndex opt_step_index=gul14::nullopt, TimeoutTrigger *sequence_timeout=nullptr)
Execute the step script within the given context, sending status information to a message queue.
Definition: Step.cc:167
Step & set_label(const std::string &label)
Set the label.
Definition: Step.cc:226
std::string label_
Definition: Step.h:267
Step & set_timeout(Timeout timeout)
Set the timeout duration for executing the script.
Definition: Step.cc:258
const VariableNames & get_used_context_variable_names() const
Retrieve the names of the variables that should be im-/exported to and from the context.
Definition: Step.h:133
short indentation_level_
Definition: Step.h:274
bool is_running_
Definition: Step.h:275
Evaluates when the clock is elapsed.
Definition: TimeoutTrigger.h:49
A type for storing a timeout duration.
Definition: Timeout.h:72
Namespace task contains all Taskolib functions and classes.
Definition: CommChannel.h:33
bool executes_script(Step::Type step_type)
Determine if a script is executed.
Definition: Step.cc:304
const ExecutionSteps execution_steps
Step types that execute a script.
Definition: Step.h:302
std::set< Step::Type > ExecutionSteps
Alias for a step type collection that executes a script.
Definition: Step.h:299
std::string to_string(Step::Type type)
Return a lower-case name for a step type ("action", "if", "end").
Definition: Step.cc:287
bool requires_bool_return_value(Step::Type step_type) noexcept
Determine if a certain step type requires a boolean return value from the script.
Definition: Step.cc:309
std::set< VariableName > VariableNames
Definition: Step.h:41
gul14::optional< StepIndex > OptionalStepIndex
An optional step index (gul14::optional<StepIndex>).
Definition: StepIndex.h:37
std::chrono::time_point< Clock > TimePoint
Definition: time_types.h:34
A struct combining a message queue and several atomic flags.
Definition: CommChannel.h:43
A context stores information that influences the execution of steps and sequences,...
Definition: Context.h:128
Declaration of time-related types.