osrf/ros_dds — pull request #17 by wjwwood (2014-03-26 22:44:53+00:00)
Title: major refactor to hide the dds implementation

I set out to refactor the prototype so that packages using `rclcpp` and `std_msgs`, e.g. `rclcpp_examples`, will not have to include any headers which contain any kind of DDS symbols.

To this end I have restructured the package layout:

![dependency_change](https://cloud.githubusercontent.com/assets/100427/2531818/12d6ce12-b537-11e3-8ba2-ee612fb7e365.png)

In this way, all DDS specific code is either in the `genidlcpp` generated _cpp_ files or in implementation headers in the new package `rclcpp_impl_ospl`. The implementation headers in `rclcpp_impl_ospl` are included by the generated _cpp_ files from `genidlcpp` and the _cpp_ files in `rclcpp`. That way there is no transitive dependency on any DDS headers for message generators (like `std_msgs`) or `rclcpp`. In order to access the DDS headers you would need to depend on `rclcpp_impl_ospl`. The DDS types are still generated in `genidlcpp`, so a further useful abstraction would probably be to have a `genrclcpp_impl_ospl` which generates the code which uses both ROS msg types and DDS idl types and then `genidlcpp` would only be responsible for generating C++ code from the `idl` files.

Pros of this design:
- DDS symbols are hidden in installed headers from message generation packages (like `std_msgs`)
- DDS symbols are hidden from `rclcpp`
- Publisher and Subscription objects are no longer template types (this could be achieved separately)
- Compilation of end-user code is faster because majority of generation and compilation happens on message generation packages
- Lends itself to abstracting the DDS implementation away

Cons of the design:
- More code is generated in the message generator packages rather than with the compiler via templates
- More code is compiled in the message generator packages, causing them to take longer to compile and be larger to distribute

To help address the first Con I believe we can move the majority of the code in the `msg_pubsub.cpp` file into the `rclcpp_impl_ospl` package as templates in headers and use a similar pattern that was used previously with the `dds_impl::DDSTypeResolver` struct. This will not move where the code is compiled (in `std_msgs`), but it will change the location of the code and move it out of a `EmPy` template file which is more difficult to work in.