|
lintel 0.2.0
|
#include <Event.h>
Public Member Functions | |
| Event ()=default | |
| Event (const std::string &topic, const std::string &type) | |
| void | setTopic (const std::string &topic) |
| void | setType (const std::string &type) |
| const char * | topic () const |
| const char * | type () const |
| void | setSequence (std::int64_t sequence) |
| std::int64_t | sequence () const |
| void | setTimestamp (std::int64_t timestamp) |
| std::int64_t | timestamp () const |
| void | setContent (const std::byte *data, std::size_t size) |
| template<typename T > | |
| void | assign (const T &content) |
| template<typename T > | |
| T | as () const |
| std::size_t | contentLength () const |
| const std::byte * | content () const |
| bool | isContentEmpty () const |
Static Public Attributes | |
| static constexpr std::size_t | NAME_SIZE = 32 |
| static constexpr std::size_t | CONTENT_SIZE = 256 |
A fixed-size, trivially copyable event that is exchanged over the EventBus.
The event is a POD-like value type: it is safe to store it inside the lock-free shared memory queues and to copy it between processes. The sizes of the topic/type identifiers and of the payload buffer are compile-time constants (matching the "configurable fixed slots" design decision); the queue capacities and topic/subscriber counts are configured at runtime.
|
default |
Default constructor; zero-initializes the event.
Construct an event with topic and type set.
| topic | identifier of the channel this event belongs to |
| type | identifier of the event type |
Convert the content buffer back into an object of type T.
| T | target type |
Assign an object of type T to the reserved content space. Warning: T must be trivially copyable and must not exceed CONTENT_SIZE.
| T | type of the object |
| content | object which gets copied into the content buffer |
|
inline |
|
inline |
|
inline |
|
inline |
Copy a payload of given size into the content buffer.
| data | pointer to the payload (may be nullptr when size is zero) |
| size | number of bytes to copy; clamped to CONTENT_SIZE |
|
inline |
Set the monotonically increasing sequence number.
| sequence | the sequence number |
|
inline |
Set the creation timestamp (Unix epoch seconds).
| timestamp | the timestamp |
Set the topic (truncated to NAME_SIZE).
| topic | the topic name |
Set the type (truncated to NAME_SIZE).
| type | the type name |
|
inline |
|
staticconstexpr |
Maximum payload size in bytes.
|
staticconstexpr |
Maximum length of the topic/subscriber name, including the terminator.