#include <data_broker.hpp>
|
|
template<typename T > |
| class | BasicContainer |
| |
|
class | DataBroker |
| |
Signal represents the properties of a signal at runtime
- Note
- : Design-Goals:
-
: Implementation-Notes:
- Implementation-#1: Type specific aspects are implemented in templates (Design-#1)
- Implementation-#2: Objects are created via a factory-method (to prevent instances of incomplete initialization)
- Implementation-#3: An access-token is used to have a public c'tor which in fact shall be inaccesible (Design-#2).
◆ typed_get_value_function_t
Getter-function types
Note: When implementing this function with lamdas (e.g. set_getter<>() ) take care to explicitly define the return-type.
Example: []() -> const int& { return value; }
Undefined behaviour: []() { return value; } ^^^ No return type specified
◆ typed_on_value_change_event_function_t
Event trigger-function types
◆ typed_set_value_function_t
◆ typed_value_changed_event_t
◆ Signal()
| cloe::Signal::Signal |
( |
access_token |
| ) |
|
|
inlineexplicit |
Public c'tor, accessible only via private access-token
- Note
- : Design-#1: The class shall be constructible via external helpers
◆ add() [1/3]
template<typename T >
| std::enable_if_t< std::is_void_v<typename T::tag_type> > cloe::Signal::add |
( |
| ) |
|
|
inline |
Tags a signal with a void tag
- Template Parameters
-
◆ add() [2/3]
template<typename T , typename... TArgs>
| std::enable_if_t<!std::is_void_v<typename T::tag_type> > cloe::Signal::add |
( |
TArgs &&... |
args | ) |
|
|
inline |
Tags a signal with metadata constructed from parameters
- Template Parameters
-
| T | Type of the tag |
| TArgs | Type of the metadata c'tor parameters |
- Parameters
-
| args | Metadata c'tor arguments |
- Note
- This is the overload for non-void tags (T2 != void)
◆ add() [3/3]
template<typename T >
| std::enable_if_t<!std::is_void_v<typename T::tag_type> > cloe::Signal::add |
( |
typename T::tag_type |
metadata | ) |
|
|
inline |
Tags a signal with metadata
- Template Parameters
-
- Parameters
-
| metadata | Metadata used to tag the signal |
- Note
- This is the overload for non-void tags (T2 != void)
◆ add_name()
| void cloe::Signal::add_name |
( |
std::string_view |
name | ) |
|
|
inline |
Add a name of the signal.
- Parameters
-
◆ getter()
Return the getter function of the signal.
- Template Parameters
-
- Returns
- Getter function of the signal
Example:
Signal s = ...;
const typed_get_value_function_t<int>* f = s.getter<int>();
int v = (*f)();
◆ has_subscriber()
| bool cloe::Signal::has_subscriber |
( |
| ) |
const |
|
inline |
Indicate whether the value_changed event has subscribers.
- Returns
- bool True if the value_changed event has subscribers, false otherwise
◆ metadata()
template<typename T >
| auto cloe::Signal::metadata |
( |
| ) |
-> decltype(metainformations_.get<T>()) |
|
inline |
Get a tag of the signal
- Template Parameters
-
- Returns
- const typename T::tag_type* pointing to the tag-value (or nullptr), if typename T::tag_type != void
-
bool expressing the presence of the tag, if typename T::tag_type == void
◆ metadatas()
Get all tags of the signal
◆ name()
| const std::string& cloe::Signal::name |
( |
| ) |
const |
|
inline |
Return the first assigned name of the signal.
- Returns
- First name of the signal
◆ name_or()
| std::string cloe::Signal::name_or |
( |
std::string |
def | ) |
const |
|
inline |
Return the first assigned name of the signal.
- Returns
- First name of the signal
◆ names()
| const std::vector<std::string>& cloe::Signal::names |
( |
| ) |
const |
|
inline |
Return the list of names assigned to the signal.
- Returns
- List of names assigned to the signal
◆ set_getter()
Set the getter function of the signal.
- Template Parameters
-
- Parameters
-
| get_value | Getter function of the signal |
Example:
Signal s = ...;
constexpr const std::type_info * type() const
Definition: data_broker.hpp:790
databroker::signal_type_cref_t< T > value() const
Definition: data_broker.hpp:870
Usage Note: When using lambdas, the explicit return-type definition is important!
Undefined behaviour:
Signal s = ...;
^^^ No
return type specified,
type conversion rules apply
◆ set_setter()
Set the setter function of the signal.
- Template Parameters
-
- Parameters
-
| set_value | Getter function of the signal |
◆ set_value()
Set the value of the signal.
- Template Parameters
-
- Parameters
-
◆ setter()
Return the getter function of the signal.
- Template Parameters
-
- Returns
- const typed_set_value_function_t<T>*, Getter function of the signal
◆ subscribe()
Subscribe to value-changed events.
- Template Parameters
-
- Parameters
-
| callback | event-function which will be called when the value changed |
◆ subscriber_count()
| std::size_t cloe::Signal::subscriber_count |
( |
| ) |
const |
|
inline |
Return the count of subscribers to the value_changed event.
- Returns
- size_t Count of subscribers to the value_changed event
◆ trigger()
Return the trigger function for the value_changed event.
- Template Parameters
-
- Returns
- Trigger function for raising the value_changed event
◆ type()
| constexpr const std::type_info* cloe::Signal::type |
( |
| ) |
const |
|
inlineconstexpr |
Return the type info for the signal.
◆ value()
Return the current value of the signal.
- Template Parameters
-
- Returns
- databroker::signal_type_cref_t<T>, Current value of the signal
- Note
- databroker::compatible_base_t<T> == T, if the method compiles
The documentation for this class was generated from the following file:
- /home/docs/checkouts/readthedocs.org/user_builds/cloe/checkouts/develop/runtime/include/cloe/data_broker.hpp