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:
trueif the key is contained in the Event,falseotherwise.
-
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;
nullptrotherwise. 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
optionalvalue wherehas_value()istrueif 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
variantsarray member.
-
NamedVariant const *variants#
An array of NamedVariant of length
numVariants.
-
inline constexpr Event() noexcept#