Skip to content

[22682] Add RPCDDS internal API #5638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 33 commits into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5f83ac2
Refs #22682: Add public interfaces of RPC Entities
Carlosespicur Feb 6, 2025
7d906ae
Refs #22682: Add RequestInfo class
Carlosespicur Feb 6, 2025
dd76f46
Refs #22682: Add ServiceTypeSupport interface
Carlosespicur Feb 6, 2025
74252e7
Refs #22682: Add Requester/Replier parameter classes
Carlosespicur Feb 6, 2025
e1f2546
Refs #22682: Add private headers and implement RPC methods
Carlosespicur Feb 6, 2025
2d70d98
Refs #22682: Expose Requester/Replier endpoint getters to public API
Carlosespicur Feb 7, 2025
4ca5cac
Refs #22682: Add public methods for deleting requester/replier entities
Carlosespicur Feb 7, 2025
7f7ec99
Refs #22682: Allow calling get_statuscondition method on constant ent…
Carlosespicur Feb 7, 2025
6eace74
Refs #22682: Refactor blackbox tests
Carlosespicur Feb 9, 2025
7a85f85
Refs #22682: Avoid sample filtering on request topic
Carlosespicur Feb 10, 2025
c0e2fb7
Refs #22682: Fix segFault error due to deleting endpoints manually
Carlosespicur Feb 10, 2025
6c708b5
Refs #22682: Fix TCPRequester params
Carlosespicur Feb 10, 2025
d9a2db5
Refs #22682: Enable type() method for const DataReader objects
Carlosespicur Feb 11, 2025
ef90a07
Refs #22682: Add unit tests for Requester/Replier parameters validation
Carlosespicur Feb 11, 2025
c9beae3
Refs #22682: Add unit tests for DomainParticipant public API methods
Carlosespicur Feb 11, 2025
4f5eb0a
Refs #22682: Fix test errors. Add service/participant checks and avoi…
Carlosespicur Feb 11, 2025
3cf8b8e
Refs #22682: Update versions.md
Carlosespicur Feb 12, 2025
fade63b
Refs #22682: Apply suggested changes. Remove RequesterParams/ReplierP…
Carlosespicur Feb 12, 2025
4e92926
Refs #22682: Apply suggested changes. Unify parameters in Requester/R…
Carlosespicur Feb 13, 2025
0ece3fd
Refs #22682: Fix RequesterImpl::send_request related_sample_identity …
Carlosespicur Feb 13, 2025
0bddb9e
Refs #22682: Fix typos
Carlosespicur Feb 18, 2025
f6b7659
Refs #22682: Apply suggested changes
Carlosespicur Feb 23, 2025
35356f1
Refs #22682: Apply suggested changes
Carlosespicur Feb 25, 2025
b6ff4d3
Refs #22682: Uncrustify
Carlosespicur Feb 27, 2025
95d0990
Refs #22682: Avoid creating unnecesary RequestReplyContentFilter inst…
Carlosespicur Feb 28, 2025
5dc3dd5
Refs #22682: Add suggested changes
Carlosespicur Feb 28, 2025
6eac0ff
Refs #22682: Apply suggested changes. Add return_load method to Reque…
Carlosespicur Mar 3, 2025
66b9543
Refs #22682: Apply suggested changes
Carlosespicur Mar 3, 2025
abc9e46
Refs #22682: Apply suggested changes. Blackbox tests classes
Carlosespicur Mar 3, 2025
52695fa
Refs #22682: Apply suggested changes. Update send_reply signature.
Carlosespicur Mar 3, 2025
6285bf7
Refs #22682: Fix blackbox tests
Carlosespicur Mar 4, 2025
e35dd7a
Refs #22682: Fix notation errors in Requester/Replier
Carlosespicur Mar 4, 2025
be0c76f
Refs #22682: Fix memory leaks in RequestReplyContentFilterFactory
Carlosespicur Mar 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions include/fastdds/dds/core/Entity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ class Entity
return status_condition_;
}

/**
* @brief Allows access to the StatusCondition associated with the Entity
*
* @return Const Reference to StatusCondition object
*/
FASTDDS_EXPORTED_API const StatusCondition& get_statuscondition() const
{
return status_condition_;
}

protected:

/**
Expand Down
113 changes: 113 additions & 0 deletions include/fastdds/dds/domain/DomainParticipant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <fastdds/dds/domain/qos/DomainParticipantQos.hpp>
#include <fastdds/dds/domain/qos/ReplierQos.hpp>
#include <fastdds/dds/domain/qos/RequesterQos.hpp>
#include <fastdds/dds/rpc/ServiceTypeSupport.hpp>
#include <fastdds/dds/topic/ContentFilteredTopic.hpp>
#include <fastdds/dds/topic/IContentFilterFactory.hpp>
#include <fastdds/dds/topic/Topic.hpp>
Expand All @@ -55,12 +56,19 @@ class ResourceEvent;
} // namespace rtps

namespace dds {
namespace rpc {
class Replier;
class Requester;
class Service;
} // namespace rpc

class DomainParticipantImpl;
class DomainParticipantListener;
class Publisher;
class PublisherQos;
class PublisherListener;
class ReplierQos;
class RequesterQos;
class Subscriber;
class SubscriberQos;
class SubscriberListener;
Expand Down Expand Up @@ -388,6 +396,82 @@ class DomainParticipant : public Entity
const std::string& topic_name,
const fastdds::dds::Duration_t& timeout);

/**
* Create a RPC service.
*
* @param service_name Name of the service.
* @param service_type_name Type name of the service (Request & reply types)
*
* @return Pointer to the created service. nullptr in error case.
*/
FASTDDS_EXPORTED_API rpc::Service* create_service(
const std::string& service_name,
const std::string& service_type_name);

/**
* Find a RPC service by name
*
* @param service_name Name of the service to search for.
* @return Pointer to the service object if found, nullptr if not found.
*/
FASTDDS_EXPORTED_API rpc::Service* find_service(
const std::string& service_name) const;

/**
* Delete a registered RPC service
*
* @param service Pointer to the service to be deleted.
* @return RETCODE_OK if the service was deleted, or an specific error code otherwise.
*/
FASTDDS_EXPORTED_API ReturnCode_t delete_service(
const rpc::Service* service);

/**
* Create a RPC Requester in a given Service.
*
* @param service Pointer to a service object where the requester will be created.
* @param requester_qos QoS of the requester.
*
* @return Pointer to the created requester. nullptr in error case.
*/
FASTDDS_EXPORTED_API rpc::Requester* create_service_requester(
rpc::Service* service,
const RequesterQos& requester_qos);

/**
* Deletes an existing RPC Requester
*
* @param service_name Name of the service where the requester is created.
* @param requester Pointer to the requester to be deleted.
* @return RETCODE_OK if the requester was deleted, or an specific error code otherwise.
*/
FASTDDS_EXPORTED_API ReturnCode_t delete_service_requester(
const std::string& service_name,
rpc::Requester* requester);

/**
* Create a RPC Replier in a given Service. It will override the current service's replier
*
* @param service Pointer to a service object where the Replier will be created.
* @param requester_qos QoS of the requester.
*
* @return Pointer to the created requester. nullptr in error case.
*/
FASTDDS_EXPORTED_API rpc::Replier* create_service_replier(
rpc::Service* service,
const ReplierQos& replier_qos);

/**
* Deletes an existing RPC Replier
*
* @param service_name Name of the service where the replier is created.
* @param replier Pointer to the replier to be deleted.
* @return RETCODE_OK if the replier was deleted, or an specific error code otherwise.
*/
FASTDDS_EXPORTED_API ReturnCode_t delete_service_replier(
const std::string& service_name,
rpc::Replier* replier);

/**
* Looks up an existing, locally created @ref TopicDescription, based on its name.
* May be called on a disabled participant.
Expand Down Expand Up @@ -1041,6 +1125,35 @@ class DomainParticipant : public Entity
FASTDDS_EXPORTED_API TypeSupport find_type(
const std::string& type_name) const;

/**
* Register a service type in this participant.
*
* @param service_type ServiceTypeSupport.
* @param service_type_name The name that will be used to identify the service type.
* @return RETCODE_OK if it is correctly registered. Error code otherwise.
*/
FASTDDS_EXPORTED_API ReturnCode_t register_service_type(
rpc::ServiceTypeSupport service_type,
const std::string& service_type_name);

/**
* Unregister a service type in this participant.
*
* @param service_type_name Name of the type
* @return RETCODE_OK if it is correctly unregistered. Error code otherwise.
*/
FASTDDS_EXPORTED_API ReturnCode_t unregister_service_type(
const std::string& service_type_name);

/**
* This method gives access to a registered service type based on its name.
*
* @param service_type_name Name of the type
* @return ServiceTypeSupport corresponding to the service_type_name
*/
FASTDDS_EXPORTED_API rpc::ServiceTypeSupport find_service_type(
const std::string& service_type_name) const;

/**
* Returns the DomainParticipant's handle.
*
Expand Down
80 changes: 80 additions & 0 deletions include/fastdds/dds/rpc/RPCEntity.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// Copyright 2025 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef FASTDDS_DDS_RPC__RPCENTITY_HPP
#define FASTDDS_DDS_RPC__RPCENTITY_HPP

#include <fastdds/dds/core/detail/DDSReturnCode.hpp>
#include <fastdds/fastdds_dll.hpp>

namespace eprosima {
namespace fastdds {
namespace dds {
namespace rpc {

/**
* @brief Abstract base class for all RPC Objects
*/
class RPCEntity
{

public:

/**
* @brief Constructor
*/
FASTDDS_EXPORTED_API RPCEntity()
: enable_(false)
{
}

/**
* @brief Enables the entity
*/
virtual ReturnCode_t enable()
{
enable_ = true;
return RETCODE_OK;
}

/**
* @brief Disables the entity
*/
virtual ReturnCode_t close()
{
enable_ = false;
return RETCODE_OK;
}

/**
* @brief Checks if the entity is enabled
*/
FASTDDS_EXPORTED_API bool is_enabled() const
{
return enable_;
}

protected:

//! Boolean that states if the Entity is enabled or disabled
bool enable_;

};

} // namespace rpc
} // namespace dds
} // namespace fastdds
} // namespace eprosima

#endif // FASTDDS_DDS_RPC__RPCENTITY_HPP
107 changes: 107 additions & 0 deletions include/fastdds/dds/rpc/Replier.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
// Copyright 2025 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef FASTDDS_DDS_RPC__REPLIER_HPP
#define FASTDDS_DDS_RPC__REPLIER_HPP

#include <fastdds/dds/core/LoanableSequence.hpp>
#include <fastdds/dds/rpc/RPCEntity.hpp>

namespace eprosima {
namespace fastdds {
namespace dds {

class LoanableCollection;
class SampleInfo;
class DataWriter;
class DataReader;

} // namespace dds

namespace dds {
namespace rpc {

class RequestInfo;

/**
* @brief Base class for a Replier in the RPC communication
*/
class Replier : public RPCEntity
{

public:

/**
* @brief Destructor
*/
virtual ~Replier(){};

/**
* @brief Returns the name of the service to which the replier belongs
*/
virtual const std::string& get_service_name() const = 0;

/**
* @brief Send a reply message
*
* @param data Data to send
* @param info Information about the reply sample. This information is used to match the reply with the request through the SampleIdentity
* @return RETCODE_OK if the reply was sent successfully or a ReturnCode related to the specific error otherwise
*/
virtual ReturnCode_t send_reply(
void* data,
RequestInfo& info) = 0;

/**
* @brief Take a request message from the Replier DataReader's history.
*
* @param data Data to receive the request
* @param info Information about the request sample
* @return RETCODE_OK if the request was taken successfully or a ReturnCode related to the specific error otherwise
*/
virtual ReturnCode_t take_request(
void* data,
SampleInfo& info) = 0;

/**
* @brief Take all request messages stored in the Replier DataReader's history.
* @note This method does not allow to take only the samples associated to a given request. User must implement a zero-copy solution to link request and reply samples.
*
* @param data Data to receive the request
* @param info Information about the request sample
* @return RETCODE_OK if the request was taken successfully or a ReturnCode related to the specific error otherwise
*/
virtual ReturnCode_t take_request(
LoanableCollection& data,
LoanableSequence<SampleInfo>& info) = 0;

/**
* @brief Getter for the Replier's DataWriter
*/
virtual const DataWriter* get_replier_writer() const = 0;

/**
* @brief Getter for the Replier's DataReader
*/
virtual const DataReader* get_replier_reader() const = 0;

};

} // namespace rpc
} // namespace dds
} // namesapce fastdds
} // namespace eprosima


#endif // FASTDDS_DDS_RPC__REPLIER_HPP
Loading
Loading