nexuslua
Loading...
Searching...
No Matches
configuration.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 <cbeam/memory/pointer.hpp>
31
32#include <memory>
33#include <mutex>
34#include <string>
35#include <string_view>
36
37namespace nexuslua
38{
42 {
43 public:
45 {
46 _t.sub_tables[(std::string)internal].data[(std::string)luaStartNewThreadTime] = 0.01;
47
48#if CBEAM_DEBUG_LOGGING
49 _t.sub_tables[(std::string)internal].data[(std::string)logMessages] = true;
50 _t.sub_tables[(std::string)internal].data[(std::string)logReplication] = true;
51#else
52 _t.sub_tables[(std::string)internal].data[(std::string)logMessages] = false;
53 _t.sub_tables[(std::string)internal].data[(std::string)logReplication] = false;
54#endif
55 }
56
57 virtual ~Configuration() = default;
58
59 template <typename T>
60 T GetInternal(const std::string_view& key)
61 {
62 std::lock_guard lock(_mtx);
63 return _t.sub_tables[(std::string)internal].get_mapped_value_or_throw<T>((std::string)key);
64 }
65
67 {
68 std::lock_guard lock(_mtx);
69 return _t;
70 }
71
72 void SetTable(const LuaTable& t)
73 {
74 std::lock_guard lock(_mtx);
75 _t = t;
76 }
77
78 static constexpr std::string_view internal{"internal"};
79 static constexpr std::string_view luaStartNewThreadTime{"luaStartNewThreadTime"};
80 static constexpr std::string_view logMessages{"logMessages"};
81 static constexpr std::string_view logReplication{"logReplication"};
82
83 private:
84 LuaTable _t;
85 std::mutex _mtx;
86 };
87} // namespace nexuslua
static constexpr std::string_view luaStartNewThreadTime
stores a double value in seconds that is used to decide after which non-idle time an agent replicates...
Definition configuration.hpp:79
T GetInternal(const std::string_view &key)
Definition configuration.hpp:60
static constexpr std::string_view internal
the name of the SubTable the contains the list of internal values, like the following
Definition configuration.hpp:78
static constexpr std::string_view logReplication
stores a bool value (default false); if true, each time an agent is replicated a corresponding log en...
Definition configuration.hpp:81
LuaTable GetTable()
Definition configuration.hpp:66
void SetTable(const LuaTable &t)
Definition configuration.hpp:72
virtual ~Configuration()=default
static constexpr std::string_view logMessages
stores a bool value (default false); if true, all nexuslua messages are logged to "nexuslua....
Definition configuration.hpp:80
Configuration()
Definition configuration.hpp:44
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