Skip to content
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

[22722] Support interfaces for RPC generated code #5622

Open
wants to merge 15 commits into
base: feature/rpc/main
Choose a base branch
from
Open
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
28 changes: 28 additions & 0 deletions include/fastdds/dds/rpc/exceptions.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// 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 exceptions.hpp
*/

#ifndef FASTDDS_DDS_RPC__EXCEPTIONS_HPP
#define FASTDDS_DDS_RPC__EXCEPTIONS_HPP

#include <fastdds/dds/rpc/exceptions/RpcBrokenPipeException.hpp>
#include <fastdds/dds/rpc/exceptions/RpcException.hpp>
#include <fastdds/dds/rpc/exceptions/RpcFeedCancelledException.hpp>
#include <fastdds/dds/rpc/exceptions/RpcOperationError.hpp>
#include <fastdds/dds/rpc/exceptions/RpcTimeoutException.hpp>

#endif // FASTDDS_DDS_RPC__EXCEPTIONS_HPP
71 changes: 71 additions & 0 deletions include/fastdds/dds/rpc/exceptions/RpcBrokenPipeException.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// 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 RpcBrokenPipeException.hpp
*/

#ifndef FASTDDS_DDS_RPC_EXCEPTIONS__RPCBROKENPIPEEXCEPTION_HPP
#define FASTDDS_DDS_RPC_EXCEPTIONS__RPCBROKENPIPEEXCEPTION_HPP

#include <fastdds/fastdds_dll.hpp>
#include <fastdds/dds/rpc/exceptions/RpcException.hpp>

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

/**
* Exception thrown by the RPC API when the communication with the remote endpoint breaks.
*/
class FASTDDS_EXPORTED_API RpcBrokenPipeException : public RpcException
{

public:

/**
* Constructor.
*/
RpcBrokenPipeException(
bool local_is_server)
: RpcException(local_is_server ? "Communication lost with the client" : "Communication lost with the server")
{
}

/**
* Copy constructor.
*/
RpcBrokenPipeException(
const RpcBrokenPipeException& other) noexcept = default;

/**
* Copy assignment.
*/
RpcBrokenPipeException& operator =(
const RpcBrokenPipeException& other) noexcept = default;

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

};

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

#endif // FASTDDS_DDS_RPC_EXCEPTIONS__RPCBROKENPIPEEXCEPTION_HPP
86 changes: 86 additions & 0 deletions include/fastdds/dds/rpc/exceptions/RpcException.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// 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 RpcException.hpp
*/

#ifndef FASTDDS_DDS_RPC_EXCEPTIONS__RPCEXCEPTION_HPP
#define FASTDDS_DDS_RPC_EXCEPTIONS__RPCEXCEPTION_HPP

#include <stdexcept>
#include <string>

#include <fastdds/fastdds_dll.hpp>

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

/**
* Base class for all exceptions thrown by the RPC API.
*/
class FASTDDS_EXPORTED_API RpcException : public std::logic_error
{

public:

/**
* Constructor.
*
* @param message The exception message.
*/
explicit RpcException(
const std::string& message)
: std::logic_error(message)
{
}

/**
* Constructor.
*
* @param message The exception message.
*/
explicit RpcException(
const char* message)
: std::logic_error(message)
{
}

/**
* Copy constructor.
*/
RpcException(
const RpcException& other) noexcept = default;

/**
* Copy assignment.
*/
RpcException& operator =(
const RpcException& other) noexcept = default;

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

};

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

#endif // FASTDDS_DDS_RPC_EXCEPTIONS__RPCEXCEPTION_HPP
74 changes: 74 additions & 0 deletions include/fastdds/dds/rpc/exceptions/RpcFeedCancelledException.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// 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 RpcFeedCancelledException.hpp
*/

#ifndef FASTDDS_DDS_RPC_EXCEPTIONS__RPCINPUTFEEDCANCELLEDEXCEPTION_HPP
#define FASTDDS_DDS_RPC_EXCEPTIONS__RPCINPUTFEEDCANCELLEDEXCEPTION_HPP

#include <string>

#include <fastdds/fastdds_dll.hpp>
#include <fastdds/dds/rpc/exceptions/RpcException.hpp>
#include <fastdds/dds/rpc/interfaces/RpcStatusCode.hpp>

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

/**
* Exception thrown by the RPC API when the client cancels an input feed.
*/
class FASTDDS_EXPORTED_API RpcFeedCancelledException : public RpcException
{

public:

/**
* Constructor.
*/
RpcFeedCancelledException(
RpcStatusCode reason)
: RpcException("Input feed cancelled with reason '" + std::to_string(reason) + "'")
{
}

/**
* Copy constructor.
*/
RpcFeedCancelledException(
const RpcFeedCancelledException& other) noexcept = default;

/**
* Copy assignment.
*/
RpcFeedCancelledException& operator =(
const RpcFeedCancelledException& other) noexcept = default;

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

};

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

#endif // FASTDDS_DDS_RPC_EXCEPTIONS__RPCINPUTFEEDCANCELLEDEXCEPTION_HPP
82 changes: 82 additions & 0 deletions include/fastdds/dds/rpc/exceptions/RpcOperationError.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// 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 RpcOperationError.hpp
*/

#ifndef FASTDDS_DDS_RPC_EXCEPTIONS__RPCOPERATIONERROR_HPP
#define FASTDDS_DDS_RPC_EXCEPTIONS__RPCOPERATIONERROR_HPP

#include <string>

#include <fastdds/fastdds_dll.hpp>
#include <fastdds/dds/rpc/exceptions/RpcException.hpp>

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

/**
* Base class for exceptions thrown by the RPC API when the server communicates an error.
*/
class FASTDDS_EXPORTED_API RpcOperationError : public RpcException
{

public:

/**
* Constructor.
*/
RpcOperationError(
const std::string& message)
: RpcException(message)
{
}

/**
* Constructor.
*/
RpcOperationError(
const char* message)
: RpcException(message)
{
}

/**
* Copy constructor.
*/
RpcOperationError(
const RpcOperationError& other) noexcept = default;

/**
* Copy assignment.
*/
RpcOperationError& operator =(
const RpcOperationError& other) noexcept = default;

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

};

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

#endif // FASTDDS_DDS_RPC_EXCEPTIONS__RPCOPERATIONERROR_HPP
Loading