Skip to content

Commit

Permalink
Remove inner RCL public macros for each of the modified classes and i…
Browse files Browse the repository at this point in the history
…ntroduce a separate configure_rclcpp.cmake

Signed-off-by: Sachin Suresh Bhat <[email protected]>
  • Loading branch information
bhatsach committed Feb 27, 2019
1 parent 6f15f30 commit 1459878
Show file tree
Hide file tree
Showing 17 changed files with 71 additions and 237 deletions.
3 changes: 2 additions & 1 deletion rclcpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
endif()

include_directories(include)
include(cmake/configure_rclcpp.cmake)

set(${PROJECT_NAME}_SRCS
src/rclcpp/any_executable.cpp
Expand Down Expand Up @@ -109,7 +110,7 @@ ament_target_dependencies(${PROJECT_NAME}
"rosidl_typesupport_cpp"
"rosidl_generator_cpp")

configure_rcl(${PROJECT_NAME})
configure_rclcpp(${PROJECT_NAME})
# Causes the visibility macros to use dllexport rather than dllimport,
# which is appropriate when building the dll but not consuming it.
target_compile_definitions(${PROJECT_NAME}
Expand Down
66 changes: 66 additions & 0 deletions rclcpp/cmake/configure_rclcpp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Copyright 2019 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.
#
# Configures ros client library with custom settings.
# The custom settings are all related to library symbol visibility, see:
# https://gcc.gnu.org/wiki/Visibility
# http://www.ibm.com/developerworks/aix/library/au-aix-symbol-visibility/
#
# Below code is heavily referenced from a similar functionality in rmw:
# https://github.com/ros2/rmw/blob/master/rmw/cmake/configure_rmw_library.cmake
#
# :param library_target: the library target
# :type library_target: string
# :param LANGUAGE: Optional flag for the language of the library.
# Allowed values are "C" and "CXX". The default is "CXX".
# :type LANGUAGE: string
#
# @public
#
macro(configure_rclcpp library_target)
cmake_parse_arguments(_ARG "" "LANGUAGE" "" ${ARGN})
if(_ARG_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "configure_rclcpp() called with unused arguments: ${_ARG_UNPARSED_ARGUMENTS}")
endif()

if(NOT _ARG_LANGUAGE)
set(_ARG_LANGUAGE "CXX")
endif()

if(_ARG_LANGUAGE STREQUAL "C")
# Set the visibility to hidden by default if possible
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
# Set the visibility of symbols to hidden by default for gcc and clang
# (this is already the default on Windows)
set_target_properties(${library_target}
PROPERTIES
COMPILE_FLAGS "-fvisibility=hidden"
)
endif()

elseif(_ARG_LANGUAGE STREQUAL "CXX")
# Set the visibility to hidden by default if possible
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# Set the visibility of symbols to hidden by default for gcc and clang
# (this is already the default on Windows)
set_target_properties(${library_target}
PROPERTIES
COMPILE_FLAGS "-fvisibility=hidden -fvisibility-inlines-hidden"
)
endif()

else()
message(FATAL_ERROR "configure_rclcpp() called with unsupported LANGUAGE: '${_ARG_LANGUAGE}'")
endif()
endmacro()
9 changes: 0 additions & 9 deletions rclcpp/include/rclcpp/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,21 @@ class RCLCPP_PUBLIC ClientBase
public:
RCLCPP_SMART_PTR_DEFINITIONS_NOT_COPYABLE(ClientBase)

RCLCPP_PUBLIC
ClientBase(
rclcpp::node_interfaces::NodeBaseInterface * node_base,
rclcpp::node_interfaces::NodeGraphInterface::SharedPtr node_graph);

RCLCPP_PUBLIC
virtual ~ClientBase();

RCLCPP_PUBLIC
const char *
get_service_name() const;

RCLCPP_PUBLIC
std::shared_ptr<rcl_client_t>
get_client_handle();

RCLCPP_PUBLIC
std::shared_ptr<const rcl_client_t>
get_client_handle() const;

RCLCPP_PUBLIC
bool
service_is_ready() const;

Expand All @@ -96,15 +90,12 @@ class RCLCPP_PUBLIC ClientBase
protected:
RCLCPP_DISABLE_COPY(ClientBase)

RCLCPP_PUBLIC
bool
wait_for_service_nanoseconds(std::chrono::nanoseconds timeout);

RCLCPP_PUBLIC
rcl_node_t *
get_rcl_node_handle();

RCLCPP_PUBLIC
const rcl_node_t *
get_rcl_node_handle() const;

Expand Down
25 changes: 0 additions & 25 deletions rclcpp/include/rclcpp/executor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,9 @@ class RCLCPP_PUBLIC Executor

/// Default constructor.
// \param[in] ms The memory strategy to be used with this executor.
RCLCPP_PUBLIC
explicit Executor(const ExecutorArgs & args = ExecutorArgs());

/// Default destructor.
RCLCPP_PUBLIC
virtual ~Executor();

/// Do work periodically as it becomes available to us. Blocking call, may block indefinitely.
Expand All @@ -119,12 +117,10 @@ class RCLCPP_PUBLIC Executor
* the executor is blocked at the rmw layer while waiting for work and it is notified that a new
* node was added, it will wake up.
*/
RCLCPP_PUBLIC
virtual void
add_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr, bool notify = true);

/// Convenience function which takes Node and forwards NodeBaseInterface.
RCLCPP_PUBLIC
virtual void
add_node(std::shared_ptr<rclcpp::Node> node_ptr, bool notify = true);

Expand All @@ -135,12 +131,10 @@ class RCLCPP_PUBLIC Executor
* This is useful if the last node was removed from the executor while the executor was blocked
* waiting for work in another thread, because otherwise the executor would never be notified.
*/
RCLCPP_PUBLIC
virtual void
remove_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr, bool notify = true);

/// Convenience function which takes Node and forwards NodeBaseInterface.
RCLCPP_PUBLIC
virtual void
remove_node(std::shared_ptr<rclcpp::Node> node_ptr, bool notify = true);

Expand Down Expand Up @@ -180,12 +174,10 @@ class RCLCPP_PUBLIC Executor
/**
* \param[in] node Shared pointer to the node to add.
*/
RCLCPP_PUBLIC
void
spin_node_some(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node);

/// Convenience function which takes Node and forwards NodeBaseInterface.
RCLCPP_PUBLIC
void
spin_node_some(std::shared_ptr<rclcpp::Node> node);

Expand All @@ -200,11 +192,9 @@ class RCLCPP_PUBLIC Executor
* Note that spin_some() may take longer than this time as it only returns once max_duration has
* been exceeded.
*/
RCLCPP_PUBLIC
virtual void
spin_some(std::chrono::nanoseconds max_duration = std::chrono::nanoseconds(0));

RCLCPP_PUBLIC
virtual void
spin_once(std::chrono::nanoseconds timeout = std::chrono::nanoseconds(-1));

Expand Down Expand Up @@ -269,7 +259,6 @@ class RCLCPP_PUBLIC Executor

/// Cancel any running spin* function, causing it to return.
/* This function can be called asynchonously from any thread. */
RCLCPP_PUBLIC
void
cancel();

Expand All @@ -279,12 +268,10 @@ class RCLCPP_PUBLIC Executor
* unintended consequences.
* \param[in] memory_strategy Shared pointer to the memory strategy to set.
*/
RCLCPP_PUBLIC
void
set_memory_strategy(memory_strategy::MemoryStrategy::SharedPtr memory_strategy);

protected:
RCLCPP_PUBLIC
void
spin_node_once_nanoseconds(
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node,
Expand All @@ -294,53 +281,41 @@ class RCLCPP_PUBLIC Executor
/** \param[in] any_exec Union structure that can hold any executable type (timer, subscription,
* service, client).
*/
RCLCPP_PUBLIC
void
execute_any_executable(AnyExecutable & any_exec);

RCLCPP_PUBLIC
static void
execute_subscription(
rclcpp::SubscriptionBase::SharedPtr subscription);

RCLCPP_PUBLIC
static void
execute_intra_process_subscription(
rclcpp::SubscriptionBase::SharedPtr subscription);

RCLCPP_PUBLIC
static void
execute_timer(rclcpp::TimerBase::SharedPtr timer);

RCLCPP_PUBLIC
static void
execute_service(rclcpp::ServiceBase::SharedPtr service);

RCLCPP_PUBLIC
static void
execute_client(rclcpp::ClientBase::SharedPtr client);

RCLCPP_PUBLIC
void
wait_for_work(std::chrono::nanoseconds timeout = std::chrono::nanoseconds(-1));

RCLCPP_PUBLIC
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr
get_node_by_group(rclcpp::callback_group::CallbackGroup::SharedPtr group);

RCLCPP_PUBLIC
rclcpp::callback_group::CallbackGroup::SharedPtr
get_group_by_timer(rclcpp::TimerBase::SharedPtr timer);

RCLCPP_PUBLIC
void
get_next_timer(AnyExecutable & any_exec);

RCLCPP_PUBLIC
bool
get_next_ready_executable(AnyExecutable & any_executable);

RCLCPP_PUBLIC
bool
get_next_executable(
AnyExecutable & any_executable,
Expand Down
8 changes: 0 additions & 8 deletions rclcpp/include/rclcpp/intra_process_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,9 @@ class RCLCPP_PUBLIC IntraProcessManager
public:
RCLCPP_SMART_PTR_DEFINITIONS(IntraProcessManager)

RCLCPP_PUBLIC
explicit IntraProcessManager(
IntraProcessManagerImplBase::SharedPtr state = create_default_impl());

RCLCPP_PUBLIC
virtual ~IntraProcessManager();

/// Register a subscription with the manager, returns subscriptions unique id.
Expand All @@ -147,7 +145,6 @@ class RCLCPP_PUBLIC IntraProcessManager
* \param subscription the Subscription to register.
* \return an unsigned 64-bit integer which is the subscription's unique id.
*/
RCLCPP_PUBLIC
uint64_t
add_subscription(SubscriptionBase::SharedPtr subscription);

Expand All @@ -157,7 +154,6 @@ class RCLCPP_PUBLIC IntraProcessManager
*
* \param intra_process_subscription_id id of the subscription to remove.
*/
RCLCPP_PUBLIC
void
remove_subscription(uint64_t intra_process_subscription_id);

Expand Down Expand Up @@ -206,7 +202,6 @@ class RCLCPP_PUBLIC IntraProcessManager
*
* \param intra_process_publisher_id id of the publisher to remove.
*/
RCLCPP_PUBLIC
void
remove_publisher(uint64_t intra_process_publisher_id);

Expand Down Expand Up @@ -342,17 +337,14 @@ class RCLCPP_PUBLIC IntraProcessManager
}

/// Return true if the given rmw_gid_t matches any stored Publishers.
RCLCPP_PUBLIC
bool
matches_any_publishers(const rmw_gid_t * id) const;

/// Return the number of intraprocess subscriptions to a topic, given the publisher id.
RCLCPP_PUBLIC
size_t
get_subscription_count(uint64_t intra_process_publisher_id) const;

private:
RCLCPP_PUBLIC
static uint64_t
get_next_unique_id();

Expand Down
Loading

0 comments on commit 1459878

Please sign in to comment.