nexuslua
Loading...
Searching...
No Matches
lua_table.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 <cbeam/container/xpod.hpp>
29
30#include <cbeam/container/nested_map.hpp>
31
32#include <cbeam/serialization/nested_map.hpp>
33
34#include "nexuslua_export.h"
35
36#include <memory>
37#include <string>
38#include <string_view>
39
40namespace nexuslua
41{
42 struct Message;
43 using LuaTableBase = cbeam::container::nested_map<cbeam::container::xpod::type, cbeam::container::xpod::type>;
44
53 struct NEXUSLUA_EXPORT LuaTable : public LuaTableBase
54 {
56 LuaTable() = default;
57
59 LuaTable(const cbeam::serialization::serialized_object serializedNestedMap);
60
62 LuaTable(const cbeam::container::nested_map<cbeam::container::xpod::type, cbeam::container::xpod::type>& baseInstance);
63
64 void SetOriginalMessage(const std::shared_ptr<Message> originalMessage);
65 void SetReplyTo(const std::string& agentName, const std::string& messageName);
66 void SetReplyToAgentName(const std::string& agentName);
67 void SetReplyToMessageName(const std::string& messageName);
68 std::string GetReplyToAgentNameOrEmpty() const;
69 std::string GetReplyToMessageNameOrEmpty() const;
72
73 protected:
74 static constexpr std::string_view replyToTableId{"reply_to"};
75 static constexpr std::string_view tableToMergeWhenReplyingId{"merge"};
76 static constexpr std::string_view unreplicatedId{"unreplicated"};
77 static constexpr std::string_view agentNameId{"agent"};
78 static constexpr std::string_view agentMessageId{"message"};
79 };
80}
The nexuslua library is implemented inside this namespace.
cbeam::container::nested_map< cbeam::container::xpod::type, cbeam::container::xpod::type > LuaTableBase
Definition lua_table.hpp:43
LuaTable(const cbeam::container::nested_map< cbeam::container::xpod::type, cbeam::container::xpod::type > &baseInstance)
construct LuaTable from an instance of its base class
static constexpr std::string_view tableToMergeWhenReplyingId
name of a cbeam::container::nested_map::sub_tables entry that stores the agent that a message shall r...
Definition lua_table.hpp:75
static constexpr std::string_view replyToTableId
name of a cbeam::container::nested_map::sub_tables entry that stores the agent that a message shall r...
Definition lua_table.hpp:74
bool RequestsUnreplicatedReceiver() const
return true if the table represents message parameters from a sender that requests that the message m...
void SetReplyTo(const std::string &agentName, const std::string &messageName)
Sets the entries "reply_to/agent" and "reply_to/message" to the given strings, which will trigger an ...
std::string GetReplyToMessageNameOrEmpty() const
if there is an entry "reply_to/message", returns it, otherwise returns the empty string
static constexpr std::string_view unreplicatedId
name of a data field that stores if the sender requests that the message must be received by a non-re...
Definition lua_table.hpp:76
static constexpr std::string_view agentNameId
name of an entry in cbeam::serialization::serialized_object::data that stores the name of the agent t...
Definition lua_table.hpp:77
LuaTable(const cbeam::serialization::serialized_object serializedNestedMap)
construct table from serialized void*
LuaTableBase GetTableToMergeWhenReplyingOrEmpty() const
if there is a table entry "reply_to/merge", return it, otherwise an empty nexuslua::LuaTableBase
static constexpr std::string_view agentMessageId
name of an entry in cbeam::serialization::serialized_object::data that stores the name of the message...
Definition lua_table.hpp:78
void SetReplyToMessageName(const std::string &messageName)
only sets the entry "reply_to/message" to the given message name, leaves the "reply_to/agent" unchang...
void SetOriginalMessage(const std::shared_ptr< Message > originalMessage)
Copies the given message into a sub table (cbeam::container::nested_map::sub_tables) with name "origi...
void SetReplyToAgentName(const std::string &agentName)
only sets the entry "reply_to/agent" to the given name, leaves the "reply_to/message" unchanged
std::string GetReplyToAgentNameOrEmpty() const
if there is an entry "reply_to/agent", returns it, otherwise returns the empty string
LuaTable()=default
construct empty LuaTable
This type is the actual message type that is sent by function send.
Definition message.hpp:44