$darkmode
cloe::DataBroker Class Reference

#include <data_broker.hpp>

Public Types

using SignalContainer = std::map< std::string, SignalPtr, std::less<> >
 

Public Member Functions

 DataBroker (const sol::state_view &lua)
 
 DataBroker (const DataBroker &)=delete
 
 DataBroker (DataBroker &&)=delete
 
DataBrokeroperator= (const DataBroker &)=delete
 
DataBrokeroperator= (DataBroker &&)=delete
 
template<typename T >
void declare_type (lua_signal_declarator_t type_declarator)
 Declares a DataType to Lua (if not yet done) More...
 
void bind_signal (std::string_view signal_name, std::string_view lua_name)
 Binds a signal to the Lua-VM. More...
 
void bind_signal (std::string_view signal_name)
 Binds a signal to the Lua-VM. More...
 
void bind (std::string_view signals_name, sol::table parent)
 Binds the signals-object to Lua. More...
 
void bind (std::string_view signals_name)
 
const SignalContainer::const_iterator operator[] (std::string_view name) const
 
SignalContainer::iterator operator[] (std::string_view name)
 
SignalPtr alias (SignalPtr signal, std::string_view new_name)
 
SignalPtr alias (std::string_view old_name, std::string_view new_name, std::regex::flag_type f=std::regex_constants::ECMAScript)
 
template<typename T >
SignalPtr declare (std::string_view name)
 
template<typename T >
SignalPtr declare (std::string_view name, T *value_ptr)
 
template<typename T >
SignalPtr declare (std::string_view name, std::function< T()> getter, std::function< void(T)> setter)
 
template<typename T >
Container< databroker::compatible_base_t< T > > implement (std::string_view new_name)
 
SignalPtr signal (std::string_view name) const
 
SignalPtr signal (std::string_view name)
 
const SignalContainer & signals () const
 
SignalContainer & signals ()
 
template<typename T >
void subscribe (std::string_view name, databroker::on_value_changed_callback_t< T > callback)
 
template<typename T >
void set_value (std::string_view name, databroker::signal_type_cref_t< T > value)
 
template<typename T >
databroker::signal_type_cref_t< T > value (std::string_view name) const
 
template<typename T >
const Signal::typed_get_value_function_t< T > & getter (std::string_view name) const
 
template<typename T >
void set_getter (std::string_view name, const Signal::typed_get_value_function_t< T > &getter_fn)
 
template<typename T >
const Signal::typed_set_value_function_t< T > & setter (std::string_view name) const
 
template<typename T >
void set_setter (std::string_view name, const Signal::typed_set_value_function_t< T > &setter_fn)
 

Detailed Description

Registry for type-erased signals.

Member Function Documentation

◆ alias() [1/2]

SignalPtr cloe::DataBroker::alias ( SignalPtr  signal,
std::string_view  new_name 
)
inline

Give an existing signal an alias.

Parameters
signalSignal to be named
new_nameNew name of the signal
Returns
Pointer to the signal
Note
If an exception is thrown by any operation, the aliasing has no effect.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ alias() [2/2]

SignalPtr cloe::DataBroker::alias ( std::string_view  old_name,
std::string_view  new_name,
std::regex::flag_type  f = std::regex_constants::ECMAScript 
)
inline

Give an existing signal a (new) name.

Parameters
old_nameName of the existing signal
new_nameNew name of the signal
fflag_type flags used to guide the interpretation of the character sequence as a regular expression
Returns
Pointer to the signal
Note
If an exception is thrown by any operation, the aliasing has no effect.
Here is the call graph for this function:

◆ bind()

void cloe::DataBroker::bind ( std::string_view  signals_name,
sol::table  parent 
)
inline

Binds the signals-object to Lua.

Parameters
signals_nameName which shall be used for the table
parent_tableParent-table to use

◆ bind_signal() [1/2]

void cloe::DataBroker::bind_signal ( std::string_view  signal_name)
inline

Binds a signal to the Lua-VM.

Parameters
signal_nameName of the signal
Note
The bind-method needs to be invoked at least once (in total) to bring all signal bindings into effect
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bind_signal() [2/2]

void cloe::DataBroker::bind_signal ( std::string_view  signal_name,
std::string_view  lua_name 
)
inline

Binds a signal to the Lua-VM.

Parameters
signal_nameName of the signal
lua_nameName of the table/variable used in Lua
Note
The bind-method needs to be invoked at least once (in total) to bring all signal bindings into effect
Here is the call graph for this function:

◆ declare() [1/2]

template<typename T >
SignalPtr cloe::DataBroker::declare ( std::string_view  name)
inline

Declare a new signal.

Template Parameters
TType of the signal
Parameters
nameName of the signal
Returns
Pointer to the specified signal
Here is the call graph for this function:

◆ declare() [2/2]

template<typename T >
SignalPtr cloe::DataBroker::declare ( std::string_view  name,
T *  value_ptr 
)
inline

Declare a new signal and auto-implement getter and setter.

Template Parameters
Ttype of the signal value
Parameters
namename of the signal
value_ptrpointer to signal value
Returns
pointer to specified signal
Here is the call graph for this function:

◆ declare_type()

template<typename T >
void cloe::DataBroker::declare_type ( lua_signal_declarator_t  type_declarator)
inline

Declares a DataType to Lua (if not yet done)

Note
: The function can be used independent of a bound Lua instance
Here is the caller graph for this function:

◆ getter()

template<typename T >
const Signal::typed_get_value_function_t<T>& cloe::DataBroker::getter ( std::string_view  name) const
inline

Return the getter-function of a signal.

Template Parameters
TType of the signal
Parameters
nameName of the signal
Returns
getter-function of the signal
Here is the call graph for this function:
Here is the caller graph for this function:

◆ implement()

template<typename T >
Container<databroker::compatible_base_t<T> > cloe::DataBroker::implement ( std::string_view  new_name)
inline

Declare a new signal.

Template Parameters
TType of the signal
Parameters
nameName of the signal
Returns
Container<T> storing the signal value
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator[]() [1/2]

SignalContainer::iterator cloe::DataBroker::operator[] ( std::string_view  name)
inline

Return the signal with the given name.

Parameters
nameName of the signal
Returns
Signal with the given name

◆ operator[]() [2/2]

const SignalContainer::const_iterator cloe::DataBroker::operator[] ( std::string_view  name) const
inline

Return the signal with the given name.

Parameters
nameName of the signal
Returns
Signal with the given name

◆ set_getter()

template<typename T >
void cloe::DataBroker::set_getter ( std::string_view  name,
const Signal::typed_get_value_function_t< T > &  getter_fn 
)
inline

Sets the getter-function of a signal.

Template Parameters
TType of the signal
Parameters
nameName of the signal
getter_fngetter-function of the signal
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_setter()

template<typename T >
void cloe::DataBroker::set_setter ( std::string_view  name,
const Signal::typed_set_value_function_t< T > &  setter_fn 
)
inline

Sets the setter-function of a signal.

Template Parameters
TType of the signal
Parameters
nameName of the signal
getter_fnsetter-function of the signal
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_value()

template<typename T >
void cloe::DataBroker::set_value ( std::string_view  name,
databroker::signal_type_cref_t< T >  value 
)
inline

Set the value of a signal.

Template Parameters
TType of the signal
Parameters
nameName of the signal
valueValue to be assigned to the signal
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setter()

template<typename T >
const Signal::typed_set_value_function_t<T>& cloe::DataBroker::setter ( std::string_view  name) const
inline

Return the setter-function of a signal.

Template Parameters
TType of the signal
Parameters
nameName of the signal
Returns
const Signal::typed_set_value_function_t<T>&, setter-function of the signal
Here is the call graph for this function:
Here is the caller graph for this function:

◆ signal() [1/2]

SignalPtr cloe::DataBroker::signal ( std::string_view  name)
inline

Return the signal with the given name.

Parameters
nameName of the signal
Returns
Signal with the given name

◆ signal() [2/2]

SignalPtr cloe::DataBroker::signal ( std::string_view  name) const
inline

Return the signal with the given name.

Parameters
nameName of the signal
Returns
Signal with the given name
Here is the caller graph for this function:

◆ signals() [1/2]

SignalContainer& cloe::DataBroker::signals ( )
inline

Return all signals.

Here is the call graph for this function:

◆ signals() [2/2]

const SignalContainer& cloe::DataBroker::signals ( ) const
inline

Return all signals.

Here is the caller graph for this function:

◆ subscribe()

template<typename T >
void cloe::DataBroker::subscribe ( std::string_view  name,
databroker::on_value_changed_callback_t< T >  callback 
)
inline

Subscribe to value-changed events.

Template Parameters
TType of the signal
Parameters
nameName of the signal
callbackevent-function which will be called when the value changed
Here is the call graph for this function:

◆ value()

template<typename T >
databroker::signal_type_cref_t<T> cloe::DataBroker::value ( std::string_view  name) const
inline

Return the value of a signal.

Template Parameters
TType of the signal
Parameters
nameName of the signal
Returns
Pointer to the value of the signal
Note
databroker::compatible_base_t<T> == T, if the function compiles
Here is the call graph for this function:
Here is the caller graph for this function:

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