RobotLocomotion/drake — pull request #370 by tkoolen (2014-08-30 19:22:41+00:00)
Title: DrakeJoint in RigidBody redo

Redo of "DrakeJoint in RigidBody" (#344)

Adds a `std::unique_ptr` member to the `RigidBody` class, but doesn't use it for anything yet. Both `constructModelmex` and `URDFRigidBodyManipulator` set the `joint` member in `RigidBody`.

I had to change the `bodies` member of RigidBodyManipulator from a `std::vector` to a `std::vector>`. Previously, the std::vector implementation relied on the default copy constructor of RigidBody. Adding a `std::unique_ptr` member to `RigidBody` makes it so that the default copy constructor is implicitly deleted, since `unique_ptr`s cannot be copy constructed.

Another option would have been to use a raw pointer for the `joint` member of `RigidBody`, but using a `unique_ptr` makes it much clearer who owns the `DrakeJoint` and prevents a memory bug waiting to happen.

I added an implementation of `make_unique` that was recommended on Stack Overflow. The absense of `make_unique` is generally seen as an oversight in C++11; it will be added in C++14. But for now, I believe the recommended practice is to implement your own, the main reason being an exception safety issue. It is templated and not explicitly instantiated though; I can get rid of it if you prefer.