Skip to content

Commit

Permalink
Refactor to use DDS standard API (#518)
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Co-authored-by: Miguel Barro <miguelbarro@eprosima.com>
Co-authored-by: EduPonz <eduardoponz@eprosima.com>
  • Loading branch information
3 people committed Apr 6, 2021
1 parent ae4485e commit 29050bf
Show file tree
Hide file tree
Showing 95 changed files with 3,328 additions and 1,762 deletions.
4 changes: 2 additions & 2 deletions rmw_fastrtps_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ find_package(rmw_fastrtps_shared_cpp REQUIRED)

find_package(fastrtps_cmake_module REQUIRED)
find_package(fastcdr REQUIRED CONFIG)
find_package(fastrtps REQUIRED CONFIG)
find_package(FastRTPS REQUIRED MODULE)
find_package(fastrtps 2.3 REQUIRED CONFIG)
find_package(FastRTPS 2.3 REQUIRED MODULE)

find_package(rmw REQUIRED)
find_package(rosidl_runtime_c REQUIRED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
#ifndef RMW_FASTRTPS_CPP__SERVICETYPESUPPORT_HPP_
#define RMW_FASTRTPS_CPP__SERVICETYPESUPPORT_HPP_

#include <fastcdr/FastBuffer.h>
#include <fastcdr/Cdr.h>
#include <cassert>

#include "fastcdr/FastBuffer.h"
#include "fastcdr/Cdr.h"

#include "rosidl_typesupport_fastrtps_cpp/message_type_support.h"
#include "rosidl_typesupport_fastrtps_cpp/service_type_support.h"

Expand Down
13 changes: 6 additions & 7 deletions rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/TypeSupport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@
#ifndef RMW_FASTRTPS_CPP__TYPESUPPORT_HPP_
#define RMW_FASTRTPS_CPP__TYPESUPPORT_HPP_

#include <rosidl_runtime_c/string.h>
#include <rosidl_runtime_c/string_functions.h>

#include <fastrtps/TopicDataType.h>

#include <fastcdr/FastBuffer.h>
#include <fastcdr/Cdr.h>
#include <cassert>
#include <string>

#include "rosidl_runtime_c/string.h"
#include "rosidl_runtime_c/string_functions.h"

#include "fastcdr/Cdr.h"
#include "fastcdr/FastBuffer.h"

#include "rosidl_typesupport_fastrtps_cpp/message_type_support.h"

#include "rmw_fastrtps_shared_cpp/TypeSupport.hpp"
Expand Down
21 changes: 11 additions & 10 deletions rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/get_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,36 @@
#ifndef RMW_FASTRTPS_CPP__GET_CLIENT_HPP_
#define RMW_FASTRTPS_CPP__GET_CLIENT_HPP_

#include "fastrtps/publisher/Publisher.h"
#include "fastrtps/subscriber/Subscriber.h"
#include "fastdds/dds/publisher/DataWriter.hpp"
#include "fastdds/dds/subscriber/DataReader.hpp"

#include "rmw/rmw.h"
#include "rmw_fastrtps_cpp/visibility_control.h"

namespace rmw_fastrtps_cpp
{

/// Return a native FastRTPS publisher handle for the request.
/// Return a native Fast DDS DataWriter handle for the request.
/**
* The function returns `NULL` when either the client handle is `NULL` or
* when the client handle is from a different rmw implementation.
*
* \return native FastRTPS publisher handle if successful, otherwise `NULL`
* \return native Fast DDS DataWriter handle if successful, otherwise `NULL`
*/
RMW_FASTRTPS_CPP_PUBLIC
eprosima::fastrtps::Publisher *
get_request_publisher(rmw_client_t * client);
eprosima::fastdds::dds::DataWriter *
get_request_datawriter(rmw_client_t * client);

/// Return a native FastRTPS subscriber handle for the response.
/// Return a native Fast DDS DataReader handle for the response.
/**
* The function returns `NULL` when either the client handle is `NULL` or
* when the client handle is from a different rmw implementation.
*
* \return native FastRTPS subscriber handle if successful, otherwise `NULL`
* \return native Fast DDS DataReader handle if successful, otherwise `NULL`
*/
RMW_FASTRTPS_CPP_PUBLIC
eprosima::fastrtps::Subscriber *
get_response_subscriber(rmw_client_t * client);
eprosima::fastdds::dds::DataReader *
get_response_datareader(rmw_client_t * client);

} // namespace rmw_fastrtps_cpp

Expand Down
13 changes: 7 additions & 6 deletions rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/get_participant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,24 @@
#ifndef RMW_FASTRTPS_CPP__GET_PARTICIPANT_HPP_
#define RMW_FASTRTPS_CPP__GET_PARTICIPANT_HPP_

#include "fastrtps/participant/Participant.h"
#include "fastdds/dds/domain/DomainParticipant.hpp"

#include "rmw/rmw.h"
#include "rmw_fastrtps_cpp/visibility_control.h"

namespace rmw_fastrtps_cpp
{

/// Return a native FastRTPS participant handle.
/// Return a native Fast DDS DomainParticipant handle.
/**
* The function returns `NULL` when either the node handle is `NULL` or when the
* This function returns `NULL` when either the node handle is `NULL` or when the
* node handle is from a different rmw implementation.
*
* \return native FastRTPS participant handle if successful, otherwise `NULL`
* \return native Fast DDS DomainParticipant handle if successful, otherwise `NULL`
*/
RMW_FASTRTPS_CPP_PUBLIC
eprosima::fastrtps::Participant *
get_participant(rmw_node_t * node);
eprosima::fastdds::dds::DomainParticipant *
get_domain_participant(rmw_node_t * node);

} // namespace rmw_fastrtps_cpp

Expand Down
11 changes: 6 additions & 5 deletions rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/get_publisher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,24 @@
#ifndef RMW_FASTRTPS_CPP__GET_PUBLISHER_HPP_
#define RMW_FASTRTPS_CPP__GET_PUBLISHER_HPP_

#include "fastrtps/publisher/Publisher.h"
#include "fastdds/dds/publisher/DataWriter.hpp"

#include "rmw/rmw.h"
#include "rmw_fastrtps_cpp/visibility_control.h"

namespace rmw_fastrtps_cpp
{

/// Return a native FastRTPS publisher handle.
/// Return a native Fast DDS DataWriter handle.
/**
* The function returns `NULL` when either the publisher handle is `NULL` or
* when the publisher handle is from a different rmw implementation.
*
* \return native FastRTPS publisher handle if successful, otherwise `NULL`
* \return native Fast DDS DataWriter handle if successful, otherwise `NULL`
*/
RMW_FASTRTPS_CPP_PUBLIC
eprosima::fastrtps::Publisher *
get_publisher(rmw_publisher_t * publisher);
eprosima::fastdds::dds::DataWriter *
get_datawriter(rmw_publisher_t * publisher);

} // namespace rmw_fastrtps_cpp

Expand Down
21 changes: 11 additions & 10 deletions rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/get_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,36 @@
#ifndef RMW_FASTRTPS_CPP__GET_SERVICE_HPP_
#define RMW_FASTRTPS_CPP__GET_SERVICE_HPP_

#include "fastrtps/publisher/Publisher.h"
#include "fastrtps/subscriber/Subscriber.h"
#include "fastdds/dds/publisher/DataWriter.hpp"
#include "fastdds/dds/subscriber/DataReader.hpp"

#include "rmw/rmw.h"
#include "rmw_fastrtps_cpp/visibility_control.h"

namespace rmw_fastrtps_cpp
{

/// Return a native FastRTPS subscriber handle for the request.
/// Return a native Fast DDS DataReader handle for the request.
/**
* The function returns `NULL` when either the service handle is `NULL` or
* when the service handle is from a different rmw implementation.
*
* \return native FastRTPS subscriber handle if successful, otherwise `NULL`
* \return native Fast DDS DataReader handle if successful, otherwise `NULL`
*/
RMW_FASTRTPS_CPP_PUBLIC
eprosima::fastrtps::Subscriber *
get_request_subscriber(rmw_service_t * service);
eprosima::fastdds::dds::DataReader *
get_request_datareader(rmw_service_t * service);

/// Return a native FastRTPS publisher handle for the response.
/// Return a native Fast DDS DataWriter handle for the response.
/**
* The function returns `NULL` when either the service handle is `NULL` or
* when the service handle is from a different rmw implementation.
*
* \return native FastRTPS publisher handle if successful, otherwise `NULL`
* \return native Fast DDS DataWriter handle if successful, otherwise `NULL`
*/
RMW_FASTRTPS_CPP_PUBLIC
eprosima::fastrtps::Publisher *
get_response_publisher(rmw_service_t * service);
eprosima::fastdds::dds::DataWriter *
get_response_datawriter(rmw_service_t * service);

} // namespace rmw_fastrtps_cpp

Expand Down
11 changes: 6 additions & 5 deletions rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/get_subscriber.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,24 @@
#ifndef RMW_FASTRTPS_CPP__GET_SUBSCRIBER_HPP_
#define RMW_FASTRTPS_CPP__GET_SUBSCRIBER_HPP_

#include "fastrtps/subscriber/Subscriber.h"
#include "fastdds/dds/subscriber/DataReader.hpp"

#include "rmw/rmw.h"
#include "rmw_fastrtps_cpp/visibility_control.h"

namespace rmw_fastrtps_cpp
{

/// Return a native FastRTPS subscriber handle.
/// Return a native Fast DDS DataReader handle.
/**
* The function returns `NULL` when either the subscription handle is `NULL` or
* when the subscription handle is from a different rmw implementation.
*
* \return native FastRTPS subscriber handle if successful, otherwise `NULL`
* \return native Fast DDS DataReader handle if successful, otherwise `NULL`
*/
RMW_FASTRTPS_CPP_PUBLIC
eprosima::fastrtps::Subscriber *
get_subscriber(rmw_subscription_t * subscription);
eprosima::fastdds::dds::DataReader *
get_datareader(rmw_subscription_t * subscription);

} // namespace rmw_fastrtps_cpp

Expand Down
1 change: 0 additions & 1 deletion rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/publisher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ create_publisher(
const rmw_publisher_options_t * publisher_options,
bool keyed,
bool create_publisher_listener);

} // namespace rmw_fastrtps_cpp

#endif // RMW_FASTRTPS_CPP__PUBLISHER_HPP_
1 change: 0 additions & 1 deletion rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/subscription.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ create_subscription(
const rmw_subscription_options_t * subscription_options,
bool keyed,
bool create_subscription_listener);

} // namespace rmw_fastrtps_cpp

#endif // RMW_FASTRTPS_CPP__SUBSCRIPTION_HPP_
15 changes: 9 additions & 6 deletions rmw_fastrtps_cpp/src/get_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "fastdds/dds/publisher/DataWriter.hpp"
#include "fastdds/dds/subscriber/DataReader.hpp"

#include "rmw_fastrtps_cpp/get_client.hpp"

#include "rmw_fastrtps_shared_cpp/custom_client_info.hpp"
Expand All @@ -20,8 +23,8 @@
namespace rmw_fastrtps_cpp
{

eprosima::fastrtps::Publisher *
get_request_publisher(rmw_client_t * client)
eprosima::fastdds::dds::DataWriter *
get_request_datawriter(rmw_client_t * client)
{
if (!client) {
return nullptr;
Expand All @@ -30,11 +33,11 @@ get_request_publisher(rmw_client_t * client)
return nullptr;
}
auto impl = static_cast<CustomClientInfo *>(client->data);
return impl->request_publisher_;
return impl->request_writer_;
}

eprosima::fastrtps::Subscriber *
get_response_subscriber(rmw_client_t * client)
eprosima::fastdds::dds::DataReader *
get_response_datareader(rmw_client_t * client)
{
if (!client) {
return nullptr;
Expand All @@ -43,7 +46,7 @@ get_response_subscriber(rmw_client_t * client)
return nullptr;
}
auto impl = static_cast<CustomClientInfo *>(client->data);
return impl->response_subscriber_;
return impl->response_reader_;
}

} // namespace rmw_fastrtps_cpp
6 changes: 3 additions & 3 deletions rmw_fastrtps_cpp/src/get_participant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
namespace rmw_fastrtps_cpp
{

eprosima::fastrtps::Participant *
get_participant(rmw_node_t * node)
eprosima::fastdds::dds::DomainParticipant *
get_domain_participant(rmw_node_t * node)
{
if (!node) {
return nullptr;
Expand All @@ -32,7 +32,7 @@ get_participant(rmw_node_t * node)
return nullptr;
}
auto impl = static_cast<CustomParticipantInfo *>(node->context->impl->participant_info);
return impl->participant;
return impl->participant_;
}

} // namespace rmw_fastrtps_cpp
6 changes: 3 additions & 3 deletions rmw_fastrtps_cpp/src/get_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
namespace rmw_fastrtps_cpp
{

eprosima::fastrtps::Publisher *
get_publisher(rmw_publisher_t * publisher)
eprosima::fastdds::dds::DataWriter *
get_datawriter(rmw_publisher_t * publisher)
{
if (!publisher) {
return nullptr;
Expand All @@ -30,7 +30,7 @@ get_publisher(rmw_publisher_t * publisher)
return nullptr;
}
auto impl = static_cast<CustomPublisherInfo *>(publisher->data);
return impl->publisher_;
return impl->data_writer_;
}

} // namespace rmw_fastrtps_cpp
12 changes: 6 additions & 6 deletions rmw_fastrtps_cpp/src/get_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
namespace rmw_fastrtps_cpp
{

eprosima::fastrtps::Subscriber *
get_request_subscriber(rmw_service_t * service)
eprosima::fastdds::dds::DataReader *
get_request_datareader(rmw_service_t * service)
{
if (!service) {
return nullptr;
Expand All @@ -30,11 +30,11 @@ get_request_subscriber(rmw_service_t * service)
return nullptr;
}
auto impl = static_cast<CustomServiceInfo *>(service->data);
return impl->request_subscriber_;
return impl->request_reader_;
}

eprosima::fastrtps::Publisher *
get_response_publisher(rmw_service_t * service)
eprosima::fastdds::dds::DataWriter *
get_response_datawriter(rmw_service_t * service)
{
if (!service) {
return nullptr;
Expand All @@ -43,7 +43,7 @@ get_response_publisher(rmw_service_t * service)
return nullptr;
}
auto impl = static_cast<CustomServiceInfo *>(service->data);
return impl->response_publisher_;
return impl->response_writer_;
}

} // namespace rmw_fastrtps_cpp
6 changes: 3 additions & 3 deletions rmw_fastrtps_cpp/src/get_subscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
namespace rmw_fastrtps_cpp
{

eprosima::fastrtps::Subscriber *
get_subscriber(rmw_subscription_t * subscription)
eprosima::fastdds::dds::DataReader *
get_datareader(rmw_subscription_t * subscription)
{
if (!subscription) {
return nullptr;
Expand All @@ -30,7 +30,7 @@ get_subscriber(rmw_subscription_t * subscription)
return nullptr;
}
auto impl = static_cast<CustomSubscriberInfo *>(subscription->data);
return impl->subscriber_;
return impl->data_reader_;
}

} // namespace rmw_fastrtps_cpp
2 changes: 1 addition & 1 deletion rmw_fastrtps_cpp/src/init_rmw_context_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ init_context_impl(rmw_context_t * context)
}

common_context->gid = rmw_fastrtps_shared_cpp::create_rmw_gid(
eprosima_fastrtps_identifier, participant_info->participant->getGuid());
eprosima_fastrtps_identifier, participant_info->participant_->guid());
common_context->pub = publisher.get();
common_context->sub = subscription.get();
common_context->graph_guard_condition = graph_guard_condition.get();
Expand Down
Loading

0 comments on commit 29050bf

Please sign in to comment.