107 #ifdef VLINK_SUPPORT_DDS
111 #include <shared_mutex>
116 #include "../base/functional.h"
117 #include "../extension/qos.h"
118 #include "../impl/conf.h"
120 namespace eprosima::fastdds::dds {
141 PropertiesMap qos_ext;
151 explicit DdsConf(
const std::string& _topic, int32_t _domain = 0, int32_t _depth = 0,
const std::string& _qos =
"");
165 explicit DdsConf(
const std::string& _topic, int32_t _domain,
const PropertiesMap& _qos_ext);
173 [[nodiscard]]
bool operator==(
const DdsConf& conf)
const noexcept;
181 [[nodiscard]]
bool operator!=(
const DdsConf& conf)
const noexcept;
188 [[nodiscard]]
TransportType get_transport_type()
const override;
201 [[nodiscard]]
static std::vector<std::tuple<std::string, std::string>> get_discovered_topics(int32_t _domain);
213 static bool load_global_qos_file(
const std::string& filepath);
229 template <
typename TypeSupportT,
typename TypeSupportRespT =
void>
230 static void register_topic(
const std::string& name);
243 template <
typename TypeSupportT,
typename TypeSupportRespT =
void>
244 static void register_url(
const std::string& name);
257 static void register_qos(
const std::string& name,
const Qos& qos);
260 template <
typename TypeSupportT>
261 static void register_topic_internal(
const std::string& name);
263 static void register_qos_internal(
const std::string& name,
const Qos& qos);
265 static Function<
void*()> find_type_support(
const std::string& name);
267 static const Qos& find_qos(
const std::string& name);
269 static std::string get_topic_for_url(
const std::string& url);
271 friend class DdsFactory;
272 static std::map<std::string, Function<
void*()>> type_support_map_;
273 static std::map<std::string, Qos> qos_map_;
274 static std::shared_mutex mtx_;
275 static constexpr
const char* kRespSuffix{
"___resp"};
276 #ifndef VLINK_ENABLE_C_INTERFACE
287 inline DdsConf::DdsConf(
const std::string& _topic, int32_t _domain, int32_t _depth,
const std::string& _qos)
288 : topic(_topic), domain(_domain), depth(_depth), qos(_qos) {}
290 inline DdsConf::DdsConf(
const std::string& _topic, int32_t _domain,
const PropertiesMap& _qos_ext)
291 : topic(_topic), domain(_domain), qos_ext(_qos_ext) {}
294 return topic == conf.topic && domain == conf.domain && depth == conf.depth && qos == conf.qos &&
295 qos_ext == conf.qos_ext;
298 inline bool DdsConf::operator!=(
const DdsConf& conf)
const noexcept {
return !(*
this == conf); }
300 inline TransportType DdsConf::get_transport_type()
const {
return TransportType::kDds; }
302 template <
typename TypeSupportT,
typename TypeSupportRespT>
303 inline void DdsConf::register_topic(
const std::string& name) {
304 std::lock_guard lock(mtx_);
305 register_topic_internal<TypeSupportT>(name);
306 if constexpr (!std::is_same_v<TypeSupportRespT, void>) {
307 register_topic_internal<TypeSupportRespT>(name + kRespSuffix);
311 template <
typename TypeSupportT,
typename TypeSupportRespT>
312 inline void DdsConf::register_url(
const std::string& name) {
313 register_topic<TypeSupportT, TypeSupportRespT>(get_topic_for_url(name));
316 template <
typename TypeSupportT>
317 inline void DdsConf::register_topic_internal(
const std::string& name) {
318 static_assert(std::is_base_of_v<eprosima::fastdds::dds::TopicDataType, TypeSupportT>,
"Must be dds type.");
320 type_support_map_[name] = [] {
return new TypeSupportT(); };
#define VLINK_CONF_IMPL(classname)
Convenience macro that emits the standard concrete conf boilerplate.
Definition: conf.h:250
#define VLINK_DECLARE_GLOBAL_PROPERTY()
Declares per-transport static configuration storage and access helpers.
Definition: conf.h:308
#define VLINK_ALLOW_IMPL_TYPE(type)
Records the bitmask of ImplType values supported by a conf.
Definition: conf.h:291
#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:1057
bool operator!=(const Function< ReturnT(ArgsT...), SboSizeT > &cb, std::nullptr_t) noexcept
Inequality with nullptr; true when cb stores a target.
Definition: functional.h:1067
TransportType
Enumeration of every transport backend recognised by VLink.
Definition: types.h:126
@ kGetter
Field getter (reads latest value).
Definition: types.h:115
@ kSubscriber
Event subscriber (receives broadcasts).
Definition: types.h:113
@ kClient
Method client (RPC caller).
Definition: types.h:111
@ kSetter
Field setter (writes latest value).
Definition: types.h:114
@ kPublisher
Event publisher (one-to-many broadcast).
Definition: types.h:112
@ kServer
Method server (RPC responder).
Definition: types.h:110