Skip to content

Commit

Permalink
Support interfaces for RPC generated code (#5622)
Browse files Browse the repository at this point in the history
* Refs #22722. Add RpcException class.

Signed-off-by: Miguel Company <[email protected]>

* Refs #22722. Add RpcTimeoutException class.

Signed-off-by: Miguel Company <[email protected]>

* Refs #22722. Add RpcBrokenPipeException class.

* Refs #22722. Add RpcOperationError class.

Signed-off-by: Miguel Company <[email protected]>

* Refs #22722. Add utility include for exceptions.

Signed-off-by: Miguel Company <[email protected]>

* Refs #22722. Add RpcServerReader template interface.

Signed-off-by: Miguel Company <[email protected]>

* Refs #22722. Add RpcClientReader template interface.

Signed-off-by: Miguel Company <[email protected]>

* Refs #22722. Add RpcServerWriter template interface.

Signed-off-by: Miguel Company <[email protected]>

* Refs #22722. Add RpcClientWriter template interface.

Signed-off-by: Miguel Company <[email protected]>

* Refs #22722. Add RpcInputFeedCancelledException.

Signed-off-by: Miguel Company <[email protected]>

* Refs #22722. Add RpcFuture template.

Signed-off-by: Miguel Company <[email protected]>

* Refs #22722. Rename `RpcInputFeedCancelledException` -> `RpcFeedCancelledException`

Signed-off-by: Miguel Company <[email protected]>

* Refs #22722. `RpcServerWriter` operations can throw `RpcFeedCancelledException`

Signed-off-by: Miguel Company <[email protected]>

* Refs #22722. Improve documentation of `RpcClientReader`

Signed-off-by: Miguel Company <[email protected]>

* Refs #22722. Improve documentation of `RpcClientWriter`

Signed-off-by: Miguel Company <[email protected]>

* Refs #22722. Avoid DSO export warning on Windows

Signed-off-by: Miguel Company <[email protected]>

* Refs #22722. Add utility include for interfaces.

Signed-off-by: Miguel Company <[email protected]>

* Refs #22722. Add missing argument on doxygen documentation.

Signed-off-by: Miguel Company <[email protected]>

---------

Signed-off-by: Miguel Company <[email protected]>
  • Loading branch information
MiguelCompany committed Feb 12, 2025
1 parent 80347b5 commit 723ae39
Show file tree
Hide file tree
Showing 13 changed files with 887 additions and 0 deletions.
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
98 changes: 98 additions & 0 deletions include/fastdds/dds/rpc/exceptions/RpcException.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// 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:

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

/**
* Constructor.
*
* @param message The exception message.
*/
explicit RpcException(
const char* message)
: 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;

/**
* Returns the explanatory string.
*/
const char* what() const noexcept
{
return logic_error_.what();
}

private:

std::logic_error logic_error_;

};

} // 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

0 comments on commit 723ae39

Please sign in to comment.