106 #ifdef VLINK_SUPPORT_DDS
110 #include <shared_mutex>
115 #include "../base/functional.h"
116 #include "../extension/qos.h"
117 #include "../impl/conf.h"
119 namespace eprosima::fastdds::dds {
140 PropertiesMap qos_ext;
150 explicit DdsConf(
const std::string& _topic, int32_t _domain = 0, int32_t _depth = 0,
const std::string& _qos =
"");
164 explicit DdsConf(
const std::string& _topic, int32_t _domain,
const PropertiesMap& _qos_ext);
172 [[nodiscard]]
bool operator==(
const DdsConf& conf)
const noexcept;
180 [[nodiscard]]
bool operator!=(
const DdsConf& conf)
const noexcept;
187 [[nodiscard]]
TransportType get_transport_type()
const override;
200 [[nodiscard]]
static std::vector<std::tuple<std::string, std::string>> get_discovered_topics(int32_t _domain);
212 static bool load_global_qos_file(
const std::string& filepath);
227 template <
typename TypeSupportT,
typename TypeSupportRespT =
void>
228 static void register_topic(
const std::string& name);
241 template <
typename TypeSupportT,
typename TypeSupportRespT =
void>
242 static void register_url(
const std::string& name);
255 static void register_qos(
const std::string& name,
const Qos& qos);
258 template <
typename TypeSupportT>
259 static void register_topic_internal(
const std::string& name);
261 static void register_qos_internal(
const std::string& name,
const Qos& qos);
263 static Function<
void*()> find_type_support(
const std::string& name);
265 static const Qos& find_qos(
const std::string& name);
267 static std::string get_topic_for_url(
const std::string& url);
269 friend class DdsFactory;
270 static std::map<std::string, Function<
void*()>> type_support_map_;
271 static std::map<std::string, Qos> qos_map_;
272 static std::shared_mutex mtx_;
273 static constexpr
const char* kRespSuffix{
"___resp"};
274 #ifndef VLINK_ENABLE_C_INTERFACE
285 inline DdsConf::DdsConf(
const std::string& _topic, int32_t _domain, int32_t _depth,
const std::string& _qos)
286 : topic(_topic), domain(_domain), depth(_depth), qos(_qos) {}
288 inline DdsConf::DdsConf(
const std::string& _topic, int32_t _domain,
const PropertiesMap& _qos_ext)
289 : topic(_topic), domain(_domain), qos_ext(_qos_ext) {}
292 return topic == conf.topic && domain == conf.domain && depth == conf.depth && qos == conf.qos &&
293 qos_ext == conf.qos_ext;
296 inline bool DdsConf::operator!=(
const DdsConf& conf)
const noexcept {
return !(*
this == conf); }
298 inline TransportType DdsConf::get_transport_type()
const {
return TransportType::kDds; }
300 template <
typename TypeSupportT,
typename TypeSupportRespT>
301 inline void DdsConf::register_topic(
const std::string& name) {
302 std::lock_guard lock(mtx_);
303 register_topic_internal<TypeSupportT>(name);
304 if constexpr (!std::is_same_v<TypeSupportRespT, void>) {
305 register_topic_internal<TypeSupportRespT>(name + kRespSuffix);
309 template <
typename TypeSupportT,
typename TypeSupportRespT>
310 inline void DdsConf::register_url(
const std::string& name) {
311 register_topic<TypeSupportT, TypeSupportRespT>(get_topic_for_url(name));
314 template <
typename TypeSupportT>
315 inline void DdsConf::register_topic_internal(
const std::string& name) {
316 static_assert(std::is_base_of_v<eprosima::fastdds::dds::TopicDataType, TypeSupportT>,
"Must be dds type.");
318 type_support_map_[name] = [] {
return new TypeSupportT(); };
#define VLINK_CONF_IMPL(classname)
Convenience macro that emits the standard concrete conf boilerplate.
Definition: conf.h:251
#define VLINK_DECLARE_GLOBAL_PROPERTY()
Declares per-transport static configuration storage and access helpers.
Definition: conf.h:309
#define VLINK_ALLOW_IMPL_TYPE(type)
Records the bitmask of ImplType values supported by a conf.
Definition: conf.h:292
#define VLINK_EXPORT
Definition: macros.h:81
bool operator==(const Function< ReturnT(ArgsT...), SboSizeT > &cb, std::nullptr_t) noexcept
Equality with nullptr; true when cb has no stored target.
Definition: functional.h:1051
bool operator!=(const Function< ReturnT(ArgsT...), SboSizeT > &cb, std::nullptr_t) noexcept
Inequality with nullptr; true when cb stores a target.
Definition: functional.h:1061
TransportType
Enumeration of every transport backend recognised by VLink.
Definition: types.h:128
@ kGetter
Field getter (reads latest value).
Definition: types.h:117
@ kSubscriber
Event subscriber (receives broadcasts).
Definition: types.h:115
@ kClient
Method client (RPC caller).
Definition: types.h:113
@ kSetter
Field setter (writes latest value).
Definition: types.h:116
@ kPublisher
Event publisher (one-to-many broadcast).
Definition: types.h:114
@ kServer
Method server (RPC responder).
Definition: types.h:112