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

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.

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.

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 where has_value() is true if the key exists and the variant value that it represents can be converted to type T. Otherwise returns an empty optional.

template<class T>
T getValueOr(RStringKey key, T &&defaultValue) const

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

RString eventName

The name of the event.

size_t numVariants

Number of items in the variants array member.

NamedVariant const *variants

An array of NamedVariant of length numVariants.