$darkmode
data_broker.hpp File Reference
#include <any>
#include <cassert>
#include <functional>
#include <map>
#include <memory>
#include <regex>
#include <stdexcept>
#include <string_view>
#include <typeindex>
#include <vector>
#include <fmt/format.h>
#include <sol/sol.hpp>
Include dependency graph for data_broker.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  cloe::databroker::detail::has_to_lua< T, typename >
 
struct  cloe::databroker::detail::has_to_lua< T, std::void_t< decltype(to_lua(std::declval< sol::state_view >(), std::declval< T * >()))> >
 
struct  cloe::databroker::type_t_or_int_if< T, condition >
 
struct  cloe::databroker::type_t_or_int_if< T, false >
 
class  cloe::databroker::Event< TArgs >
 
class  cloe::BasicContainer< T >
 
class  cloe::MetaInformation
 
struct  cloe::MetaInformation::Tag< T >
 
struct  cloe::SignalDocumentation
 
struct  cloe::LuaAutocompletionTag
 
class  cloe::Signal
 
class  cloe::TypedSignal< T >
 
class  cloe::DataBroker
 
struct  cloe::DataBroker::SignalsObject::LuaAccessorFactory< T >
 
struct  cloe::DataBroker::SignalsObject::LuaAccessorFactory< std::optional< T > >
 
struct  cloe::databroker::DynamicName
 
struct  cloe::databroker::StaticName< NAME >
 
struct  cloe::databroker::SignalDescriptorBase< T, TNAME, bool >
 
struct  cloe::databroker::SignalDescriptorBase< T, TNAME, true >
 
struct  cloe::databroker::SignalDescriptorBase< T, TNAME, false >
 
struct  cloe::databroker::SignalDescriptorImpl< T, NAME >
 
struct  cloe::databroker::SignalDescriptorImpl< T, nullptr >
 
struct  cloe::databroker::SignalDescriptor< T, NAME >
 
struct  cloe::databroker::SignalTemplate< T, NAME >
 

Macros

#define CLOE_DATA_BROKER_HPP_
 
#define LUADATATYPE_LIST
 
#define X(name, value)   name = value,
 
#define X(name, value)
 
#define PHYSICALQUANTITIES_LIST
 
#define X(name, value)   name,
 
#define X(name, value)
 
#define CLOE_DATABROKER_TEMPLATE_INSTANTIATION(elem)
 
#define CLOE_DATABROKER_TEMPLATE_INSTANTATION_TYPES()
 

Typedefs

template<typename T >
using cloe::databroker::compatible_base_t = typename type_t_or_int_if< T, !is_incompatible_type_v< T > >::type
 
template<typename T >
using cloe::databroker::signal_type_cref_t = databroker::compatible_base_t< T > const &
 
template<typename T >
using cloe::databroker::on_value_changed_callback_t = std::function< void(signal_type_cref_t< T >)>
 
using cloe::lua_signal_adapter_t = std::function< void(const SignalPtr &, sol::state_view, std::string_view)>
 
using cloe::lua_signal_declarator_t = std::function< void(sol::state_view)>
 
template<typename T >
using cloe::Container = BasicContainer< databroker::compatible_base_t< T > >
 

Functions

template<typename T >
void cloe::databroker::detail::to_lua (sol::state_view lua)
 
template<typename T >
constexpr void cloe::assert_static_type ()
 
template<typename T , typename U >
constexpr bool cloe::operator== (const BasicContainer< T > &lhs, const BasicContainer< U > &rhs)
 
template<typename T , typename U >
constexpr bool cloe::operator!= (const BasicContainer< T > &lhs, const BasicContainer< U > &rhs)
 
template<typename T , typename U >
constexpr bool cloe::operator< (const BasicContainer< T > &lhs, const BasicContainer< U > &rhs)
 
template<typename T , typename U >
constexpr bool cloe::operator<= (const BasicContainer< T > &lhs, const BasicContainer< U > &rhs)
 
template<typename T , typename U >
constexpr bool cloe::operator> (const BasicContainer< T > &lhs, const BasicContainer< U > &rhs)
 
template<typename T , typename U >
constexpr bool cloe::operator>= (const BasicContainer< T > &lhs, const BasicContainer< U > &rhs)
 
template<typename T , typename U >
constexpr bool cloe::operator== (const BasicContainer< T > &lhs, const U &rhs)
 
template<typename T , typename U >
constexpr bool cloe::operator== (const T &lhs, const BasicContainer< U > &rhs)
 
template<typename T , typename U >
constexpr bool cloe::operator!= (const BasicContainer< T > &lhs, const U &rhs)
 
template<typename T , typename U >
constexpr bool cloe::operator!= (const T &lhs, const BasicContainer< U > &rhs)
 
template<typename T , typename U >
constexpr bool cloe::operator< (const BasicContainer< T > &lhs, const U &rhs)
 
template<typename T , typename U >
constexpr bool cloe::operator< (const T &lhs, const BasicContainer< U > &rhs)
 
template<typename T , typename U >
constexpr bool cloe::operator<= (const BasicContainer< T > &lhs, const U &rhs)
 
template<typename T , typename U >
constexpr bool cloe::operator<= (const T &lhs, const BasicContainer< U > &rhs)
 
template<typename T , typename U >
constexpr bool cloe::operator> (const BasicContainer< T > &lhs, const U &rhs)
 
template<typename T , typename U >
constexpr bool cloe::operator> (const T &lhs, const BasicContainer< U > &rhs)
 
template<typename T , typename U >
constexpr bool cloe::operator>= (const BasicContainer< T > &lhs, const U &rhs)
 
template<typename T , typename U >
constexpr bool cloe::operator>= (const T &lhs, const BasicContainer< U > &rhs)
 

Variables

template<typename T >
constexpr bool cloe::databroker::detail::has_to_lua_v = has_to_lua<T>::value
 
template<typename T >
constexpr bool cloe::databroker::is_incompatible_type_v = std::is_void_v<T> || std::is_reference_v<T>
 

Detailed Description

Classes: DataBroker: A central registry for (type erased) signals.

Signal: A type-erased abstraction of a signal.

BasicContainer<T> An optional container storing the value of a signal and abstracting the interaction with Signal.

Background: Real world simulations utilize manifolds of signals (variables) and coresponding types. Still the very basic problem around a single signal (variable) boils down to CRUD

  • declaring a signal (Create)
  • reading its value / receiving value-changed events (Read)
  • writing its value / triggering value-changed events (Update)
  • NOT NEEDED: undeclaring a signal (Delete)

Concept: Abstract CRU(D) operations by registering signals in a uniform way by their name.

Macro Definition Documentation

◆ CLOE_DATABROKER_TEMPLATE_INSTANTIATION

#define CLOE_DATABROKER_TEMPLATE_INSTANTIATION (   elem)
Value:
extern template class BasicContainer<elem>; \
extern template const Signal::typed_get_value_function_t<elem>* Signal::getter<elem>() const; \
extern template void Signal::set_getter<elem>(Signal::typed_get_value_function_t<elem>); \
extern template databroker::signal_type_cref_t<elem> Signal::value<elem>() const; \
extern template const Signal::typed_set_value_function_t<elem>* Signal::setter<elem>() const; \
extern template void Signal::set_setter<elem>(Signal::typed_set_value_function_t<elem>); \
extern template void Signal::set_value<elem>(databroker::signal_type_cref_t<elem> value) const; \
extern template const Signal::typed_on_value_change_event_function_t<elem>& \
Signal::trigger<elem>() const; \
extern template void Signal::subscribe_impl<elem>( \
const std::function<void(databroker::Event<databroker::signal_type_cref_t<elem>>&)>&); \
extern template void Signal::subscribe<elem>(databroker::on_value_changed_callback_t<elem>); \
extern template std::unique_ptr<Signal> Signal::make<elem>(); \
extern template BasicContainer<elem> Signal::create_container<elem>(); \
extern template void Signal::initialize<elem>(); \
extern template SignalPtr DataBroker::declare<elem>(std::string_view); \
extern template BasicContainer<elem> DataBroker::implement<elem>(std::string_view); \
extern template void DataBroker::subscribe<elem>(std::string_view, \
databroker::on_value_changed_callback_t<elem>); \
extern template databroker::signal_type_cref_t<elem> DataBroker::value<elem>(std::string_view); \
extern template const Signal::typed_get_value_function_t<elem>& DataBroker::getter<elem>( \
std::string_view name); \
extern template void DataBroker::set_value<elem>(std::string_view, \
databroker::signal_type_cref_t<elem>); \
extern template const Signal::typed_set_value_function_t<elem>& DataBroker::setter<elem>( \
std::string_view name);

◆ LUADATATYPE_LIST

#define LUADATATYPE_LIST
Value:
X(Class, 0) \
X(Number, 1) \
X(String, 2)

X-Macro: enum definition & enum-to-string conversion

◆ PHYSICALQUANTITIES_LIST

#define PHYSICALQUANTITIES_LIST
Value:
X(Dimensionless, "[]") \
X(Radian, "[rad]") \
X(Length, "[m]") \
X(Time, "[s]") \
X(Mass, "[kg]") \
X(Temperature, "[K]") \
X(ElectricCurrent, "[A]") \
X(Velocity, "[m/s]") \
X(Acceleration, "[m/s^2]") \
X(Jerk, "[m/s^3]") \
X(Jounce, "[m/s^4]") \
X(Crackle, "[m/s^5]")

X-Macro: enum definition & enum-to-string conversion

◆ X [1/2]

#define X (   name,
  value 
)
Value:
case LuaDatatype::name: \
return #name;

◆ X [2/2]

#define X (   name,
  value 
)
Value:
case PhysicalQuantity::name: \
return #value;

Typedef Documentation

◆ compatible_base_t

template<typename T >
using cloe::databroker::compatible_base_t = typedef typename type_t_or_int_if<T, !is_incompatible_type_v<T> >::type

Determines a datatype which is compatible with the data broker, derived from the template type.

Returns
T, if T is compatible with the data broker; int, otherwise
Note
Purpose is to suppress irrelevant compiler errors, in case of incompatible data types

◆ lua_signal_adapter_t

using cloe::lua_signal_adapter_t = typedef std::function<void(const SignalPtr&, sol::state_view, std::string_view)>

Function which integrates a specific datum into the Lua-VM

◆ lua_signal_declarator_t

using cloe::lua_signal_declarator_t = typedef std::function<void(sol::state_view)>

Function which declares a specific datatype to the Lua-VM

◆ on_value_changed_callback_t

template<typename T >
using cloe::databroker::on_value_changed_callback_t = typedef std::function<void(signal_type_cref_t<T>)>

Type of event function, which is called when the value of a signal changed

◆ signal_type_cref_t

template<typename T >
using cloe::databroker::signal_type_cref_t = typedef databroker::compatible_base_t<T> const&

Argument-/Return-Type of signal related functions

Function Documentation

◆ assert_static_type()

template<typename T >
constexpr void cloe::assert_static_type ( )
constexpr

Assert that the type-argument is compatible with the data broker.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ to_lua()

template<typename T >
void cloe::databroker::detail::to_lua ( sol::state_view  lua)

Invokes to_lua procedure, if detecting its presence

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ has_to_lua_v

template<typename T >
constexpr bool cloe::databroker::detail::has_to_lua_v = has_to_lua<T>::value
constexpr

Detects the presence of the to_lua function (based on ADL)

◆ is_incompatible_type_v

template<typename T >
constexpr bool cloe::databroker::is_incompatible_type_v = std::is_void_v<T> || std::is_reference_v<T>
constexpr

Predicate which determines whether a type is incompatible with the data broker.