Event#
Fully qualified name: carb::eventdispatcher::Event
Defined in carb/eventdispatcher/EventDispatcherTypes.h
-
class Event : public carb::eventdispatcher::EventData#
A presentation class for EventData. Allows querying the data via a simple C++ interface.
Public Functions
-
inline constexpr Event() noexcept#
Default constructor.
-
inline bool hasKey(RStringKey key) const#
Returns true if an Event contains the requested key.
- Parameters:
key – The key to query.
- Returns:
true
if the key is contained in the Event,false
otherwise.
-
inline const variant::Variant *get(RStringKey key) const#
Returns a variant value from the event by key.
- Parameters:
key – The key to query.
- Returns:
A variant::Variant representing the item if the key is present;
nullptr
otherwise. The lifetime of the returned pointer is the same as*this
.
-
template<class T>
cpp::optional<T> getValue(RStringKey key) const# Retrieves a value from the Event by key.
- Template Parameters:
T – The requested type to convert the value to.
- Parameters:
key – The key to query.
- Returns:
An
optional
value wherehas_value()
istrue
if the key exists and the variant value that it represents can be converted to typeT
. Otherwise returns an emptyoptional
.
-
template<class T>
T getValueOr( - RStringKey key,
- T &&defaultValue,
Retrieves a value from the Event by key, or a fallback value.
Effectively the same as
getValue<T>(key).value_or(defaultValue)
- Template Parameters:
T – The requested type to convert the value to.
- Parameters:
key – The key to query.
defaultValue – A value to return if the key does not exist or is not convertible to
T
.
Public Members
-
size_t numVariants#
Number of items in the
variants
array member.
-
NamedVariant const *variants#
An array of NamedVariant of length
numVariants
.
-
inline constexpr Event() noexcept#