orocos-toolchain/rtt — pull request #14 by meyerj (2013-11-17 17:18:53+00:00)
Title: Remove duplicates from component/plugin search paths in ComponentLoader and PluginLoader

This patch removes duplicates from the search path for components and plugins.

The env-hook in `rtt_ros` sets the `RTT_COMPONENT_PATH` environment variable to list of all catkin devel- and install-spaces with the `lib/orocos` suffix appended to each of them. As the ComponentLoader and the PluginLoader append the default path to the contents of the environment variable and there is no other mechanism that checks if a directory has already been search during the import call, the package directories that are in the same workspace than rtt itself (like if everything is installed in `/opt/ros/hydro`) are imported twice:

```
[...]

(Initialization of the PluginLoader:)
0.001 [ Info ][Logger] RTT_COMPONENT_PATH was set to: /opt/orocos/hydro/lib/orocos:/opt/ros/hydro/lib/orocos . Searching in: /opt/orocos/hydro/lib/orocos:/opt/ros/hydro/lib/orocos:/opt/orocos/hydro/lib/orocos
0.001 [ Debug ][Logger] PluginLoader Created

[...]

(Initialization of the ComponentLoader:)
0.098 [ Info ][Logger] RTT_COMPONENT_PATH was set to: /opt/orocos/hydro/lib/orocos:/opt/ros/hydro/lib/orocos . Searching in: /opt/orocos/hydro/lib/orocos:/opt/ros/hydro/lib/orocos:/opt/orocos/hydro/lib/orocos
0.098 [ Info ][Logger] OCL factory set for real-time logging

[...]

Deployer [S]> import("rtt_ros")
7.050 [ Info ][DeploymentComponent::import] Importing directory /opt/orocos/hydro/lib/orocos/gnulinux/rtt_ros ...
7.050 [ Debug ][DeploymentComponent::import] Scanning file /opt/orocos/hydro/lib/orocos/gnulinux/rtt_ros/plugins ...not a regular file: ignored.
7.050 [ Debug ][DeploymentComponent::import] Looking for plugins or typekits in directory /opt/orocos/hydro/lib/orocos/gnulinux/rtt_ros ...
7.051 [ Debug ][DeploymentComponent::import] No such directory: "/opt/orocos/hydro/lib/orocos/gnulinux/rtt_ros/types"
7.051 [ Info ][DeploymentComponent::import] Loading plugin libraries from directory /opt/orocos/hydro/lib/orocos/gnulinux/rtt_ros/plugins ...
7.061 [ Debug ][DeploymentComponent::import] Scanning file /opt/orocos/hydro/lib/orocos/gnulinux/rtt_ros/plugins/librtt_ros-gnulinux.so ...Found library librtt_ros-gnulinux.so
7.061 [ Info ][DeploymentComponent::import] Loaded RTT Plugin 'ros' from 'rtt_ros'
7.061 [ Info ][DeploymentComponent::import] Importing directory /opt/orocos/hydro/lib/orocos/gnulinux/rtt_ros ...
7.061 [ Debug ][DeploymentComponent::import] Scanning file /opt/orocos/hydro/lib/orocos/gnulinux/rtt_ros/plugins ...not a regular file: ignored.
7.061 [ Debug ][DeploymentComponent::import] Looking for plugins or typekits in directory /opt/orocos/hydro/lib/orocos/gnulinux/rtt_ros ...
7.062 [ Debug ][DeploymentComponent::import] No such directory: "/opt/orocos/hydro/lib/orocos/gnulinux/rtt_ros/types"
7.062 [ Info ][DeploymentComponent::import] Loading plugin libraries from directory /opt/orocos/hydro/lib/orocos/gnulinux/rtt_ros/plugins ...
7.062 [ Debug ][DeploymentComponent::import] Scanning file /opt/orocos/hydro/lib/orocos/gnulinux/rtt_ros/plugins/librtt_ros-gnulinux.so ...plugin '/opt/orocos/hydro/lib/orocos/gnulinux/rtt_ros/plugins/librtt_ros-gnulinux.so' already loaded. Not reloading it.
= true
```

In this case the toolchain and rtt_ros_integration are installed to `/opt/orocos/hydro` which overlays `/opt/ros/hydro`. Note that even the Info level output is duplicated, not only Debug messages.

Removing duplicates from the search paths is IMHO the cleanest solution to solve that "cosmetic" problem. The `rtt_ros` env-hook cannot easily know which of the overlayed catkin workspaces contains the RTT installation.

I also eliminated some compiler warnings about defined but unsed helper functions by adding `__attribute__((unused))` (gcc only).