Taskolib  1.3.3
Context.h
Go to the documentation of this file.
1 
23 // SPDX-License-Identifier: LGPL-2.1-or-later
24 
25 #ifndef TASKOLIB_CONTEXT_H_
26 #define TASKOLIB_CONTEXT_H_
27 
28 #include <functional>
29 #include <string>
30 #include <unordered_map>
31 #include <variant>
32 
33 #include "sol/sol.hpp"
34 #include "taskolib/CommChannel.h"
36 #include "taskolib/Message.h"
37 #include "taskolib/StepIndex.h"
38 #include "taskolib/VariableName.h"
39 
40 namespace task {
41 
47 using LuaInteger = LUA_INTEGER;
48 using LuaFloat = LUA_NUMBER;
49 using LuaString = std::string;
50 using LuaBool = bool;
51 
55 using VarInteger = long long;
56 using VarFloat = double;
57 using VarString = std::string;
58 using VarBool = bool;
59 
69 using VariableValue = std::variant<
70  VarInteger,
71  VarFloat,
72  VarString,
73  VarBool>;
74 
80 using VariableTable = std::unordered_map<VariableName, VariableValue>;
81 
86 using MessageCallback = std::function<void(const Message&)>;
87 
127 struct Context
128 {
131 
134  std::string step_setup_script = "";
135 
137  std::function<void(sol::state&)> step_setup_function;
138 
144 };
145 
146 } // namespace task
147 
148 #endif
Declaration of the CommChannel struct.
Declaration of the Message class.
Declaration of the StepIndex type.
Declaration of the VariableName class and of an associated specialization of std::hash.
A message carrying some text, a timestamp, and a type, to be transported with a message queue between...
Definition: Message.h:45
Declaration of the default_message_callback() function.
Namespace task contains all Taskolib functions and classes.
Definition: CommChannel.h:33
long long VarInteger
Storage type for integral numbers.
Definition: Context.h:55
std::string LuaString
The string type used by the Lua interpreter.
Definition: Context.h:49
bool VarBool
Storage type for booleans.
Definition: Context.h:58
LUA_INTEGER LuaInteger
The integer type used by the Lua interpreter.
Definition: Context.h:47
void default_message_callback(const Message &msg)
Default callback function for messages.
Definition: default_message_callback.cc:30
std::function< void(const Message &)> MessageCallback
A message callback function receives a Message object as a parameter.
Definition: Context.h:86
LUA_NUMBER LuaFloat
The floating point type used by the Lua interpreter.
Definition: Context.h:48
std::variant< VarInteger, VarFloat, VarString, VarBool > VariableValue
A VariableValue is a variant over all Variable types.
Definition: Context.h:73
double VarFloat
Storage type for floatingpoint number.
Definition: Context.h:56
bool LuaBool
The boolean type used by the Lua interpreter.
Definition: Context.h:50
std::string VarString
Storage type for strings.
Definition: Context.h:57
std::unordered_map< VariableName, VariableValue > VariableTable
Associative table that holds Lua variable names and their value.
Definition: Context.h:80
A context stores information that influences the execution of steps and sequences,...
Definition: Context.h:128
std::function< void(sol::state &)> step_setup_function
An initialization function that is called on a Lua state before a step is executed.
Definition: Context.h:137
MessageCallback message_callback_function
A callback (or "hook") function that is invoked whenever a message is processed during the execution ...
Definition: Context.h:143
std::string step_setup_script
Step setup script with common functions or constants like a small library.
Definition: Context.h:134
VariableTable variables
A map of variables (names and values) that can be im-/exported into steps.
Definition: Context.h:130