97 #include <type_traits>
99 #include "../base/exception.h"
100 #include "../base/macros.h"
140 [[nodiscard]] [[maybe_unused]]
static constexpr
bool is_for_writer(
Type type) noexcept {
150 [[nodiscard]] [[maybe_unused]]
static constexpr
bool is_for_reader(
Type type) noexcept {
201 template <
typename T>
202 [[nodiscard]] std::shared_ptr<T> as()
const;
251 using BasePtr = std::shared_ptr<Status::Base>;
266 template <
typename T>
268 static_assert(std::is_base_of_v<Base, T> && !std::is_same_v<struct Unknown, T>,
269 "Can not convert target status type.");
275 #if defined(NDEBUG) || defined(__ANDROID__)
276 return std::static_pointer_cast<T>(
const_cast<Base*
>(
this)->shared_from_this());
278 return std::dynamic_pointer_cast<T>(
const_cast<Base*
>(
this)->shared_from_this());
Generic runtime failure; thrown by the logger on kFatal messages.
Definition: exception.h:90
#define VUNLIKELY(...)
Short alias for VLINK_UNLIKELY.
Definition: macros.h:289
#define VLINK_EXPORT
Definition: macros.h:81
const void * InstanceHandle
Opaque transport-defined identifier for a matched publication or subscription.
Definition: status.h:161
VLINK_EXPORT std::ostream & operator<<(std::ostream &ostream, const BasePtr &status) noexcept
Writes the human-readable description of status to ostream.
Type
Discriminator that identifies the concrete Base subclass carried by an event.
Definition: status.h:118
@ kLivelinessLost
Writer liveliness assertion lapsed.
Definition: status.h:124
@ kOfferedDeadlineMissed
Writer missed its offered publication deadline.
Definition: status.h:122
@ kRequestedDeadlineMissed
Reader missed its requested deadline.
Definition: status.h:127
@ kSubscriptionMatched
Matching publisher appeared or disappeared.
Definition: status.h:126
@ kSampleRejected
Inbound sample dropped by resource limits.
Definition: status.h:129
@ kUnknown
Placeholder for unrecognised status events.
Definition: status.h:119
@ kOfferedIncompatibleQos
Discovered subscriber with incompatible QoS.
Definition: status.h:123
@ kRequestedIncompatibleQos
Discovered publisher with incompatible QoS.
Definition: status.h:130
@ kSampleLost
Sample lost before delivery.
Definition: status.h:131
@ kLivelinessChanged
Liveliness of a matched publisher changed.
Definition: status.h:128
@ kPublicationMatched
Matching subscriber appeared or disappeared.
Definition: status.h:121
std::shared_ptr< Status::Base > BasePtr
Shared-pointer alias used as the parameter type of every status callback.
Definition: status.h:251
Polymorphic base for every concrete status event delivered to a callback.
Definition: status.h:173
std::shared_ptr< T > as() const
Safely narrows this event to a concrete Status subclass.
Definition: status.h:267
VLINK_EXPORT friend std::ostream & operator<<(std::ostream &ostream, const Base &status) noexcept
Writes the human-readable description of status to ostream.
virtual std::string get_string() const =0
Returns the event name without numeric fields.
virtual Type get_type() const =0
Returns the concrete event type discriminator.
Placeholder event emitted when the transport reports a status the runtime cannot map.
Definition: status.h:222
VLINK_EXPORT friend std::ostream & operator<<(std::ostream &ostream, const Unknown &status) noexcept
Writes "Unknown" to ostream.
Type get_type() const override
Returns kUnknown.
std::string get_string() const override
Returns the literal "Unknown".