conduit 0.6.0
Modern C++23 header-only event-dispatching / event-transport library
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
conduit::EventEnvelope Class Reference

Polymorphic envelope cell. More...

#include <envelope.hpp>

Inheritance diagram for conduit::EventEnvelope:
Inheritance graph
[legend]
Collaboration diagram for conduit::EventEnvelope:
Collaboration graph
[legend]

Public Member Functions

 EventEnvelope ()
 
template<typename T >
requires std::derived_from<T, parcel::ICell>
 EventEnvelope (T payload)
 Build an envelope around a typed payload event.
 
 EventEnvelope (detail::EnvelopeCore core, parcel::cell_t payload)
 
 EventEnvelope (std::shared_ptr< detail::EnvelopeCore > core)
 
const ulid::Ulid & id () const noexcept
 
std::string_view name () const noexcept
 
const flags::FlagSetflags () const noexcept
 
const Metadatametadata () const noexcept
 
const Timestampstimestamps () const noexcept
 
const std::optional< ulid::Ulid > & correlation_id () const noexcept
 
const std::optional< ulid::Ulid > & causation_id () const noexcept
 
const parcel::cell_t & payload_cell () const noexcept
 
template<typename T >
std::shared_ptr< const T > payload_as () const noexcept
 Typed payload accessor: returns shared_ptr<const T> if the underlying payload is a T cell, or nullptr otherwise.
 
Timestampstimestamps () noexcept
 
Metadatametadata () noexcept
 
flags::FlagSetflags () noexcept
 
std::shared_ptr< detail::EnvelopeCorecore_ptr () const noexcept
 
bool valid () const noexcept
 
std::string to_string () const override
 
parcel::json_t to_json () const override
 
std::partial_ordering compare (parcel::ICell const &other) const override
 

Static Public Member Functions

static parcel::cell_t from_json (parcel::json_t const &j, parcel::ParcelRegistry const &reg)
 
static parcel::cell_type_descriptor_t descriptor ()
 

Static Public Attributes

static constexpr std::string_view kind_id = "conduit:envelope"
 

Detailed Description

Polymorphic envelope cell.

Holds bookkeeping (id, flags, metadata, timestamps, correlation/causation ids) plus a parcel::cell_t payload — so any registered event cell can ride inside the same envelope kind.

Storage is a shared_ptr<detail::EnvelopeCore> so copies share the same mutable core: transports that adjust timestamps()/metadata() on a local copy update the originating envelope as well.

Constructor & Destructor Documentation

◆ EventEnvelope() [1/4]

conduit::EventEnvelope::EventEnvelope ( )
inline

◆ EventEnvelope() [2/4]

template<typename T >
requires std::derived_from<T, parcel::ICell>
conduit::EventEnvelope::EventEnvelope ( payload)
inlineexplicit

Build an envelope around a typed payload event.

T must derive from conduit::Event<T, Name> (i.e. be an ICell-derived cell).

◆ EventEnvelope() [3/4]

conduit::EventEnvelope::EventEnvelope ( detail::EnvelopeCore  core,
parcel::cell_t  payload 
)
inline

◆ EventEnvelope() [4/4]

conduit::EventEnvelope::EventEnvelope ( std::shared_ptr< detail::EnvelopeCore core)
inlineexplicit

Member Function Documentation

◆ causation_id()

const std::optional< ulid::Ulid > & conduit::EventEnvelope::causation_id ( ) const
inlinenoexcept

◆ compare()

std::partial_ordering conduit::EventEnvelope::compare ( parcel::ICell const &  other) const
inlineoverride

◆ core_ptr()

std::shared_ptr< detail::EnvelopeCore > conduit::EventEnvelope::core_ptr ( ) const
inlinenoexcept

◆ correlation_id()

const std::optional< ulid::Ulid > & conduit::EventEnvelope::correlation_id ( ) const
inlinenoexcept

◆ descriptor()

static parcel::cell_type_descriptor_t conduit::EventEnvelope::descriptor ( )
inlinestatic

◆ flags() [1/2]

const flags::FlagSet & conduit::EventEnvelope::flags ( ) const
inlinenoexcept

◆ flags() [2/2]

flags::FlagSet & conduit::EventEnvelope::flags ( )
inlinenoexcept

◆ from_json()

parcel::cell_t conduit::EventEnvelope::from_json ( parcel::json_t const &  j,
parcel::ParcelRegistry const &  reg 
)
inlinestatic

◆ id()

const ulid::Ulid & conduit::EventEnvelope::id ( ) const
inlinenoexcept

◆ metadata() [1/2]

const Metadata & conduit::EventEnvelope::metadata ( ) const
inlinenoexcept

◆ metadata() [2/2]

Metadata & conduit::EventEnvelope::metadata ( )
inlinenoexcept

◆ name()

std::string_view conduit::EventEnvelope::name ( ) const
inlinenoexcept

◆ payload_as()

template<typename T >
std::shared_ptr< const T > conduit::EventEnvelope::payload_as ( ) const
inlinenoexcept

Typed payload accessor: returns shared_ptr<const T> if the underlying payload is a T cell, or nullptr otherwise.

◆ payload_cell()

const parcel::cell_t & conduit::EventEnvelope::payload_cell ( ) const
inlinenoexcept

◆ timestamps() [1/2]

const Timestamps & conduit::EventEnvelope::timestamps ( ) const
inlinenoexcept

◆ timestamps() [2/2]

Timestamps & conduit::EventEnvelope::timestamps ( )
inlinenoexcept

◆ to_json()

parcel::json_t conduit::EventEnvelope::to_json ( ) const
inlineoverride

◆ to_string()

std::string conduit::EventEnvelope::to_string ( ) const
inlineoverride

◆ valid()

bool conduit::EventEnvelope::valid ( ) const
inlinenoexcept

Member Data Documentation

◆ kind_id

constexpr std::string_view conduit::EventEnvelope::kind_id = "conduit:envelope"
staticconstexpr

The documentation for this class was generated from the following file: