nexuslua
Loading...
Searching...
No Matches
nexuslua::LuaTable Struct Reference

This type is used for the parameters of nexuslua::Message. In its serialized representation, it can be passed to or returned by functions of shared libraries that are imported via nexuslua function import. It is the composition of a std::map of cbeam::container::xpod::type instances (cbeam::container::table_of_values) and a std::map of cbeam::container::nested_map instances (cbeam::container::nested_table). The std::variant cbeam::container::xpod::type which is used for keys and values is central to the functionality of nexuslua. More...

#include <lua_table.hpp>

Inheritance diagram for nexuslua::LuaTable:
Collaboration diagram for nexuslua::LuaTable:

Public Member Functions

 LuaTable ()=default
 construct empty LuaTable
 LuaTable (const cbeam::serialization::serialized_object serializedNestedMap)
 construct table from serialized void*
 LuaTable (const cbeam::container::nested_map< cbeam::container::xpod::type, cbeam::container::xpod::type > &baseInstance)
 construct LuaTable from an instance of its base class
void SetOriginalMessage (const std::shared_ptr< Message > originalMessage)
 Copies the given message into a sub table (cbeam::container::nested_map::sub_tables) with name "original_message". Its name is copied to key "message_name" and its parameters into a cbeam::container::nested_map::sub_tables entry "parameters".
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 automatic reply-to message with the return value of a function.
void SetReplyToAgentName (const std::string &agentName)
 only sets the entry "reply_to/agent" to the given name, leaves the "reply_to/message" unchanged
void SetReplyToMessageName (const std::string &messageName)
 only sets the entry "reply_to/message" to the given message name, leaves the "reply_to/agent" unchanged
std::string GetReplyToAgentNameOrEmpty () const
 if there is an entry "reply_to/agent", returns it, otherwise returns the empty string
std::string GetReplyToMessageNameOrEmpty () const
 if there is an entry "reply_to/message", returns it, otherwise returns the empty string
bool RequestsUnreplicatedReceiver () const
 return true if the table represents message parameters from a sender that requests that the message must be received by a non-replicated instance of the lua script that contains the message function
LuaTableBase GetTableToMergeWhenReplyingOrEmpty () const
 if there is a table entry "reply_to/merge", return it, otherwise an empty nexuslua::LuaTableBase

Static Protected Attributes

static constexpr std::string_view replyToTableId {"reply_to"}
 name of a cbeam::container::nested_map::sub_tables entry that stores the agent that a message shall reply to
static constexpr std::string_view tableToMergeWhenReplyingId {"merge"}
 name of a cbeam::container::nested_map::sub_tables entry that stores the agent that a message shall reply to
static constexpr std::string_view unreplicatedId {"unreplicated"}
 name of a data field that stores if the sender requests that the message must be received by a non-replicated instance of the lua script that contains the message function
static constexpr std::string_view agentNameId {"agent"}
 name of an entry in cbeam::serialization::serialized_object::data that stores the name of the agent that a message shall reply to
static constexpr std::string_view agentMessageId {"message"}
 name of an entry in cbeam::serialization::serialized_object::data that stores the name of the message that shall be sent in reply to a message

Detailed Description

This type is used for the parameters of nexuslua::Message. In its serialized representation, it can be passed to or returned by functions of shared libraries that are imported via nexuslua function import. It is the composition of a std::map of cbeam::container::xpod::type instances (cbeam::container::table_of_values) and a std::map of cbeam::container::nested_map instances (cbeam::container::nested_table). The std::variant cbeam::container::xpod::type which is used for keys and values is central to the functionality of nexuslua.

It serves the following purposes:

  • carry data inside nexuslua::Message instances, i.e. the data in an cbeam::serialization::serialized_object
  • interface between Lua code and C++ code (because these messages can be sent from Lua to Lua or between C++ and Lua)
  • pass data from and to functions of shared libraries that have been imported using import (by using data type cbeam::serialization::serialized_object, which is automatically serialized).

Constructor & Destructor Documentation

◆ LuaTable() [1/3]

nexuslua::LuaTable::LuaTable ( )
default

construct empty LuaTable

◆ LuaTable() [2/3]

nexuslua::LuaTable::LuaTable ( const cbeam::serialization::serialized_object serializedNestedMap)

construct table from serialized void*

◆ LuaTable() [3/3]

nexuslua::LuaTable::LuaTable ( const cbeam::container::nested_map< cbeam::container::xpod::type, cbeam::container::xpod::type > & baseInstance)

construct LuaTable from an instance of its base class

Member Function Documentation

◆ GetReplyToAgentNameOrEmpty()

std::string nexuslua::LuaTable::GetReplyToAgentNameOrEmpty ( ) const

if there is an entry "reply_to/agent", returns it, otherwise returns the empty string

◆ GetReplyToMessageNameOrEmpty()

std::string nexuslua::LuaTable::GetReplyToMessageNameOrEmpty ( ) const

if there is an entry "reply_to/message", returns it, otherwise returns the empty string

◆ GetTableToMergeWhenReplyingOrEmpty()

LuaTableBase nexuslua::LuaTable::GetTableToMergeWhenReplyingOrEmpty ( ) const

if there is a table entry "reply_to/merge", return it, otherwise an empty nexuslua::LuaTableBase

◆ RequestsUnreplicatedReceiver()

bool nexuslua::LuaTable::RequestsUnreplicatedReceiver ( ) const

return true if the table represents message parameters from a sender that requests that the message must be received by a non-replicated instance of the lua script that contains the message function

◆ SetOriginalMessage()

void nexuslua::LuaTable::SetOriginalMessage ( const std::shared_ptr< Message > originalMessage)

Copies the given message into a sub table (cbeam::container::nested_map::sub_tables) with name "original_message". Its name is copied to key "message_name" and its parameters into a cbeam::container::nested_map::sub_tables entry "parameters".

◆ SetReplyTo()

void nexuslua::LuaTable::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 automatic reply-to message with the return value of a function.

◆ SetReplyToAgentName()

void nexuslua::LuaTable::SetReplyToAgentName ( const std::string & agentName)

only sets the entry "reply_to/agent" to the given name, leaves the "reply_to/message" unchanged

◆ SetReplyToMessageName()

void nexuslua::LuaTable::SetReplyToMessageName ( const std::string & messageName)

only sets the entry "reply_to/message" to the given message name, leaves the "reply_to/agent" unchanged

Member Data Documentation

◆ agentMessageId

std::string_view nexuslua::LuaTable::agentMessageId {"message"}
staticconstexprprotected

name of an entry in cbeam::serialization::serialized_object::data that stores the name of the message that shall be sent in reply to a message

◆ agentNameId

std::string_view nexuslua::LuaTable::agentNameId {"agent"}
staticconstexprprotected

name of an entry in cbeam::serialization::serialized_object::data that stores the name of the agent that a message shall reply to

◆ replyToTableId

std::string_view nexuslua::LuaTable::replyToTableId {"reply_to"}
staticconstexprprotected

name of a cbeam::container::nested_map::sub_tables entry that stores the agent that a message shall reply to

◆ tableToMergeWhenReplyingId

std::string_view nexuslua::LuaTable::tableToMergeWhenReplyingId {"merge"}
staticconstexprprotected

name of a cbeam::container::nested_map::sub_tables entry that stores the agent that a message shall reply to

◆ unreplicatedId

std::string_view nexuslua::LuaTable::unreplicatedId {"unreplicated"}
staticconstexprprotected

name of a data field that stores if the sender requests that the message must be received by a non-replicated instance of the lua script that contains the message function


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