update to match ROS2 Dashing interface
passes a decent subset of the tests ... fixes: * sequences of simple types: remove accidental alignment * trigger graph guard on any built-in topic * create a participant for each node, with node name/namespace in user data It is still only a proof-of-concept, but it might now actually be usable ...
This commit is contained in:
parent
e520cb4d63
commit
24726b4685
4 changed files with 328 additions and 67 deletions
|
@ -17,6 +17,8 @@
|
|||
|
||||
#include <cassert>
|
||||
#include <memory>
|
||||
#include <regex>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "rmw_cyclonedds_cpp/MessageTypeSupport.hpp"
|
||||
|
@ -31,9 +33,16 @@ MessageTypeSupport<MembersType>::MessageTypeSupport(const MembersType * members)
|
|||
assert(members);
|
||||
this->members_ = members;
|
||||
|
||||
std::string name = std::string(members->package_name_) + "::msg::dds_::" +
|
||||
members->message_name_ + "_";
|
||||
this->setName(name.c_str());
|
||||
std::ostringstream ss;
|
||||
std::string message_namespace(this->members_->message_namespace_);
|
||||
std::string message_name(this->members_->message_name_);
|
||||
if (!message_namespace.empty()) {
|
||||
// Find and replace C namespace separator with C++, in case this is using C typesupport
|
||||
message_namespace = std::regex_replace(message_namespace, std::regex("__"), "::");
|
||||
ss << message_namespace << "::";
|
||||
}
|
||||
ss << "dds_::" << message_name << "_";
|
||||
this->setName(ss.str().c_str());
|
||||
}
|
||||
|
||||
} // namespace rmw_cyclonedds_cpp
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#define RMW_CYCLONEDDS_CPP__SERVICETYPESUPPORT_IMPL_HPP_
|
||||
|
||||
#include <cassert>
|
||||
#include <regex>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "rmw_cyclonedds_cpp/ServiceTypeSupport.hpp"
|
||||
|
@ -36,9 +38,16 @@ RequestTypeSupport<ServiceMembersType, MessageMembersType>::RequestTypeSupport(
|
|||
assert(members);
|
||||
this->members_ = members->request_members_;
|
||||
|
||||
std::string name = std::string(members->package_name_) + "::srv::dds_::" +
|
||||
members->service_name_ + "_Request_";
|
||||
this->setName(name.c_str());
|
||||
std::ostringstream ss;
|
||||
std::string service_namespace(members->service_namespace_);
|
||||
std::string service_name(members->service_name_);
|
||||
if (!service_namespace.empty()) {
|
||||
// Find and replace C namespace separator with C++, in case this is using C typesupport
|
||||
service_namespace = std::regex_replace(service_namespace, std::regex("__"), "::");
|
||||
ss << service_namespace << "::";
|
||||
}
|
||||
ss << "dds_::" << service_name << "_Request_";
|
||||
this->setName(ss.str().c_str());
|
||||
}
|
||||
|
||||
template<typename ServiceMembersType, typename MessageMembersType>
|
||||
|
@ -48,9 +57,17 @@ ResponseTypeSupport<ServiceMembersType, MessageMembersType>::ResponseTypeSupport
|
|||
assert(members);
|
||||
this->members_ = members->response_members_;
|
||||
|
||||
std::string name = std::string(members->package_name_) + "::srv::dds_::" +
|
||||
members->service_name_ + "_Response_";
|
||||
this->setName(name.c_str());
|
||||
|
||||
std::ostringstream ss;
|
||||
std::string service_namespace(members->service_namespace_);
|
||||
std::string service_name(members->service_name_);
|
||||
if (!service_namespace.empty()) {
|
||||
// Find and replace C namespace separator with C++, in case this is using C typesupport
|
||||
service_namespace = std::regex_replace(service_namespace, std::regex("__"), "::");
|
||||
ss << service_namespace << "::";
|
||||
}
|
||||
ss << "dds_::" << service_name << "_Response_";
|
||||
this->setName(ss.str().c_str());
|
||||
}
|
||||
|
||||
} // namespace rmw_cyclonedds_cpp
|
||||
|
|
|
@ -85,12 +85,14 @@ public:
|
|||
}
|
||||
|
||||
#define SIMPLEA(T) inline void serializeA (const T *x, size_t cnt) { \
|
||||
if ((off % sizeof (T)) != 0) { \
|
||||
off += sizeof (T) - (off % sizeof (T)); \
|
||||
if (cnt > 0) { \
|
||||
if ((off % sizeof (T)) != 0) { \
|
||||
off += sizeof (T) - (off % sizeof (T)); \
|
||||
} \
|
||||
resize (off + cnt * sizeof (T)); \
|
||||
memcpy (data () + off, (void *) x, cnt * sizeof (T)); \
|
||||
off += cnt * sizeof (T); \
|
||||
} \
|
||||
resize (off + cnt * sizeof (T)); \
|
||||
memcpy (data () + off, (void *) x, cnt * sizeof (T)); \
|
||||
off += cnt * sizeof (T); \
|
||||
}
|
||||
SIMPLEA (char);
|
||||
SIMPLEA (int8_t);
|
||||
|
@ -111,7 +113,7 @@ public:
|
|||
template<class T> inline void serialize (const std::vector<T>& x)
|
||||
{
|
||||
serialize (static_cast<uint32_t> (x.size ()));
|
||||
if (x.size () > 0) serializeA (x.data (), x.size ());
|
||||
serializeA (x.data (), x.size ());
|
||||
}
|
||||
inline void serialize (const std::vector<bool>& x) {
|
||||
serialize (static_cast<uint32_t> (x.size ()));
|
||||
|
@ -121,7 +123,7 @@ public:
|
|||
template<class T> inline void serializeS (const T *x, size_t cnt)
|
||||
{
|
||||
serialize (static_cast<uint32_t> (cnt));
|
||||
if (cnt > 0) serializeA (x, cnt);
|
||||
serializeA (x, cnt);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -192,9 +194,11 @@ public:
|
|||
}
|
||||
|
||||
#define SIMPLEA(T) inline void deserializeA (T *x, size_t cnt) { \
|
||||
align (sizeof (T)); \
|
||||
memcpy ((void *) x, (void *) (data + pos), (cnt) * sizeof (T)); \
|
||||
pos += (cnt) * sizeof (T); \
|
||||
if (cnt > 0) { \
|
||||
align (sizeof (T)); \
|
||||
memcpy ((void *) x, (void *) (data + pos), (cnt) * sizeof (T)); \
|
||||
pos += (cnt) * sizeof (T); \
|
||||
} \
|
||||
}
|
||||
SIMPLEA (char);
|
||||
SIMPLEA (int8_t);
|
||||
|
@ -215,7 +219,7 @@ public:
|
|||
template<class T> inline void deserialize (std::vector<T>& x) {
|
||||
const uint32_t sz = deserialize32 ();
|
||||
x.resize (sz);
|
||||
if (sz > 0) deserializeA (x.data (), sz);
|
||||
deserializeA (x.data (), sz);
|
||||
}
|
||||
inline void deserialize (std::vector<bool>& x) {
|
||||
const uint32_t sz = deserialize32 ();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue