.. _program_listing_file_foxglove_include_foxglove_channel.hpp: Program Listing for File channel.hpp ==================================== |exhale_lsh| :ref:`Return to documentation for file ` (``foxglove/include/foxglove/channel.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #pragma once #include #include #include #include #include #include #include #include #include #include #include #include namespace foxglove { class ChannelDescriptor { const foxglove_channel_descriptor* channel_descriptor_; public: explicit ChannelDescriptor(const foxglove_channel_descriptor* channel_descriptor); [[nodiscard]] uint64_t id() const noexcept; [[nodiscard]] std::string_view topic() const noexcept; [[nodiscard]] std::string_view messageEncoding() const noexcept; // NOLINTNEXTLINE(readability-identifier-naming) [[deprecated("Use messageEncoding() instead")]] [[nodiscard]] std::string_view message_encoding( ) const noexcept { return messageEncoding(); } [[nodiscard]] std::optional> metadata() const noexcept; [[nodiscard]] std::optional schema() const noexcept; }; class SinkChannelFilterFn { public: SinkChannelFilterFn() = default; template< typename F, typename = std::enable_if_t< std::is_invocable_r_v && !std::is_same_v, SinkChannelFilterFn>>> // NOLINTNEXTLINE(google-explicit-constructor,hicpp-explicit-conversions) SinkChannelFilterFn(F&& fn) : fn_(std::forward(fn)) {} template< typename F, typename = std::enable_if_t< std::is_invocable_r_v && !std::is_invocable_v && !std::is_same_v, SinkChannelFilterFn>>, typename /*Disambiguate*/ = void> [[deprecated( "Use a filter function taking const ChannelDescriptor& instead of ChannelDescriptor&&" )]] // NOLINTNEXTLINE(google-explicit-constructor,hicpp-explicit-conversions) SinkChannelFilterFn(F&& fn) : fn_([f = std::forward(fn)](const ChannelDescriptor& ch) mutable { auto copy = ch; return f(std::move(copy)); }) {} explicit operator bool() const { return static_cast(fn_); } bool operator()(const ChannelDescriptor& channel) const { return fn_(channel); } private: std::function fn_; }; class RawChannel final { public: static FoxgloveResult create( const std::string_view& topic, const std::string_view& message_encoding, std::optional schema = std::nullopt, const Context& context = Context(), std::optional> metadata = std::nullopt ); FoxgloveError log( const std::byte* data, size_t data_len, std::optional log_time = std::nullopt, std::optional sink_id = std::nullopt ) noexcept; void close() noexcept; [[nodiscard]] uint64_t id() const noexcept; [[nodiscard]] std::string_view topic() const noexcept; [[nodiscard]] std::string_view messageEncoding() const noexcept; // NOLINTNEXTLINE(readability-identifier-naming) [[deprecated("Use messageEncoding() instead")]] [[nodiscard]] std::string_view message_encoding( ) const noexcept { return messageEncoding(); } [[nodiscard]] bool hasSinks() const noexcept; // NOLINTNEXTLINE(readability-identifier-naming) [[deprecated("Use hasSinks() instead")]] [[nodiscard]] bool has_sinks() const noexcept { return hasSinks(); } [[nodiscard]] std::optional schema() const noexcept; [[nodiscard]] std::optional> metadata() const noexcept; RawChannel(const RawChannel&) = delete; RawChannel& operator=(const RawChannel&) = delete; RawChannel(RawChannel&& other) noexcept = default; RawChannel& operator=(RawChannel&& other) noexcept = default; ~RawChannel() = default; private: explicit RawChannel(const foxglove_channel* channel); messages::ChannelUniquePtr impl_; }; } // namespace foxglove