Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions include/fastdds/dds/rpc/interfaces.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
#include <fastdds/dds/rpc/interfaces/RpcClientReader.hpp>
#include <fastdds/dds/rpc/interfaces/RpcClientWriter.hpp>
#include <fastdds/dds/rpc/interfaces/RpcFuture.hpp>
#include <fastdds/dds/rpc/interfaces/RpcRequest.hpp>
#include <fastdds/dds/rpc/interfaces/RpcServer.hpp>
#include <fastdds/dds/rpc/interfaces/RpcServerReader.hpp>
#include <fastdds/dds/rpc/interfaces/RpcServerSchedulingStrategy.hpp>
#include <fastdds/dds/rpc/interfaces/RpcServerWriter.hpp>
#include <fastdds/dds/rpc/interfaces/RpcStatusCode.hpp>

Expand Down
63 changes: 63 additions & 0 deletions include/fastdds/dds/rpc/interfaces/RpcRequest.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// 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.

/**
* @file RpcRequest.hpp
*/

#ifndef FASTDDS_DDS_RPC_INTERFACES__RPCREQUEST_HPP
#define FASTDDS_DDS_RPC_INTERFACES__RPCREQUEST_HPP

#include <fastdds/rtps/common/Guid.hpp>
#include <fastdds/rtps/common/RemoteLocators.hpp>

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

/**
* An interface with generic RPC requests functionality.
*/
class RpcRequest
{
public:

/**
* Destructor.
*/
virtual ~RpcRequest() noexcept = default;

/**
* @brief Get the GUID of the client that made the request.
*
* @return The GUID of the client that made the request.
*/
virtual const eprosima::fastdds::rtps::GUID_t& get_client_id() const = 0;

/**
* @brief Get the locators of the client that made the request.
*
* @return The locators of the client that made the request.
*/
virtual const eprosima::fastdds::rtps::RemoteLocatorList& get_client_locators() const = 0;

};

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

#endif // FASTDDS_DDS_RPC_INTERFACES__RPCREQUEST_HPP
75 changes: 75 additions & 0 deletions include/fastdds/dds/rpc/interfaces/RpcServer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// 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.

/**
* @file RpcServer.hpp
*/

#ifndef FASTDDS_DDS_RPC_INTERFACES__RPCSERVER_HPP
#define FASTDDS_DDS_RPC_INTERFACES__RPCSERVER_HPP

#include <memory>

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

// Forward declaration of RpcRequest class.
class RpcRequest;

/**
* An interface with generic RPC server functionality.
*/
class RpcServer
{
public:

/**
* Destructor.
*/
virtual ~RpcServer() noexcept = default;

/**
* @brief Run the server.
*
* This method starts the server and begins processing requests.
* The method will block until the server is stopped.
*/
virtual void run() = 0;

/**
* @brief Stop the server.
*
* This method stops the server and releases all resources.
* It will cancel all pending requests, and wait for all processing threads to finish before returning.
*/
virtual void stop() = 0;

/**
* @brief Perform execution of a client request.
*
* @param request The client request to execute.
*/
virtual void execute_request(
const std::shared_ptr<RpcRequest>& request) = 0;

};

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

#endif // FASTDDS_DDS_RPC_INTERFACES__RPCSERVER_HPP
75 changes: 75 additions & 0 deletions include/fastdds/dds/rpc/interfaces/RpcServerSchedulingStrategy.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// 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.

/**
* @file RpcServerSchedulingStrategy.hpp
*/

#ifndef FASTDDS_DDS_RPC_INTERFACES__RPCSERVERSCHEDULINGSTRATEGY_HPP
#define FASTDDS_DDS_RPC_INTERFACES__RPCSERVERSCHEDULINGSTRATEGY_HPP

#include <memory>

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

class RpcRequest;
class RpcServer;

/**
* An interface with generic RPC requests functionality.
*/
class RpcServerSchedulingStrategy
{
public:

/**
* Destructor.
*/
virtual ~RpcServerSchedulingStrategy() noexcept = default;

/**
* @brief Schedule a request for processing.
*
* This method is called when a request is received and should be processed by the server.
* The implementation should decide how to handle the request, whether to process it immediately,
* or to queue it for later processing.
*
* A call to server->execute_request(request) should eventually be made to process the request.
*
* @param request The request to schedule.
* @param server The server instance that should process the request.
*/
virtual void schedule_request(
const std::shared_ptr<RpcRequest>& request,
const std::shared_ptr<RpcServer>& server) = 0;

/**
* @brief Informs that a server has been stopped and all its requests have been cancelled.
*
* @param server The server instance that has been stopped.
*/
virtual void server_stopped(
const std::shared_ptr<RpcServer>& server) = 0;

};

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

#endif // FASTDDS_DDS_RPC_INTERFACES__RPCSERVERSCHEDULINGSTRATEGY_HPP
Loading