From 51695d1b246d6c34bd72e925547b5e3bafcffc4f Mon Sep 17 00:00:00 2001 From: William Woodall Date: Thu, 5 Nov 2015 12:59:57 -0800 Subject: [PATCH] [style] cpplint/uncrustify --- .../rclcpp/allocator/allocator_deleter.hpp | 2 +- rclcpp/include/rclcpp/any_executable.hpp | 14 +-- .../include/rclcpp/any_service_callback.hpp | 15 ++- .../rclcpp/any_subscription_callback.hpp | 1 + rclcpp/include/rclcpp/callback_group.hpp | 21 ++-- rclcpp/include/rclcpp/client.hpp | 28 +++--- rclcpp/include/rclcpp/context.hpp | 18 ++-- .../rclcpp/contexts/default_context.hpp | 14 +-- rclcpp/include/rclcpp/executors.hpp | 15 +-- .../executors/multi_threaded_executor.hpp | 10 +- rclcpp/include/rclcpp/function_traits.hpp | 13 ++- .../rclcpp/intra_process_manager_state.hpp | 12 +-- rclcpp/include/rclcpp/macros.hpp | 7 +- rclcpp/include/rclcpp/memory_strategies.hpp | 3 +- .../rclcpp/message_memory_strategy.hpp | 1 + rclcpp/include/rclcpp/parameter.hpp | 42 ++++---- rclcpp/include/rclcpp/parameter_client.hpp | 11 +-- rclcpp/include/rclcpp/parameter_service.hpp | 13 +-- rclcpp/include/rclcpp/rate.hpp | 15 ++- rclcpp/include/rclcpp/rclcpp.hpp | 22 ++--- rclcpp/include/rclcpp/service.hpp | 24 ++--- .../strategies/allocator_memory_strategy.hpp | 3 - .../message_pool_memory_strategy.hpp | 5 +- rclcpp/include/rclcpp/subscription.hpp | 2 +- rclcpp/include/rclcpp/timer.hpp | 22 ++--- rclcpp/include/rclcpp/utilities.hpp | 6 +- rclcpp/test/test_function_traits.cpp | 52 +++++++--- rclcpp/test/test_intra_process_manager.cpp | 98 +++++++++++-------- 28 files changed, 254 insertions(+), 235 deletions(-) diff --git a/rclcpp/include/rclcpp/allocator/allocator_deleter.hpp b/rclcpp/include/rclcpp/allocator/allocator_deleter.hpp index c3b59f2..ff79c40 100644 --- a/rclcpp/include/rclcpp/allocator/allocator_deleter.hpp +++ b/rclcpp/include/rclcpp/allocator/allocator_deleter.hpp @@ -16,10 +16,10 @@ #define RCLCPP__ALLOCATOR__ALLOCATOR_DELETER_HPP_ #include +#include namespace rclcpp { - namespace allocator { diff --git a/rclcpp/include/rclcpp/any_executable.hpp b/rclcpp/include/rclcpp/any_executable.hpp index 46950f4..6f886fd 100644 --- a/rclcpp/include/rclcpp/any_executable.hpp +++ b/rclcpp/include/rclcpp/any_executable.hpp @@ -12,13 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef RCLCPP_RCLCPP_ANY_EXECUTABLE_HPP_ -#define RCLCPP_RCLCPP_ANY_EXECUTABLE_HPP_ +#ifndef RCLCPP__ANY_EXECUTABLE_HPP_ +#define RCLCPP__ANY_EXECUTABLE_HPP_ #include -#include -#include +#include "rclcpp/macros.hpp" +#include "rclcpp/node.hpp" #include "rclcpp/visibility_control.hpp" namespace rclcpp @@ -44,7 +44,7 @@ struct AnyExecutable rclcpp::node::Node::SharedPtr node; }; -} /* executor */ -} /* rclcpp */ +} // namespace executor +} // namespace rclcpp -#endif +#endif // RCLCPP__ANY_EXECUTABLE_HPP_ diff --git a/rclcpp/include/rclcpp/any_service_callback.hpp b/rclcpp/include/rclcpp/any_service_callback.hpp index e77040a..3913672 100644 --- a/rclcpp/include/rclcpp/any_service_callback.hpp +++ b/rclcpp/include/rclcpp/any_service_callback.hpp @@ -12,18 +12,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef RCLCPP_RCLCPP_ANY_SERVICE_CALLBACK_HPP_ -#define RCLCPP_RCLCPP_ANY_SERVICE_CALLBACK_HPP_ - -#include +#ifndef RCLCPP__ANY_SERVICE_CALLBACK_HPP_ +#define RCLCPP__ANY_SERVICE_CALLBACK_HPP_ #include #include +#include #include -#include #include "rclcpp/function_traits.hpp" #include "rclcpp/visibility_control.hpp" +#include "rmw/types.h" namespace rclcpp { @@ -99,7 +98,7 @@ public: } }; -} /* namespace any_service_callback */ -} /* namespace rclcpp */ +} // namespace any_service_callback +} // namespace rclcpp -#endif /* RCLCPP_RCLCPP_ANY_SERVICE_CALLBACK_HPP_ */ +#endif // RCLCPP__ANY_SERVICE_CALLBACK_HPP_ diff --git a/rclcpp/include/rclcpp/any_subscription_callback.hpp b/rclcpp/include/rclcpp/any_subscription_callback.hpp index 555d1d7..a52e8d9 100644 --- a/rclcpp/include/rclcpp/any_subscription_callback.hpp +++ b/rclcpp/include/rclcpp/any_subscription_callback.hpp @@ -19,6 +19,7 @@ #include #include +#include #include #include "rclcpp/allocator/allocator_common.hpp" diff --git a/rclcpp/include/rclcpp/callback_group.hpp b/rclcpp/include/rclcpp/callback_group.hpp index deb395e..63ebca8 100644 --- a/rclcpp/include/rclcpp/callback_group.hpp +++ b/rclcpp/include/rclcpp/callback_group.hpp @@ -12,17 +12,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef RCLCPP_RCLCPP_CALLBACK_GROUP_HPP_ -#define RCLCPP_RCLCPP_CALLBACK_GROUP_HPP_ +#ifndef RCLCPP__CALLBACK_GROUP_HPP_ +#define RCLCPP__CALLBACK_GROUP_HPP_ #include #include #include -#include -#include -#include -#include +#include "rclcpp/client.hpp" +#include "rclcpp/service.hpp" +#include "rclcpp/subscription.hpp" +#include "rclcpp/timer.hpp" #include "rclcpp/visibility_control.hpp" namespace rclcpp @@ -32,7 +32,7 @@ namespace rclcpp namespace node { class Node; -} // namespace node +} // namespace node namespace callback_group { @@ -102,10 +102,9 @@ private: std::vector service_ptrs_; std::vector client_ptrs_; std::atomic_bool can_be_taken_from_; - }; -} /* namespace callback_group */ -} /* namespace rclcpp */ +} // namespace callback_group +} // namespace rclcpp -#endif /* RCLCPP_RCLCPP_CALLBACK_GROUP_HPP_ */ +#endif // RCLCPP__CALLBACK_GROUP_HPP_ diff --git a/rclcpp/include/rclcpp/client.hpp b/rclcpp/include/rclcpp/client.hpp index dab0025..ba087f4 100644 --- a/rclcpp/include/rclcpp/client.hpp +++ b/rclcpp/include/rclcpp/client.hpp @@ -12,32 +12,30 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef RCLCPP_RCLCPP_CLIENT_HPP_ -#define RCLCPP_RCLCPP_CLIENT_HPP_ +#ifndef RCLCPP__CLIENT_HPP_ +#define RCLCPP__CLIENT_HPP_ #include -#include #include #include #include +#include +#include #include -#include -#include - -#include -#include +#include "rclcpp/macros.hpp" +#include "rclcpp/utilities.hpp" #include "rclcpp/visibility_control.hpp" +#include "rmw/error_handling.h" +#include "rmw/rmw.h" namespace rclcpp { - namespace client { class ClientBase { - public: RCLCPP_SMART_PTR_DEFINITIONS_NOT_COPYABLE(ClientBase); @@ -70,7 +68,6 @@ private: rmw_client_t * client_handle_; std::string service_name_; - }; template @@ -109,7 +106,8 @@ public: auto typed_request_header = std::static_pointer_cast(request_header); auto typed_response = std::static_pointer_cast(response); int64_t sequence_number = typed_request_header->sequence_number; - // TODO this must check if the sequence_number is valid otherwise the call_promise will be null + // TODO(esteve) this must check if the sequence_number is valid otherwise the + // call_promise will be null auto tuple = this->pending_requests_[sequence_number]; auto call_promise = std::get<0>(tuple); auto callback = std::get<1>(tuple); @@ -149,7 +147,7 @@ private: std::map> pending_requests_; }; -} /* namespace client */ -} /* namespace rclcpp */ +} // namespace client +} // namespace rclcpp -#endif /* RCLCPP_RCLCPP_CLIENT_HPP_ */ +#endif // RCLCPP__CLIENT_HPP_ diff --git a/rclcpp/include/rclcpp/context.hpp b/rclcpp/include/rclcpp/context.hpp index b800772..e06146f 100644 --- a/rclcpp/include/rclcpp/context.hpp +++ b/rclcpp/include/rclcpp/context.hpp @@ -12,22 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef RCLCPP_RCLCPP_CONTEXT_HPP_ -#define RCLCPP_RCLCPP_CONTEXT_HPP_ - -#include +#ifndef RCLCPP__CONTEXT_HPP_ +#define RCLCPP__CONTEXT_HPP_ #include - #include #include -#include #include +#include #include -#include #include "rclcpp/macros.hpp" #include "rclcpp/visibility_control.hpp" +#include "rmw/rmw.h" namespace rclcpp { @@ -73,10 +70,9 @@ private: std::unordered_map> sub_contexts_; std::mutex mutex_; - }; -} /* namespace context */ -} /* namespace rclcpp */ +} // namespace context +} // namespace rclcpp -#endif /* RCLCPP_RCLCPP_CONTEXT_HPP_ */ +#endif // RCLCPP__CONTEXT_HPP_ diff --git a/rclcpp/include/rclcpp/contexts/default_context.hpp b/rclcpp/include/rclcpp/contexts/default_context.hpp index 2c70714..757a767 100644 --- a/rclcpp/include/rclcpp/contexts/default_context.hpp +++ b/rclcpp/include/rclcpp/contexts/default_context.hpp @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef RCLCPP_RCLCPP_CONTEXTS_DEFAULT_CONTEXT_HPP_ -#define RCLCPP_RCLCPP_CONTEXTS_DEFAULT_CONTEXT_HPP_ +#ifndef RCLCPP__CONTEXTS__DEFAULT_CONTEXT_HPP_ +#define RCLCPP__CONTEXTS__DEFAULT_CONTEXT_HPP_ -#include +#include "rclcpp/context.hpp" #include "rclcpp/visibility_control.hpp" namespace rclcpp @@ -38,8 +38,8 @@ RCLCPP_PUBLIC DefaultContext::SharedPtr get_global_default_context(); -} // namespace default_context -} // namespace contexts -} // namespace rclcpp +} // namespace default_context +} // namespace contexts +} // namespace rclcpp -#endif /* RCLCPP_RCLCPP_CONTEXTS_DEFAULT_CONTEXT_HPP_ */ +#endif // RCLCPP__CONTEXTS__DEFAULT_CONTEXT_HPP_ diff --git a/rclcpp/include/rclcpp/executors.hpp b/rclcpp/include/rclcpp/executors.hpp index 64aaa20..310040c 100644 --- a/rclcpp/include/rclcpp/executors.hpp +++ b/rclcpp/include/rclcpp/executors.hpp @@ -12,14 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef RCLCPP_RCLCPP_EXECUTORS_HPP_ -#define RCLCPP_RCLCPP_EXECUTORS_HPP_ +#ifndef RCLCPP__EXECUTORS_HPP_ +#define RCLCPP__EXECUTORS_HPP_ #include -#include -#include -#include -#include + +#include "rclcpp/executors/multi_threaded_executor.hpp" +#include "rclcpp/executors/single_threaded_executor.hpp" +#include "rclcpp/node.hpp" +#include "rclcpp/utilities.hpp" #include "rclcpp/visibility_control.hpp" namespace rclcpp @@ -108,4 +109,4 @@ spin_until_future_complete( } // namespace rclcpp -#endif /* RCLCPP_RCLCPP_EXECUTORS_HPP_ */ +#endif // RCLCPP__EXECUTORS_HPP_ diff --git a/rclcpp/include/rclcpp/executors/multi_threaded_executor.hpp b/rclcpp/include/rclcpp/executors/multi_threaded_executor.hpp index 7b57eb0..30ca1b0 100644 --- a/rclcpp/include/rclcpp/executors/multi_threaded_executor.hpp +++ b/rclcpp/include/rclcpp/executors/multi_threaded_executor.hpp @@ -15,18 +15,12 @@ #ifndef RCLCPP__EXECUTORS__MULTI_THREADED_EXECUTOR_HPP_ #define RCLCPP__EXECUTORS__MULTI_THREADED_EXECUTOR_HPP_ -#include - -#include -#include -#include #include -#include +#include +#include #include "rclcpp/executor.hpp" #include "rclcpp/macros.hpp" -#include "rclcpp/node.hpp" -#include "rclcpp/utilities.hpp" #include "rclcpp/memory_strategies.hpp" #include "rclcpp/visibility_control.hpp" diff --git a/rclcpp/include/rclcpp/function_traits.hpp b/rclcpp/include/rclcpp/function_traits.hpp index 639d8d1..8cd2d02 100644 --- a/rclcpp/include/rclcpp/function_traits.hpp +++ b/rclcpp/include/rclcpp/function_traits.hpp @@ -12,9 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef RCLCPP_RCLCPP_FUNCTION_TRAITS_HPP_ -#define RCLCPP_RCLCPP_FUNCTION_TRAITS_HPP_ +#ifndef RCLCPP__FUNCTION_TRAITS_HPP_ +#define RCLCPP__FUNCTION_TRAITS_HPP_ + #include +#include + +#include "rclcpp/visibility_control.hpp" namespace rclcpp { @@ -95,6 +99,7 @@ struct same_arguments : std::is_same< typename function_traits::arguments > {}; -} /* namespace rclcpp */ -#endif /* RCLCPP_RCLCPP_FUNCTION_TRAITS_HPP_ */ +} // namespace rclcpp + +#endif // RCLCPP__FUNCTION_TRAITS_HPP_ diff --git a/rclcpp/include/rclcpp/intra_process_manager_state.hpp b/rclcpp/include/rclcpp/intra_process_manager_state.hpp index f35c8d8..0649505 100644 --- a/rclcpp/include/rclcpp/intra_process_manager_state.hpp +++ b/rclcpp/include/rclcpp/intra_process_manager_state.hpp @@ -15,21 +15,21 @@ #ifndef RCLCPP__INTRA_PROCESS_MANAGER_STATE_HPP_ #define RCLCPP__INTRA_PROCESS_MANAGER_STATE_HPP_ -#include -#include -#include - #include #include #include #include -#include #include -#include +#include #include #include +#include #include +#include "rclcpp/macros.hpp" +#include "rclcpp/mapped_ring_buffer.hpp" +#include "rclcpp/publisher.hpp" +#include "rclcpp/subscription.hpp" #include "rclcpp/visibility_control.hpp" namespace rclcpp diff --git a/rclcpp/include/rclcpp/macros.hpp b/rclcpp/include/rclcpp/macros.hpp index c9e5936..b22067d 100644 --- a/rclcpp/include/rclcpp/macros.hpp +++ b/rclcpp/include/rclcpp/macros.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef RCLCPP_RCLCPP_MACROS_HPP_ -#define RCLCPP_RCLCPP_MACROS_HPP_ +#ifndef RCLCPP__MACROS_HPP_ +#define RCLCPP__MACROS_HPP_ /* Disables the copy constructor and operator= for the given class. * @@ -76,6 +76,7 @@ { \ return std::unique_ptr<__VA_ARGS__>(new __VA_ARGS__(std::forward(args) ...)); \ } + /// Defines aliases and static functions for using the Class with unique_ptrs. #define RCLCPP_UNIQUE_PTR_DEFINITIONS(...) \ __RCLCPP_UNIQUE_PTR_ALIAS(__VA_ARGS__) \ @@ -83,4 +84,4 @@ #define RCLCPP_INFO(Args) std::cout << Args << std::endl; -#endif /* RCLCPP_RCLCPP_MACROS_HPP_ */ +#endif // RCLCPP__MACROS_HPP_ diff --git a/rclcpp/include/rclcpp/memory_strategies.hpp b/rclcpp/include/rclcpp/memory_strategies.hpp index d938840..a3950d9 100644 --- a/rclcpp/include/rclcpp/memory_strategies.hpp +++ b/rclcpp/include/rclcpp/memory_strategies.hpp @@ -15,8 +15,7 @@ #ifndef RCLCPP__MEMORY_STRATEGIES_HPP_ #define RCLCPP__MEMORY_STRATEGIES_HPP_ -#include -#include +#include "rclcpp/memory_strategy.hpp" #include "rclcpp/visibility_control.hpp" namespace rclcpp diff --git a/rclcpp/include/rclcpp/message_memory_strategy.hpp b/rclcpp/include/rclcpp/message_memory_strategy.hpp index 00b2a9a..fc764af 100644 --- a/rclcpp/include/rclcpp/message_memory_strategy.hpp +++ b/rclcpp/include/rclcpp/message_memory_strategy.hpp @@ -16,6 +16,7 @@ #define RCLCPP__MESSAGE_MEMORY_STRATEGY_HPP_ #include +#include #include "rclcpp/allocator/allocator_common.hpp" #include "rclcpp/macros.hpp" diff --git a/rclcpp/include/rclcpp/parameter.hpp b/rclcpp/include/rclcpp/parameter.hpp index 6c036e5..271960b 100644 --- a/rclcpp/include/rclcpp/parameter.hpp +++ b/rclcpp/include/rclcpp/parameter.hpp @@ -12,35 +12,33 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef RCLCPP_RCLCPP_PARAMETER_HPP_ -#define RCLCPP_RCLCPP_PARAMETER_HPP_ +#ifndef RCLCPP__PARAMETER_HPP_ +#define RCLCPP__PARAMETER_HPP_ #include #include #include +#include -#include - -#include -#include -#include +#include "rcl_interfaces/msg/parameter.hpp" +#include "rcl_interfaces/msg/parameter_type.hpp" +#include "rcl_interfaces/msg/parameter_value.hpp" #include "rclcpp/visibility_control.hpp" #include "rmw/rmw.h" namespace rclcpp { - namespace parameter { enum ParameterType { - PARAMETER_NOT_SET=rcl_interfaces::msg::ParameterType::PARAMETER_NOT_SET, - PARAMETER_BOOL=rcl_interfaces::msg::ParameterType::PARAMETER_BOOL, - PARAMETER_INTEGER=rcl_interfaces::msg::ParameterType::PARAMETER_INTEGER, - PARAMETER_DOUBLE=rcl_interfaces::msg::ParameterType::PARAMETER_DOUBLE, - PARAMETER_STRING=rcl_interfaces::msg::ParameterType::PARAMETER_STRING, - PARAMETER_BYTES=rcl_interfaces::msg::ParameterType::PARAMETER_BYTES, + PARAMETER_NOT_SET = rcl_interfaces::msg::ParameterType::PARAMETER_NOT_SET, + PARAMETER_BOOL = rcl_interfaces::msg::ParameterType::PARAMETER_BOOL, + PARAMETER_INTEGER = rcl_interfaces::msg::ParameterType::PARAMETER_INTEGER, + PARAMETER_DOUBLE = rcl_interfaces::msg::ParameterType::PARAMETER_DOUBLE, + PARAMETER_STRING = rcl_interfaces::msg::ParameterType::PARAMETER_STRING, + PARAMETER_BYTES = rcl_interfaces::msg::ParameterType::PARAMETER_BYTES, }; // Structure to store an arbitrary parameter with templated get/set methods @@ -87,48 +85,52 @@ public: get_value() const { if (value_.type != rcl_interfaces::msg::ParameterType::PARAMETER_INTEGER) { - // TODO: use custom exception + // TODO(wjwwood): use custom exception throw std::runtime_error("Invalid type"); } return value_.integer_value; } + template typename std::enable_if::type get_value() const { if (value_.type != rcl_interfaces::msg::ParameterType::PARAMETER_DOUBLE) { - // TODO: use custom exception + // TODO(wjwwood): use custom exception throw std::runtime_error("Invalid type"); } return value_.double_value; } + template typename std::enable_if::type get_value() const { if (value_.type != rcl_interfaces::msg::ParameterType::PARAMETER_STRING) { - // TODO: use custom exception + // TODO(wjwwood): use custom exception throw std::runtime_error("Invalid type"); } return value_.string_value; } + template typename std::enable_if::type get_value() const { if (value_.type != rcl_interfaces::msg::ParameterType::PARAMETER_BOOL) { - // TODO: use custom exception + // TODO(wjwwood): use custom exception throw std::runtime_error("Invalid type"); } return value_.bool_value; } + template typename std::enable_if &>::type get_value() const { if (value_.type != rcl_interfaces::msg::ParameterType::PARAMETER_BYTES) { - // TODO: use custom exception + // TODO(wjwwood): use custom exception throw std::runtime_error("Invalid type"); } return value_.bytes_value; @@ -203,4 +205,4 @@ to_string(const std::vector & parameters); } // namespace std -#endif /* RCLCPP_RCLCPP_PARAMETER_HPP_ */ +#endif // RCLCPP__PARAMETER_HPP_ diff --git a/rclcpp/include/rclcpp/parameter_client.hpp b/rclcpp/include/rclcpp/parameter_client.hpp index d748fee..3a09139 100644 --- a/rclcpp/include/rclcpp/parameter_client.hpp +++ b/rclcpp/include/rclcpp/parameter_client.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef RCLCPP_RCLCPP_PARAMETER_CLIENT_HPP_ -#define RCLCPP_RCLCPP_PARAMETER_CLIENT_HPP_ +#ifndef RCLCPP__PARAMETER_CLIENT_HPP_ +#define RCLCPP__PARAMETER_CLIENT_HPP_ #include #include @@ -162,8 +162,7 @@ private: AsyncParametersClient::SharedPtr async_parameters_client_; }; -} /* namespace parameter_client */ +} // namespace parameter_client +} // namespace rclcpp -} /* namespace rclcpp */ - -#endif /* RCLCPP_RCLCPP_PARAMETER_CLIENT_HPP_ */ +#endif // RCLCPP__PARAMETER_CLIENT_HPP_ diff --git a/rclcpp/include/rclcpp/parameter_service.hpp b/rclcpp/include/rclcpp/parameter_service.hpp index b350fe5..dbb1ce0 100644 --- a/rclcpp/include/rclcpp/parameter_service.hpp +++ b/rclcpp/include/rclcpp/parameter_service.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef RCLCPP_RCLCPP_PARAMETER_SERVICE_HPP_ -#define RCLCPP_RCLCPP_PARAMETER_SERVICE_HPP_ +#ifndef RCLCPP__PARAMETER_SERVICE_HPP_ +#define RCLCPP__PARAMETER_SERVICE_HPP_ #include @@ -32,13 +32,11 @@ namespace rclcpp { - namespace parameter_service { class ParameterService { - public: RCLCPP_SMART_PTR_DEFINITIONS(ParameterService); @@ -58,8 +56,7 @@ private: rclcpp::service::Service::SharedPtr list_parameters_service_; }; -} /* namespace parameter_service */ +} // namespace parameter_service +} // namespace rclcpp -} /* namespace rclcpp */ - -#endif /* RCLCPP_RCLCPP_PARAMETER_SERVICE_HPP_ */ +#endif // RCLCPP__PARAMETER_SERVICE_HPP_ diff --git a/rclcpp/include/rclcpp/rate.hpp b/rclcpp/include/rclcpp/rate.hpp index f4b6f70..4f25634 100644 --- a/rclcpp/include/rclcpp/rate.hpp +++ b/rclcpp/include/rclcpp/rate.hpp @@ -12,15 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef RCLCPP_RCLCPP_RATE_HPP_ -#define RCLCPP_RCLCPP_RATE_HPP_ +#ifndef RCLCPP__RATE_HPP_ +#define RCLCPP__RATE_HPP_ #include #include #include -#include -#include +#include "rclcpp/macros.hpp" +#include "rclcpp/utilities.hpp" #include "rclcpp/visibility_control.hpp" namespace rclcpp @@ -110,13 +110,12 @@ private: std::chrono::nanoseconds period_; std::chrono::time_point last_interval_; - }; using Rate = GenericRate; using WallRate = GenericRate; -} // namespace rate -} // namespace rclcpp +} // namespace rate +} // namespace rclcpp -#endif /* RCLCPP_RCLCPP_RATE_HPP_ */ +#endif // RCLCPP__RATE_HPP_ diff --git a/rclcpp/include/rclcpp/rclcpp.hpp b/rclcpp/include/rclcpp/rclcpp.hpp index ed7b081..b96da67 100644 --- a/rclcpp/include/rclcpp/rclcpp.hpp +++ b/rclcpp/include/rclcpp/rclcpp.hpp @@ -12,19 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef RCLCPP_RCLCPP_RCLCPP_HPP_ -#define RCLCPP_RCLCPP_RCLCPP_HPP_ +#ifndef RCLCPP__RCLCPP_HPP_ +#define RCLCPP__RCLCPP_HPP_ #include #include -#include -#include -#include -#include -#include -#include -#include +#include "rclcpp/executors.hpp" +#include "rclcpp/node.hpp" +#include "rclcpp/parameter.hpp" +#include "rclcpp/parameter_client.hpp" +#include "rclcpp/parameter_service.hpp" +#include "rclcpp/rate.hpp" +#include "rclcpp/utilities.hpp" #include "rclcpp/visibility_control.hpp" // NOLINTNEXTLINE(runtime/int) @@ -80,6 +80,6 @@ using rclcpp::utilities::shutdown; using rclcpp::utilities::init; using rclcpp::utilities::sleep_for; -} /* namespace rclcpp */ +} // namespace rclcpp -#endif /* RCLCPP_RCLCPP_RCLCPP_HPP_ */ +#endif // RCLCPP__RCLCPP_HPP_ diff --git a/rclcpp/include/rclcpp/service.hpp b/rclcpp/include/rclcpp/service.hpp index 169c0d6..84c2c99 100644 --- a/rclcpp/include/rclcpp/service.hpp +++ b/rclcpp/include/rclcpp/service.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef RCLCPP_RCLCPP_SERVICE_HPP_ -#define RCLCPP_RCLCPP_SERVICE_HPP_ +#ifndef RCLCPP__SERVICE_HPP_ +#define RCLCPP__SERVICE_HPP_ #include #include @@ -21,22 +21,19 @@ #include #include -#include -#include - -#include -#include +#include "rclcpp/any_service_callback.hpp" +#include "rclcpp/macros.hpp" #include "rclcpp/visibility_control.hpp" +#include "rmw/error_handling.h" +#include "rmw/rmw.h" namespace rclcpp { - namespace service { class ServiceBase { - public: RCLCPP_SMART_PTR_DEFINITIONS_NOT_COPYABLE(ServiceBase); @@ -70,10 +67,9 @@ private: rmw_service_t * service_handle_; std::string service_name_; - }; -using namespace any_service_callback; +using any_service_callback::AnyServiceCallback; template class Service : public ServiceBase @@ -141,7 +137,7 @@ private: AnyServiceCallback any_callback_; }; -} /* namespace service */ -} /* namespace rclcpp */ +} // namespace service +} // namespace rclcpp -#endif /* RCLCPP_RCLCPP_SERVICE_HPP_ */ +#endif // RCLCPP__SERVICE_HPP_ diff --git a/rclcpp/include/rclcpp/strategies/allocator_memory_strategy.hpp b/rclcpp/include/rclcpp/strategies/allocator_memory_strategy.hpp index 3bc602e..3824bf6 100644 --- a/rclcpp/include/rclcpp/strategies/allocator_memory_strategy.hpp +++ b/rclcpp/include/rclcpp/strategies/allocator_memory_strategy.hpp @@ -25,10 +25,8 @@ namespace rclcpp { - namespace memory_strategies { - namespace allocator_memory_strategy { @@ -313,7 +311,6 @@ private: } // namespace allocator_memory_strategy } // namespace memory_strategies - } // namespace rclcpp #endif // RCLCPP__STRATEGIES__ALLOCATOR_MEMORY_STRATEGY_HPP_ diff --git a/rclcpp/include/rclcpp/strategies/message_pool_memory_strategy.hpp b/rclcpp/include/rclcpp/strategies/message_pool_memory_strategy.hpp index 801a8f8..0a7ce22 100644 --- a/rclcpp/include/rclcpp/strategies/message_pool_memory_strategy.hpp +++ b/rclcpp/include/rclcpp/strategies/message_pool_memory_strategy.hpp @@ -15,8 +15,8 @@ #ifndef RCLCPP__STRATEGIES__MESSAGE_POOL_MEMORY_STRATEGY_HPP_ #define RCLCPP__STRATEGIES__MESSAGE_POOL_MEMORY_STRATEGY_HPP_ -#include -#include +#include "rclcpp/macros.hpp" +#include "rclcpp/message_memory_strategy.hpp" #include "rclcpp/visibility_control.hpp" namespace rclcpp @@ -106,4 +106,5 @@ protected: } // namespace message_pool_memory_strategy } // namespace strategies } // namespace rclcpp + #endif // RCLCPP__STRATEGIES__MESSAGE_POOL_MEMORY_STRATEGY_HPP_ diff --git a/rclcpp/include/rclcpp/subscription.hpp b/rclcpp/include/rclcpp/subscription.hpp index 8e5b06a..0044b20 100644 --- a/rclcpp/include/rclcpp/subscription.hpp +++ b/rclcpp/include/rclcpp/subscription.hpp @@ -147,7 +147,7 @@ public: bool ignore_local_publications, AnySubscriptionCallback callback, typename message_memory_strategy::MessageMemoryStrategy::SharedPtr - memory_strategy = message_memory_strategy::MessageMemoryStrategy::create_default()) : SubscriptionBase(node_handle, subscription_handle, topic_name, ignore_local_publications), any_callback_(callback), diff --git a/rclcpp/include/rclcpp/timer.hpp b/rclcpp/include/rclcpp/timer.hpp index b6a25b7..e418b79 100644 --- a/rclcpp/include/rclcpp/timer.hpp +++ b/rclcpp/include/rclcpp/timer.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef RCLCPP_RCLCPP_TIMER_HPP_ -#define RCLCPP_RCLCPP_TIMER_HPP_ +#ifndef RCLCPP__TIMER_HPP_ +#define RCLCPP__TIMER_HPP_ #include #include @@ -21,17 +21,15 @@ #include #include -#include -#include - -#include -#include -#include +#include "rclcpp/macros.hpp" +#include "rclcpp/rate.hpp" +#include "rclcpp/utilities.hpp" #include "rclcpp/visibility_control.hpp" +#include "rmw/error_handling.h" +#include "rmw/rmw.h" namespace rclcpp { - namespace timer { @@ -39,7 +37,6 @@ using CallbackType = std::function; class TimerBase { - public: RCLCPP_SMART_PTR_DEFINITIONS_NOT_COPYABLE(TimerBase); @@ -83,14 +80,12 @@ protected: CallbackType callback_; bool canceled_; - }; /// Generic timer templated on the clock type. Periodically executes a user-specified callback. template class GenericTimer : public TimerBase { - public: RCLCPP_SMART_PTR_DEFINITIONS(GenericTimer); @@ -158,7 +153,6 @@ private: rclcpp::rate::GenericRate loop_rate_; std::chrono::time_point last_triggered_time_; - }; using WallTimer = GenericTimer; @@ -166,4 +160,4 @@ using WallTimer = GenericTimer; } /* namespace timer */ } /* namespace rclcpp */ -#endif /* RCLCPP_RCLCPP_TIMER_HPP_ */ +#endif // RCLCPP__TIMER_HPP_ diff --git a/rclcpp/include/rclcpp/utilities.hpp b/rclcpp/include/rclcpp/utilities.hpp index 40e3345..1006152 100644 --- a/rclcpp/include/rclcpp/utilities.hpp +++ b/rclcpp/include/rclcpp/utilities.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef RCLCPP_RCLCPP_UTILITIES_HPP_ -#define RCLCPP_RCLCPP_UTILITIES_HPP_ +#ifndef RCLCPP__UTILITIES_HPP_ +#define RCLCPP__UTILITIES_HPP_ #include @@ -64,4 +64,4 @@ sleep_for(const std::chrono::nanoseconds & nanoseconds); } // namespace utilities } // namespace rclcpp -#endif /* RCLCPP_RCLCPP_UTILITIES_HPP_ */ +#endif // RCLCPP__UTILITIES_HPP_ diff --git a/rclcpp/test/test_function_traits.cpp b/rclcpp/test/test_function_traits.cpp index 0eb2c7f..e92420e 100644 --- a/rclcpp/test/test_function_traits.cpp +++ b/rclcpp/test/test_function_traits.cpp @@ -21,6 +21,7 @@ int func_no_args() return 0; } +// NOLINTNEXTLINE(readability/casting) int func_one_int(int) { return 1; @@ -142,15 +143,20 @@ TEST(TestFunctionTraits, arity) { return 0; }; - auto lambda_one_int = [](int) { + auto lambda_one_int = [](int one) { + (void)one; return 1; }; - auto lambda_two_ints = [](int, int) { + auto lambda_two_ints = [](int one, int two) { + (void)one; + (void)two; return 2; }; - auto lambda_one_int_one_char = [](int, char) { + auto lambda_one_int_one_char = [](int one, char two) { + (void)one; + (void)two; return 3; }; @@ -224,15 +230,20 @@ TEST(TestFunctionTraits, argument_types) { >::value, "Functor accepts a char as second argument"); // Test lambdas - auto lambda_one_int = [](int) { + auto lambda_one_int = [](int one) { + (void)one; return 1; }; - auto lambda_two_ints = [](int, int) { + auto lambda_two_ints = [](int one, int two) { + (void)one; + (void)two; return 2; }; - auto lambda_one_int_one_char = [](int, char) { + auto lambda_one_int_one_char = [](int one, char two) { + (void)one; + (void)two; return 3; }; @@ -336,15 +347,20 @@ TEST(TestFunctionTraits, check_arguments) { "Functor accepts an int and a char as arguments"); // Test lambdas - auto lambda_one_int = [](int) { + auto lambda_one_int = [](int one) { + (void)one; return 1; }; - auto lambda_two_ints = [](int, int) { + auto lambda_two_ints = [](int one, int two) { + (void)one; + (void)two; return 2; }; - auto lambda_one_int_one_char = [](int, char) { + auto lambda_one_int_one_char = [](int one, char two) { + (void)one; + (void)two; return 3; }; @@ -378,11 +394,14 @@ TEST(TestFunctionTraits, check_arguments) { Tests that same_arguments work. */ TEST(TestFunctionTraits, same_arguments) { - auto lambda_one_int = [](int) { + auto lambda_one_int = [](int one) { + (void)one; return 1; }; - auto lambda_two_ints = [](int, int) { + auto lambda_two_ints = [](int one, int two) { + (void)one; + (void)two; return 1; }; @@ -427,15 +446,20 @@ TEST(TestFunctionTraits, sfinae_match) { return 0; }; - auto lambda_one_int = [](int) { + auto lambda_one_int = [](int one) { + (void)one; return 1; }; - auto lambda_two_ints = [](int, int) { + auto lambda_two_ints = [](int one, int two) { + (void)one; + (void)two; return 2; }; - auto lambda_one_int_one_char = [](int, char) { + auto lambda_one_int_one_char = [](int one, char two) { + (void)one; + (void)two; return 3; }; diff --git a/rclcpp/test/test_intra_process_manager.cpp b/rclcpp/test/test_intra_process_manager.cpp index dd3c17b..6d511d9 100644 --- a/rclcpp/test/test_intra_process_manager.cpp +++ b/rclcpp/test/test_intra_process_manager.cpp @@ -13,12 +13,12 @@ // limitations under the License. #include +#include -#include - -#include -#include -#include +#include "gtest/gtest.h" +#include "rclcpp/allocator/allocator_common.hpp" +#include "rclcpp/macros.hpp" +#include "rmw/types.h" // Mock up publisher and subscription base to avoid needing an rmw impl. namespace rclcpp @@ -79,9 +79,9 @@ public: } }; -} -} -} +} // namespace mock +} // namespace publisher +} // namespace rclcpp namespace rclcpp { @@ -111,9 +111,9 @@ public: size_t mock_queue_size; }; -} -} -} +} // namespace mock +} // namespace subscription +} // namespace rclcpp // Prevent rclcpp/publisher.hpp and rclcpp/subscription.hpp from being imported. #define RCLCPP__PUBLISHER_HPP_ @@ -129,6 +129,7 @@ public: #undef Publisher #undef PublisherBase +// NOLINTNEXTLINE(build/include_order) #include /* @@ -144,13 +145,15 @@ public: TEST(TestIntraProcessManager, nominal) { rclcpp::intra_process_manager::IntraProcessManager ipm; - auto p1 = - std::make_shared>(); + auto p1 = std::make_shared< + rclcpp::publisher::mock::Publisher + >(); p1->mock_topic_name = "nominal1"; p1->mock_queue_size = 2; - auto p2 = - std::make_shared>(); + auto p2 = std::make_shared< + rclcpp::publisher::mock::Publisher + >(); p2->mock_topic_name = "nominal2"; p2->mock_queue_size = 10; @@ -233,8 +236,9 @@ TEST(TestIntraProcessManager, nominal) { TEST(TestIntraProcessManager, remove_publisher_before_trying_to_take) { rclcpp::intra_process_manager::IntraProcessManager ipm; - auto p1 = - std::make_shared>(); + auto p1 = std::make_shared< + rclcpp::publisher::mock::Publisher + >(); p1->mock_topic_name = "nominal1"; p1->mock_queue_size = 10; @@ -274,8 +278,9 @@ TEST(TestIntraProcessManager, remove_publisher_before_trying_to_take) { TEST(TestIntraProcessManager, removed_subscription_affects_take) { rclcpp::intra_process_manager::IntraProcessManager ipm; - auto p1 = - std::make_shared>(); + auto p1 = std::make_shared< + rclcpp::publisher::mock::Publisher + >(); p1->mock_topic_name = "nominal1"; p1->mock_queue_size = 10; @@ -344,8 +349,9 @@ TEST(TestIntraProcessManager, removed_subscription_affects_take) { TEST(TestIntraProcessManager, multiple_subscriptions_one_publisher) { rclcpp::intra_process_manager::IntraProcessManager ipm; - auto p1 = - std::make_shared>(); + auto p1 = std::make_shared< + rclcpp::publisher::mock::Publisher + >(); p1->mock_topic_name = "nominal1"; p1->mock_queue_size = 10; @@ -415,18 +421,21 @@ TEST(TestIntraProcessManager, multiple_subscriptions_one_publisher) { TEST(TestIntraProcessManager, multiple_publishers_one_subscription) { rclcpp::intra_process_manager::IntraProcessManager ipm; - auto p1 = - std::make_shared>(); + auto p1 = std::make_shared< + rclcpp::publisher::mock::Publisher + >(); p1->mock_topic_name = "nominal1"; p1->mock_queue_size = 10; - auto p2 = - std::make_shared>(); + auto p2 = std::make_shared< + rclcpp::publisher::mock::Publisher + >(); p2->mock_topic_name = "nominal1"; p2->mock_queue_size = 10; - auto p3 = - std::make_shared>(); + auto p3 = std::make_shared< + rclcpp::publisher::mock::Publisher + >(); p3->mock_topic_name = "nominal1"; p3->mock_queue_size = 10; @@ -512,18 +521,21 @@ TEST(TestIntraProcessManager, multiple_publishers_one_subscription) { TEST(TestIntraProcessManager, multiple_publishers_multiple_subscription) { rclcpp::intra_process_manager::IntraProcessManager ipm; - auto p1 = - std::make_shared>(); + auto p1 = std::make_shared< + rclcpp::publisher::mock::Publisher + >(); p1->mock_topic_name = "nominal1"; p1->mock_queue_size = 10; - auto p2 = - std::make_shared>(); + auto p2 = std::make_shared< + rclcpp::publisher::mock::Publisher + >(); p2->mock_topic_name = "nominal1"; p2->mock_queue_size = 10; - auto p3 = - std::make_shared>(); + auto p3 = std::make_shared< + rclcpp::publisher::mock::Publisher + >(); p3->mock_topic_name = "nominal1"; p3->mock_queue_size = 10; @@ -676,8 +688,9 @@ TEST(TestIntraProcessManager, multiple_publishers_multiple_subscription) { TEST(TestIntraProcessManager, ring_buffer_displacement) { rclcpp::intra_process_manager::IntraProcessManager ipm; - auto p1 = - std::make_shared>(); + auto p1 = std::make_shared< + rclcpp::publisher::mock::Publisher + >(); p1->mock_topic_name = "nominal1"; p1->mock_queue_size = 2; @@ -746,8 +759,9 @@ TEST(TestIntraProcessManager, ring_buffer_displacement) { TEST(TestIntraProcessManager, subscription_creation_race_condition) { rclcpp::intra_process_manager::IntraProcessManager ipm; - auto p1 = - std::make_shared>(); + auto p1 = std::make_shared< + rclcpp::publisher::mock::Publisher + >(); p1->mock_topic_name = "nominal1"; p1->mock_queue_size = 2; @@ -794,8 +808,9 @@ TEST(TestIntraProcessManager, publisher_out_of_scope_take) { uint64_t p1_id; uint64_t p1_m1_id; { - auto p1 = - std::make_shared>(); + auto p1 = std::make_shared< + rclcpp::publisher::mock::Publisher + >(); p1->mock_topic_name = "nominal1"; p1->mock_queue_size = 2; @@ -832,8 +847,9 @@ TEST(TestIntraProcessManager, publisher_out_of_scope_store) { uint64_t p1_id; { - auto p1 = - std::make_shared>(); + auto p1 = std::make_shared< + rclcpp::publisher::mock::Publisher + >(); p1->mock_topic_name = "nominal1"; p1->mock_queue_size = 2;