xentara-plugin v2.0.4
The Xentara Plugin Framework
|
A reference to an event published by a Xentara element, including change events for attributes. More...
#include <xentara/process/ExtendedEvent.hpp>
Public Member Functions | |
ExtendedEvent ()=default | |
Constructor for a null reference. | |
ExtendedEvent (std::weak_ptr< const Event > event) | |
Creates a reference to a free-standing event. | |
ExtendedEvent (const model::ElementAttribute &attribute) | |
Creates a reference to an attribute change event. | |
ExtendedEvent (data::ReadHandle readHandle) | |
Creates a reference to an attribute change event. | |
ExtendedEvent (model::ElementAttribute attribute, UnpreparedTag tag) | |
Creates a reference to an attribute change event during loading of the model. | |
operator bool () const noexcept | |
Boolean operator. | |
auto | prepare () -> void |
Prepares a reference created during loading. | |
auto | addHandler (std::reference_wrapper< EventHandler > handler) const -> void |
Adds an event handler. | |
auto | removeHandler (std::reference_wrapper< EventHandler > handler) const -> void |
Removes an event handler. | |
Related Symbols | |
(Note that these are not member symbols.) | |
constexpr UnpreparedTag | kUnprepared |
A marker to specify that an extended event still needs to be prepared. | |
A reference to an event published by a Xentara element, including change events for attributes.
This is a convenience class that contains a weak reference to a free-standing event or to a change event for an attribute. You can use this class to add and remove event handler to and from events without having to worry about the type of event.
|
default |
Constructor for a null reference.
This constructor contstruct a null object that does not contain a reference to any event. You must assign avalid object to this object before using it.
xentara::process::ExtendedEvent::ExtendedEvent | ( | std::weak_ptr< const Event > | event | ) |
Creates a reference to a free-standing event.
event | The event to reference. Must not be a null pointer (but may be expired). |
xentara::process::ExtendedEvent::ExtendedEvent | ( | const model::ElementAttribute & | attribute | ) |
Creates a reference to an attribute change event.
attribute | A reference to attribute whose change event you want to reference. Must be a valid reference. |
std::runtime_error | The attribute does not support change events |
xentara::process::ExtendedEvent::ExtendedEvent | ( | data::ReadHandle | readHandle | ) |
Creates a reference to an attribute change event.
readHandle | A read handle to attribute whose change event you want to reference. Must be a valid handle. |
std::runtime_error | The read handle does not support change events |
xentara::process::ExtendedEvent::ExtendedEvent | ( | model::ElementAttribute | attribute, |
UnpreparedTag | tag | ||
) |
Creates a reference to an attribute change event during loading of the model.
This constructor is used to create an event reference is being during the loading process, before realize() has been call on the model’s elements.
Before using a reference created with this constructor, you must call prepare(). prepare() must be called at the earliest during the prepare() phase of loading, usually from within the prepare() callback of a Xentara element.
attribute | A reference to attribute whose change event you want to reference. Must be a valid reference. |
tag | Always pass kUnprepared as this parameter |
auto xentara::process::ExtendedEvent::addHandler | ( | std::reference_wrapper< EventHandler > | handler | ) | const -> void |
Adds an event handler.
This function adds the given handler to the contained event. It is safe to call this function on a null (default constructed) reference. For a null reference, the function simply does nothing.
If the reference was created during loading, either by passing kUnprepared to the [constructor()](ExtendedEvent(model::ElementAttribute, UnpreparedTag), or by resolving it using config::Resolver, then prepare() must be called befor calling addHandler().
handler | The handler |
std::logic_error | The reference was created using kUnprepared, but prepare() was not called. |
|
explicitnoexcept |
Boolean operator.
This operator checks whether the object is not a null reference.
auto xentara::process::ExtendedEvent::prepare | ( | ) | -> void |
Prepares a reference created during loading.
This function is used to prepare a reference that was created during loading, either by passing kUnprepared to the [constructor()](ExtendedEvent(model::ElementAttribute, UnpreparedTag), or by resolving it using config::Resolver. The function must be called at the earliest during the prepare() phase of loading, and should normally be called from within the prepare() callback of a Xentara element.
It is safe to call this function an any reference, even one that was not created using kUnprepared. For references that have already been prepared, or for references that do not need to be prepared, this function simple does nothing.
std::runtime_error | The event references an attribute that does not support change events |
auto xentara::process::ExtendedEvent::removeHandler | ( | std::reference_wrapper< EventHandler > | handler | ) | const -> void |
Removes an event handler.
This function removes the given handler from the contained event. It is safe to call this function on a null (default constructed) reference. For a null reference, the function simply does nothing.
handler | The handler. If the handler is not attached to the event, this function does nothing. |
|
related |
A marker to specify that an extended event still needs to be prepared.
This marker is used to specify that an extended event reference is being created during the loading process, before realize() has been call on the model’s elements.