Class TopicTransport

Inheritance Relationships

Derived Type

Class Documentation

class TopicTransport

Port: topic publish + sample. Concrete adapter Ros2TopicTransport (src/ros2/transports/) implements it via rclcpp GenericPublisher / NativeTopicSampler.

Subclassed by ros2_medkit_gateway::ros2::Ros2TopicTransport

Public Functions

TopicTransport() = default
TopicTransport(const TopicTransport&) = delete
TopicTransport &operator=(const TopicTransport&) = delete
TopicTransport(TopicTransport&&) = delete
TopicTransport &operator=(TopicTransport&&) = delete
virtual ~TopicTransport() = default
virtual json publish(const std::string &topic_path, const std::string &msg_type, const json &data, std::chrono::duration<double> timeout) = 0

Publish JSON-encoded data to a topic. Implementations cache the underlying publisher keyed by (topic, type).

virtual TopicSample sample(const std::string &topic_name, std::chrono::duration<double> timeout) = 0

Sample a topic with timeout. Implementations fall back to metadata if no publisher is active. timeout < 0 means “use the implementation default”.

virtual std::pair<uint64_t, uint64_t> count_publishers_subscribers(const std::string &topic_name) const = 0

Publisher and subscriber count for a topic. Implementations may return stale data if the underlying graph snapshot is cached.

virtual ros2_medkit_serialization::TypeIntrospection *get_type_introspection() const = 0

Type-introspection helper used by handlers to enrich SOVD payloads with schema and default-value templates. The TypeIntrospection backend lives in ros2_medkit_serialization alongside the rest of the rosidl glue; transports own an instance so the manager body remains middleware-neutral.

Layering note: this is the one place where gateway_core’s public surface references a type defined in ros2_medkit_serialization. The dependency is intentional: TypeIntrospection is already middleware-agnostic (it operates on rosidl typesupport, not on rclcpp), and inventing a core::serialization::TypeIntrospection wrapper would duplicate the existing abstraction without changing the dependency graph. A mock transport that does not need schema introspection simply returns nullptr here.

May return nullptr in transports that do not support introspection (test mocks, alternative middlewares).