xentara-plugin v2.0.4
The Xentara Plugin Framework
|
A free-standing event provided by an element. More...
#include <xentara/process/Event.hpp>
Classes | |
class | Role |
A built-in event role. More... | |
Public Member Functions | |
Event ()=default | |
Constructor for a regular event. | |
Event (const Role &role) | |
Constructor for an event with a certain role. | |
Event (io::Directions ioDirections) | |
Constructor for an I/O event. | |
internal auto | ioDirections () const -> io::Directions |
Gets the relevant I/O directions. | |
auto | setIoDirections (io::Directions ioDirections) -> void |
Sets the relevant I/O directions. | |
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. | |
auto | raise (std::chrono::system_clock::time_point eventTime) const noexcept -> void |
Raises the event. | |
Depracated functions | |
Event (const model::Attribute &attribute) | |
deprecated Deprecated constructor for an attribute change event | |
Event (const model::Attribute::Role &attributeRole) | |
deprecated Deprecated constructor for an attribute change event | |
auto | fire (std::chrono::system_clock::time_point eventTime=std::chrono::system_clock::now()) const -> void |
deprecated Deprecated alias for raise() | |
Public Member Functions inherited from xentara::utils::tools::DisableCopy | |
constexpr | DisableCopy () noexcept=default |
DisableCopy (const DisableCopy &)=delete | |
DisableCopy & | operator= (const DisableCopy &)=delete |
Static Public Member Functions | |
template<std::same_as< Event >... Events> requires (sizeof...(Events) > 0) | |
static auto | raise (std::chrono::system_clock::time_point eventTime, const Events &... events) noexcept -> void |
Raises a list of events atomically. | |
static auto | raise (std::chrono::system_clock::time_point eventTime, std::span< std::reference_wrapper< const Event > > events) noexcept -> void |
Raises a list of events atomically. | |
Static Public Attributes | |
Standard Roles | |
static const Role | kChanged |
The standard role for the change event of a data point. | |
static const Role | kConnected |
The standard role for the connection event of an I/O component. | |
static const Role | kDisconnected |
The standard role for the disconnection event of an I/O component. | |
A free-standing event provided by an element.
This class is used by xentara elements to publish so called “free-standing” events, i.e. events that are not change events for attributes. Change events for attributes are published automatically, and do not use process::Event. They can be accessed using ExtendedEvent, or using data::ReadHandle.
|
default |
Constructor for a regular event.
xentara::process::Event::Event | ( | const Role & | role | ) |
Constructor for an event with a certain role.
This constructor marks this event as an event with a particular role. If the role is a role for an I/O event, the event is markes as such.
role | The event role. |
xentara::process::Event::Event | ( | io::Directions | ioDirections | ) |
Constructor for an I/O event.
ioDirections | The relevant I/O directions. |
The I/O directions are used for I/O events to specify whether a data point should inherit this event from its attached input and/or output. If the directions contain the flag io::Direction::Input, then the data point will inherit this event from its input. If the directions contain the flag io::Direction::Output, then the data point will inherit this event from its output. If you do not set either flag (the default), then the event will not be considered an I/O event and will not be inherited by any data points. This is equivalent to calling the default constructor.
xentara::process::Event::Event | ( | const model::Attribute & | attribute | ) |
deprecated Deprecated constructor for an attribute change event
xentara::process::Event::Event | ( | const model::Attribute::Role & | attributeRole | ) |
deprecated Deprecated constructor for an attribute change event
auto xentara::process::Event::addHandler | ( | std::reference_wrapper< EventHandler > | handler | ) | const -> void |
Adds an event handler.
handler | The handler |
auto xentara::process::Event::fire | ( | std::chrono::system_clock::time_point | eventTime = std::chrono::system_clock::now() | ) | const -> void |
deprecated Deprecated alias for raise()
internal auto xentara::process::Event::ioDirections | ( | ) | const -> io::Directions |
Gets the relevant I/O directions.
|
noexcept |
Raises the event.
This function raises the event asynchronously and returns immediately.
Do not use this function to raise the event as a result of committing a write sentinel. Pass the event to the commit() function of the write sentinel instead. This raises the event atomically together with the change events generated by the write sentinel.
If you need to raise multiple events as the result of the same action, use one of the static overloads of this function instead. The events will then be raised atomically as a block.
eventTime | The (canonical) time the event occurred |
|
staticnoexcept |
Raises a list of events atomically.
This function raises all the events atomically. This means, that first, handleEvent() is called for all the handlers of all the events, and then postHandleEvent() is called for all the handlers of all the events. This is different than firing the events separately, where handleEvent() and postHandleEvent() are called for each event in turn.
For example, if you have two handlers, handlerA1 and handlerA2 attached to “Event A”, and two further two handlers, handlerB1 and handlerB2 attached to “Event B”, then the handlers will be executed in the following order:
This allows handlers to implement behaviour that handle all the events together.
eventTime | The (canonical) time the event occurred |
events | The events to trigger |
|
staticnoexcept |
Raises a list of events atomically.
This function raises all the events atomically. This means, that first, handleEvent() is called for all the handlers of all the events, and then postHandleEvent() is called for all the handlers of all the events. This is different than firing the events separately, where handleEvent() and postHandleEvent() are called for each event in turn.
For example, if you have two handlers, handlerA1 and handlerA2 attached to “Event A”, and two further two handlers, handlerB1 and handlerB2 attached to “Event B”, then the handlers will be executed in the following order:
This allows handlers to implement behaviour that handle all the events together.
eventTime | The (canonical) time the event occurred |
events | The events to trigger |
auto xentara::process::Event::removeHandler | ( | std::reference_wrapper< EventHandler > | handler | ) | const -> void |
Removes an event handler.
handler | The handler. If the handler is not attached to the event, this function does nothing. |
auto xentara::process::Event::setIoDirections | ( | io::Directions | ioDirections | ) | -> void |
Sets the relevant I/O directions.
ioDirections | The desired I/O directions. The I/O directions are used for I/O events to specify whether a data point should inherit this event from its attached input and/or output. |
|
static |
The standard role for the change event of a data point.
|
static |
The standard role for the connection event of an I/O component.
|
static |
The standard role for the disconnection event of an I/O component.