diff --git a/include/point_cloud_transport/expected.hpp b/include/point_cloud_transport/expected.hpp deleted file mode 100644 index 5f1b54a..0000000 --- a/include/point_cloud_transport/expected.hpp +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) 2023, Czech Technical University in Prague -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// - -#ifndef POINT_CLOUD_TRANSPORT__EXPECTED_HPP_ -#define POINT_CLOUD_TRANSPORT__EXPECTED_HPP_ - - -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: Czech Technical University in Prague - -/** - * \file - * \brief An implementation of the `std::expected` proposal. - * - * `std::expected` should be used in functions that can either succeed and return a value, or fail and return an error. - * \author Martin Pecka - */ - -#include - -namespace cras -{ -using ::tl::bad_expected_access; -using ::tl::expected; -using ::tl::in_place; -using ::tl::make_unexpected; -using ::tl::unexpect; -using ::tl::unexpected; -} // namespace cras - -#include - -namespace cras -{ -/// \brief Type trait determining whether type T is cras::expected or not. -/// \tparam T The type to test. -template -struct is_cras_expected : public ::std::false_type {}; - - -/// \brief Type trait determining whether type T is std::optional or not. -/// \tparam T Type of the expected value. -/// \tparam E Type of the expected error. -template -struct is_cras_expected<::cras::expected>: public ::std::true_type {}; -} // namespace cras -#endif // POINT_CLOUD_TRANSPORT__EXPECTED_HPP_ diff --git a/include/point_cloud_transport/publisher_plugin.hpp b/include/point_cloud_transport/publisher_plugin.hpp index 6322a19..ff4a25d 100644 --- a/include/point_cloud_transport/publisher_plugin.hpp +++ b/include/point_cloud_transport/publisher_plugin.hpp @@ -38,8 +38,8 @@ #include "rclcpp/node.hpp" #include +#include -#include #include #include "point_cloud_transport/visibility_control.hpp" @@ -52,7 +52,7 @@ class POINT_CLOUD_TRANSPORT_PUBLIC PublisherPlugin public: /// \brief Result of cloud encoding. Either an holding the compressed cloud, /// empty value or error message. - typedef cras::expected>, + typedef tl::expected>, std::string> EncodeResult; PublisherPlugin() = default; diff --git a/include/point_cloud_transport/simple_publisher_plugin.hpp b/include/point_cloud_transport/simple_publisher_plugin.hpp index cc7b558..2e4ba8e 100644 --- a/include/point_cloud_transport/simple_publisher_plugin.hpp +++ b/include/point_cloud_transport/simple_publisher_plugin.hpp @@ -42,8 +42,8 @@ #include #include "rclcpp/serialization.hpp" #include +#include -#include #include #include #include @@ -75,7 +75,7 @@ class SimplePublisherPlugin : public point_cloud_transport::PublisherPlugin public: /// \brief Result of cloud encoding. Either the compressed cloud message, /// empty value, or error message. - typedef cras::expected, std::string> TypedEncodeResult; + typedef tl::expected, std::string> TypedEncodeResult; ~SimplePublisherPlugin() { @@ -114,7 +114,7 @@ class SimplePublisherPlugin : public point_cloud_transport::PublisherPlugin } void setParamCallback( - rclcpp::node_interfaces::NodeParametersInterface::OnSetParametersCallbackType + rclcpp::node_interfaces::NodeParametersInterface::OnParametersSetCallbackType param_change_callback) { if (simple_impl_) { @@ -171,7 +171,7 @@ class SimplePublisherPlugin : public point_cloud_transport::PublisherPlugin // encode the message using the expected transport method auto res = this->encodeTyped(raw); if (!res) { - return cras::make_unexpected(res.error()); + return tl::make_unexpected(res.error()); } if (!res.value()) { return std::nullopt; diff --git a/include/point_cloud_transport/simple_subscriber_plugin.hpp b/include/point_cloud_transport/simple_subscriber_plugin.hpp index 120b5d8..7df6015 100644 --- a/include/point_cloud_transport/simple_subscriber_plugin.hpp +++ b/include/point_cloud_transport/simple_subscriber_plugin.hpp @@ -98,7 +98,7 @@ class SimpleSubscriberPlugin : public SubscriberPlugin } void setParamCallback( - rclcpp::node_interfaces::NodeParametersInterface::OnSetParametersCallbackType + rclcpp::node_interfaces::NodeParametersInterface::OnParametersSetCallbackType param_change_callback) { if (impl_) { @@ -134,7 +134,7 @@ class SimpleSubscriberPlugin : public SubscriberPlugin auto serializer = rclcpp::Serialization(); serializer.deserialize_message(compressed.get(), msg.get()); } catch (const std::exception & e) { - return cras::make_unexpected( + return tl::make_unexpected( "Error deserializing message for transport decoder: " + std::string( e.what()) + "."); } diff --git a/include/point_cloud_transport/subscriber_plugin.hpp b/include/point_cloud_transport/subscriber_plugin.hpp index 473284d..91f63dc 100644 --- a/include/point_cloud_transport/subscriber_plugin.hpp +++ b/include/point_cloud_transport/subscriber_plugin.hpp @@ -40,8 +40,8 @@ #include "rclcpp/macros.hpp" #include "rclcpp/node.hpp" #include +#include -#include #include #include "point_cloud_transport/visibility_control.hpp" @@ -57,7 +57,7 @@ class POINT_CLOUD_TRANSPORT_PUBLIC SubscriberPlugin public: /// \brief Result of cloud decoding. Either a `sensor_msgs::msg::PointCloud2` /// holding the raw message, empty value or error message. - typedef cras::expected, + typedef tl::expected, std::string> DecodeResult; SubscriberPlugin() = default;