32#include "nexuslua_export.h"
48 class NEXUSLUA_EXPORT
agents :
public std::enable_shared_from_this<agents>
51 std::unique_ptr<impl> _impl;
58 const std::map<std::string, std::shared_ptr<const Agent>>&
GetPlugins();
71 std::shared_ptr<AgentCpp>
Add(
const std::string& agentName,
const CppHandler& cppHandler,
const LuaTable& predefinedTable = {});
78 std::shared_ptr<AgentLua>
Add(
const std::string& agentName,
const std::filesystem::path& pathToLuaFile,
const std::string& luaCode =
"",
const LuaTable& predefinedTable = {});
83 std::shared_ptr<Agent>
GetAgent(
const std::string& agentName);
This class describes a message that can be sent via nexuslua send or AgentMessage::Send.
Definition agent_message.hpp:50
base class of the three types of agents
Definition agent.hpp:60
std::shared_ptr< AgentCpp > Add(const std::string &agentName, const CppHandler &cppHandler, const LuaTable &predefinedTable={})
creates a new hardware thread that calls cppHandler as soon as a message is sent to it via either nex...
std::shared_ptr< Agent > GetAgent(const std::string &agentName)
returns the Agent instance associated with the given agent name, or nullptr if there is no such agent
static int64_t TotalSizeOfMessagesQueues()
PluginInstallResult InstallPlugin(const std::filesystem::path &srcFolder, std::string &errorMessage)
user selects a directory with a plugin to be installed. This function installs it....
PluginInstallResult InstallPlugin(const std::shared_ptr<::nexuslua::Agent > &agent, const std::filesystem::path &srcFolder, std::string &errorMessage)
user selects a directory with a plugin to be installed. This function installs it....
void ShutdownAgents()
if the main application quits, it should use this function to make sure all threads have ended before...
void InvalidatePluginScan()
after calling this function, the next call to agents::GetPlugins will rescan the plugin directory
const AgentMessage & GetMessage(const std::string &agentName, const std::string &messageName)
return the given message
void WaitUntilMessageQueueIsEmpty()
wait until the nexuslua agents processed all remaining messages
PluginUninstallResult UninstallPlugin(const std::string &name)
the name is identical with AgentPlugin::GetName()
const std::map< std::string, std::shared_ptr< const Agent > > & GetPlugins()
key is plugin name, same as AgentPlugin::GetName()
void RestorePersistentPluginFolder(const std::shared_ptr<::nexuslua::Agent > &plugin, const std::filesystem::path &srcFolder)
copy the persistent subfolder from the given directory to the plugin folder
std::shared_ptr< AgentLua > Add(const std::string &agentName, const std::filesystem::path &pathToLuaFile, const std::string &luaCode="", const LuaTable &predefinedTable={})
creates a new hardware thread that calls luaCode, if not empty, otherwise the given lua file
void AddMessageForCppAgent(const std::string &agentName, const std::string &messageName)
registers a message for an nexuslua::Agent that has been created via nexuslua::agents::Add.
The nexuslua library is implemented inside this namespace.
PluginInstallResult
result values of agents::InstallPlugin
Definition plugin_install_result.hpp:34
std::function< void(std::shared_ptr< Message >)> CppHandler
the signature of a function that is called whenever a C++ nexuslua::agent receives a message
Definition cpp_handler.hpp:38
This type is used for the parameters of nexuslua::Message. In its serialized representation,...
Definition lua_table.hpp:54
result values of agents::UninstallPlugin
Definition plugin_install_result.hpp:45