nexuslua
Loading...
Searching...
No Matches
agent_message.hpp
Go to the documentation of this file.
1/*
2Copyright (c) 2025 acrion innovations GmbH
3Authors: Stefan Zipproth, s.zipproth@acrion.ch
4
5This file is part of nexuslua, see https://github.com/acrion/nexuslua and https://nexuslua.org
6
7nexuslua is offered under a commercial and under the AGPL license.
8For commercial licensing, contact us at https://acrion.ch/sales. For AGPL licensing, see below.
9
10AGPL licensing:
11
12nexuslua is free software: you can redistribute it and/or modify
13it under the terms of the GNU Affero General Public License as published by
14the Free Software Foundation, either version 3 of the License, or
15(at your option) any later version.
16
17nexuslua is distributed in the hope that it will be useful,
18but WITHOUT ANY WARRANTY; without even the implied warranty of
19MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20GNU Affero General Public License for more details.
21
22You should have received a copy of the GNU Affero General Public License
23along with nexuslua. If not, see <https://www.gnu.org/licenses/>.
24*/
25
26#pragma once
27
28#include "lua_table.hpp"
29
30#include "nexuslua_export.h"
31
32#include <atomic>
33#include <memory>
34#include <string>
35
36namespace nexuslua
37{
38 class Lua;
39
40 enum class AgentType
41 {
43 Lua = 0,
44 Cpp = 1
45 };
46
49 class NEXUSLUA_EXPORT AgentMessage
50 {
51 public:
53 std::string GetAgentName() const;
54 std::string GetMessageName() const;
55 std::string GetDisplayName() const;
56 std::string GetDescription() const;
57 LuaTable::nested_tables GetParameterDescriptions() const;
58 LuaTable::nested_tables GetDescriptionsOfUnsetParameters(const LuaTable& parameterValues) const;
59 std::string GetIconPath() const;
60 void Send(const LuaTable& parameters) const;
61
62 private:
63 friend class Agent;
64 friend class AgentCpp;
65
66 AgentMessage(const int agentN, const AgentType& agentType, const std::string& agentName, const std::string& messageName, const LuaTable::nested_tables& parameterDescriptions, const std::string& displayName, const std::string& description, const std::string& icon);
67 AgentMessage(const int agentN, const AgentType& agentType, const std::string& agentName, const std::string& messageName);
68
69 int _agentN;
70 AgentType _agentType;
71 std::string _agentName;
72 std::string _messageName;
73 LuaTable::nested_tables _parameterDescriptions;
74 std::string _displayName;
75 std::string _description;
76 std::string _svgIcon;
77 std::shared_ptr<Lua> _lua;
78
79 void Validate(const LuaTable& parameterValues) const;
80 LuaTable AddDefaultParameterValues(const LuaTable& parameterValues) const;
81 };
82}
LuaTable::nested_tables GetParameterDescriptions() const
return descriptions for each of the parameters of this message (may be empty, usually set for agents ...
AgentType GetAgentType() const
return the type of the agent that accepts this message (Lua or C++)
friend class AgentCpp
Definition agent_message.hpp:64
LuaTable::nested_tables GetDescriptionsOfUnsetParameters(const LuaTable &parameterValues) const
convenience method. Returns only those descriptions of parameters that are not part of the given para...
std::string GetAgentName() const
return the name of the agent that accepts this message
std::string GetDescription() const
return a description of this message (may be empty, usually set for agents that are used as plugins,...
std::string GetDisplayName() const
return a display name of this message (may be empty, usually set for agents that are used as plugins,...
std::string GetMessageName() const
this message name is used by AgentMessage::Send
std::string GetIconPath() const
return the path to an icon that can be shown in a graphical user interface for this message (may be e...
void Send(const LuaTable &parameters) const
completes values that are missing in parameters based on GetParameterDescriptions() with their defaul...
friend class Agent
Definition agent_message.hpp:63
Definition description.hpp:33
The nexuslua library is implemented inside this namespace.
AgentType
Definition agent_message.hpp:41
@ Lua
Definition agent_message.hpp:43
@ Cpp
Definition agent_message.hpp:44
@ Undefined
Definition agent_message.hpp:42
This type is used for the parameters of nexuslua::Message. In its serialized representation,...
Definition lua_table.hpp:54