.. _program_listing_file_include_rclcpp_utilities.hpp: Program Listing for File utilities.hpp ====================================== |exhale_lsh| :ref:`Return to documentation for file ` (``include/rclcpp/utilities.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp // Copyright 2014 Open Source Robotics Foundation, Inc. // // 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. #ifndef RCLCPP__UTILITIES_HPP_ #define RCLCPP__UTILITIES_HPP_ #include #include #include #include #include #include "rclcpp/context.hpp" #include "rclcpp/init_options.hpp" #include "rclcpp/visibility_control.hpp" #ifdef ANDROID #include namespace std { template std::string to_string(T value) { std::ostringstream os; os << value; return os.str(); } } #endif namespace rclcpp { enum class SignalHandlerOptions { All, SigInt, SigTerm, None, }; RCLCPP_PUBLIC void init( int argc, char const * const * argv, const InitOptions & init_options = InitOptions(), SignalHandlerOptions signal_handler_options = SignalHandlerOptions::All); RCLCPP_PUBLIC bool install_signal_handlers(SignalHandlerOptions signal_handler_options = SignalHandlerOptions::All); RCLCPP_PUBLIC bool signal_handlers_installed(); RCLCPP_PUBLIC SignalHandlerOptions get_current_signal_handler_options(); RCLCPP_PUBLIC bool uninstall_signal_handlers(); RCLCPP_PUBLIC std::vector init_and_remove_ros_arguments( int argc, char const * const * argv, const InitOptions & init_options = InitOptions()); RCLCPP_PUBLIC std::vector remove_ros_arguments(int argc, char const * const * argv); RCLCPP_PUBLIC bool ok(rclcpp::Context::SharedPtr context = nullptr); RCLCPP_PUBLIC bool shutdown( rclcpp::Context::SharedPtr context = nullptr, const std::string & reason = "user called rclcpp::shutdown()"); RCLCPP_PUBLIC void on_shutdown(std::function callback, rclcpp::Context::SharedPtr context = nullptr); RCLCPP_PUBLIC bool sleep_for( const std::chrono::nanoseconds & nanoseconds, rclcpp::Context::SharedPtr context = nullptr); template bool add_will_overflow(const T x, const T y) { return (y > 0) && (x > (std::numeric_limits::max() - y)); } template bool add_will_underflow(const T x, const T y) { return (y < 0) && (x < (std::numeric_limits::min() - y)); } template bool sub_will_overflow(const T x, const T y) { return (y < 0) && (x > (std::numeric_limits::max() + y)); } template bool sub_will_underflow(const T x, const T y) { return (y > 0) && (x < (std::numeric_limits::min() + y)); } RCLCPP_PUBLIC const char * get_c_string(const char * string_in); RCLCPP_PUBLIC const char * get_c_string(const std::string & string_in); RCLCPP_PUBLIC std::vector get_c_vector_string(const std::vector & strings_in); } // namespace rclcpp #endif // RCLCPP__UTILITIES_HPP_