RethinkRobotics-opensource / sns_ik

Saturation in the Null Space (SNS) Inverse Kinematic Library
86 stars 41 forks source link

Standardize Usage / Interface for raw and smart pointer usage #43

Open IanTheEngineer opened 8 years ago

IanTheEngineer commented 8 years ago

Right now pointers are both raw and shared. We should choose one (preferably shared) and stick with it. Additionally, we should consistently return shared pointers rather than passing them in by reference and populating them.

MatthewPeterKelly commented 6 years ago

There are a few cases of interest here. In both cases I suggest that we follow the google style guide for C++.

1) Reference arguments: google style guide: reference arguments

2) Object lifetime management: google style guide: smart pointers

3) Follow Resource Acquisition Is Initialization (RAII)

IanTheEngineer commented 6 years ago

I agree with 2 and 3. However, on reading google's doc on reference arguments, I don't see a good justification for function outputs being passed by raw pointer. Who is responsible for cleaning up the object?

MatthewPeterKelly commented 6 years ago

I believe that the caller is responsible for managing the object lifetime. This method of handling output arguments is also suggested by the ROS style guide.

If the function is creating an object with a non-trivial lifetime, then we should return a unique pointer to the object.