nexuslua
Loading...
Searching...
No Matches
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 <string>
33#include <string_view>
34
35namespace nexuslua
36{
43 struct NEXUSLUA_EXPORT Message
44 {
45 public:
46 Message(int agent_n, const std::string& my_name, const LuaTable& my_parameters)
48 , name{my_name}
49 , parameters{my_parameters}
50 {
51 }
52
53 Message(int agent_n, const Message& message)
55 , name{message.name}
56 , parameters{message.parameters}
57 {
58 }
59
62 {
63 }
64
65 Message() = default;
66 virtual ~Message() = default;
67
68 int agent_n = -1;
69 std::string name;
71
72 std::string GetOriginalMessageNameOrEmpty() const;
74
75 virtual std::shared_ptr<Message> clone() const
76 {
77 return std::make_shared<Message>(agent_n, name, parameters);
78 }
79
80 static constexpr std::string_view originalMessageTableId{"original_message"};
81 static constexpr std::string_view originalMessageNameId{"message_name"};
82 static constexpr std::string_view originalMessageParametersId{"parameters"};
83 };
84}
The nexuslua library is implemented inside this namespace.
This type is used for the parameters of nexuslua::Message. In its serialized representation,...
Definition lua_table.hpp:54
std::string GetOriginalMessageNameOrEmpty() const
return the original message name, in case this message is a reply to a message that specified a reply...
LuaTable parameters
parameter table of the message; third parameter of send
Definition message.hpp:70
int agent_n
Definition message.hpp:68
Message(int agent_n, const Message &message)
Definition message.hpp:53
virtual ~Message()=default
Message(int agent_n)
Definition message.hpp:60
static constexpr std::string_view originalMessageParametersId
name of an entry that stores the original message parameters, in case this message is a reply to a me...
Definition message.hpp:82
LuaTable GetOriginalMessageParametersOrEmpty() const
return the original message parameters, in case this message is a reply to a message that specified a...
static constexpr std::string_view originalMessageNameId
name of an entry that stores the original message name, in case this message is a reply to a message ...
Definition message.hpp:81
Message(int agent_n, const std::string &my_name, const LuaTable &my_parameters)
Definition message.hpp:46
virtual std::shared_ptr< Message > clone() const
Definition message.hpp:75
std::string name
name of the message; second parameter of send
Definition message.hpp:69
static constexpr std::string_view originalMessageTableId
name of the SubTable that stores the original message, in case this message is a reply to a message t...
Definition message.hpp:80