carb::events::LambdaEventListener

Defined in carb/events/EventsUtils.h

Inheritance Relationships

Base Type

class carb::events::LambdaEventListener : public carb::events::IEventListener

A helper to use a std::function as an carb::events::IEventListener.

Public Functions

inline LambdaEventListener(std::function<void(IEvent*)> fn)

Constructor.

Parameters

fn – The std::function to call when onEvent() is called.

inline virtual void onEvent(IEvent *e) override

Passes the event to the std::function given to the constructor.

Parameters

e – The carb::events::IEvent to process.

inline virtual size_t addRef() override

  • Atomically adds one to the reference count. *

Returns

The current reference count after one was added, though this value may change before read if other * threads are also modifying the reference count. The return value is guaranteed to be non-zero.

inline virtual size_t release() override

  • Atomically subtracts one from the reference count. If the result is zero, carb::deleteHandler() is called for * this. *

Returns

The current reference count after one was subtracted. If zero is returned, carb::deleteHandler() was * called for this.

Public Static Functions

static inline carb::InterfaceDesc getInterfaceDesc()

Returns

The carb::InterfaceDesc struct with information about this interface.