Skip to content

[22722] Support interfaces for RPC generated code #5622

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 18 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
bfa0826
Refs #22722. Add RpcException class.
MiguelCompany Jan 30, 2025
576c2d4
Refs #22722. Add RpcTimeoutException class.
MiguelCompany Jan 30, 2025
404b75c
Refs #22722. Add RpcBrokenPipeException class.
MiguelCompany Jan 30, 2025
f95f09b
Refs #22722. Add RpcOperationError class.
MiguelCompany Jan 31, 2025
2fc5bdd
Refs #22722. Add utility include for exceptions.
MiguelCompany Jan 31, 2025
2183ead
Refs #22722. Add RpcServerReader template interface.
MiguelCompany Jan 31, 2025
e74cd0f
Refs #22722. Add RpcClientReader template interface.
MiguelCompany Jan 31, 2025
78cd26c
Refs #22722. Add RpcServerWriter template interface.
MiguelCompany Jan 31, 2025
ee5fa7b
Refs #22722. Add RpcClientWriter template interface.
MiguelCompany Jan 31, 2025
f6672c4
Refs #22722. Add RpcInputFeedCancelledException.
MiguelCompany Jan 31, 2025
d8317a7
Refs #22722. Add RpcFuture template.
MiguelCompany Jan 31, 2025
7fe135d
Refs #22722. Rename `RpcInputFeedCancelledException` -> `RpcFeedCance…
MiguelCompany Feb 5, 2025
1584639
Refs #22722. `RpcServerWriter` operations can throw `RpcFeedCancelled…
MiguelCompany Feb 5, 2025
8827652
Refs #22722. Improve documentation of `RpcClientReader`
MiguelCompany Feb 6, 2025
57d9df2
Refs #22722. Improve documentation of `RpcClientWriter`
MiguelCompany Feb 6, 2025
568f29d
Refs #22722. Avoid DSO export warning on Windows
MiguelCompany Feb 10, 2025
0d9a3c9
Refs #22722. Add utility include for interfaces.
MiguelCompany Feb 10, 2025
a3d1b28
Refs #22722. Add missing argument on doxygen documentation.
MiguelCompany Feb 10, 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
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/RpcInputFeedCancelledException.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
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 RpcInputFeedCancelledException.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 RpcInputFeedCancelledException : public RpcException
{

public:

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

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

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

/**
* Destructor.
*/
virtual ~RpcInputFeedCancelledException() 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