nexuslua
Loading...
Searching...
No Matches
nexuslua::agents Class Reference

Functions related to agents or plugins, which are (un-)installable agents with meta data like a version, see class nexuslua::Agent. More...

#include <agents.hpp>

Inheritance diagram for nexuslua::agents:
Collaboration diagram for nexuslua::agents:

Public Member Functions

 agents ()
virtual ~agents ()
void DeleteAgents ()
const std::map< std::string, std::shared_ptr< const Agent > > & GetPlugins ()
 key is plugin name, same as AgentPlugin::GetName()
void InvalidatePluginScan ()
 after calling this function, the next call to agents::GetPlugins will rescan the plugin directory
PluginInstallResult InstallPlugin (const std::filesystem::path &srcFolder, std::string &errorMessage)
 user selects a directory with a plugin to be installed. This function installs it. In case of ERROR_WHILE_CREATING_INSTANCE, errorMessage will contain an English error description
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. In case of ERROR_WHILE_CREATING_INSTANCE, errorMessage will contain an English error description
PluginUninstallResult UninstallPlugin (const std::string &name)
 the name is identical with 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
const AgentMessageGetMessage (const std::string &agentName, const std::string &messageName)
 return the given message
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 nexuslua send, or nexuslua::AgentMessage::Send
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
std::shared_ptr< AgentGetAgent (const std::string &agentName)
 returns the Agent instance associated with the given agent name, or nullptr if there is no such agent
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.
void WaitUntilMessageQueueIsEmpty ()
 wait until the nexuslua agents processed all remaining messages
void ShutdownAgents ()
 if the main application quits, it should use this function to make sure all threads have ended before the main function returned or the shared library is being unloaded

Static Public Member Functions

static int64_t TotalSizeOfMessagesQueues ()

Detailed Description

Functions related to agents or plugins, which are (un-)installable agents with meta data like a version, see class nexuslua::Agent.

Constructor & Destructor Documentation

◆ agents()

nexuslua::agents::agents ( )

◆ ~agents()

virtual nexuslua::agents::~agents ( )
virtual

Member Function Documentation

◆ Add() [1/2]

std::shared_ptr< AgentCpp > nexuslua::agents::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 nexuslua send, or nexuslua::AgentMessage::Send

Parameters
agentNamethe name of the agent to be added
cppHandlerthe handler for the agent, which needs to have the signature CppHandler
predefinedTablecan be used to predefine arbitrary Lua tables, e. g. the default table arg containing command line arguments of the Lua executable
Returns
a shared pointer to the newly added agent

◆ Add() [2/2]

std::shared_ptr< AgentLua > nexuslua::agents::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

Parameters
agentNamethe name of the agent to be added
pathToLuaFileeither the path of the Lua file that shall be used to handle messages, or the path to the Lua file that contains the luaCode given in the third parameter
luaCodeoptional Lua code as string that shall be used to handle messages to this agent
predefinedTablecan be used to predefine arbitrary Lua tables, e. g. the default table arg containing command line arguments of the Lua executable

◆ AddMessageForCppAgent()

void nexuslua::agents::AddMessageForCppAgent ( const std::string & agentName,
const std::string & messageName )

registers a message for an nexuslua::Agent that has been created via nexuslua::agents::Add.

Parameters
agentNamethe name of the agent for which the message shall be registered
messageNamethe name of the new message

◆ DeleteAgents()

void nexuslua::agents::DeleteAgents ( )

◆ GetAgent()

std::shared_ptr< Agent > nexuslua::agents::GetAgent ( const std::string & agentName)

returns the Agent instance associated with the given agent name, or nullptr if there is no such agent

Parameters
agentNamethe name of the agent to be added
Returns
the Agent instance associated with agentName, or nullptr if there is no such agent

◆ GetMessage()

const AgentMessage & nexuslua::agents::GetMessage ( const std::string & agentName,
const std::string & messageName )

return the given message

◆ GetPlugins()

const std::map< std::string, std::shared_ptr< const Agent > > & nexuslua::agents::GetPlugins ( )

key is plugin name, same as AgentPlugin::GetName()

◆ InstallPlugin() [1/2]

PluginInstallResult nexuslua::agents::InstallPlugin ( const std::filesystem::path & srcFolder,
std::string & errorMessage )

user selects a directory with a plugin to be installed. This function installs it. In case of ERROR_WHILE_CREATING_INSTANCE, errorMessage will contain an English error description

◆ InstallPlugin() [2/2]

PluginInstallResult nexuslua::agents::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. In case of ERROR_WHILE_CREATING_INSTANCE, errorMessage will contain an English error description

◆ InvalidatePluginScan()

void nexuslua::agents::InvalidatePluginScan ( )

after calling this function, the next call to agents::GetPlugins will rescan the plugin directory

◆ RestorePersistentPluginFolder()

void nexuslua::agents::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

◆ ShutdownAgents()

void nexuslua::agents::ShutdownAgents ( )

if the main application quits, it should use this function to make sure all threads have ended before the main function returned or the shared library is being unloaded

◆ TotalSizeOfMessagesQueues()

int64_t nexuslua::agents::TotalSizeOfMessagesQueues ( )
static

◆ UninstallPlugin()

PluginUninstallResult nexuslua::agents::UninstallPlugin ( const std::string & name)

the name is identical with AgentPlugin::GetName()

◆ WaitUntilMessageQueueIsEmpty()

void nexuslua::agents::WaitUntilMessageQueueIsEmpty ( )

wait until the nexuslua agents processed all remaining messages


The documentation for this class was generated from the following file: