I see. I think this is a class that is very unlikely to be present in user
code, and i think the constructor argument is the best option (slightly
breaking api). Better than using friend, I think.
On Feb 15, 2014 2:10 PM, "Acorn" <notifications@github.com> wrote:

> In
> robot_interaction/include/moveit/robot_interaction/interaction_handler.h:
>
> >    void clearError(void);
> >
> > +  /** \brief This should only be called by RobotInteraction.
> > +   * Associates this InteractionHandler to a RobotInteraction.
> > +   */
> > +  void setRobotInteraction(RobotInteraction* robot_interaction);
>
> I really wanted to make this a private function, but to do so would mean
> RobotInteraction would have to be a friend of InteractionHandler, which I
> really don't want to do (breaks encapsulation). I considered adding a new
> class which is a friend of InteractionHandler and is inherited by
> RobotInteraction with a single method that calls setRobotInteraction, but
> that seemed like a lot of complexity.
>
> On the other hand, making this a public function does not really hurt
> anything. It is an error (print error and do nothing) to call it with
> anything other than the RobotInteraction it is already associated with, and
> calling it with that RobotInteraction does nothing. So it is benign to call
> this.
>
> I could put it in a separate (but still public) section of the class (e.g.
> at the end) to make it clear it is not part of the public interface.
> Another idea is to name it specially (e.g. leading or trailing underscore)
> to make it clear it is not really part of the public interface.
>
> I think the best solution is to have the RobotInteraction be a parameter
> of the InteractionHandler constructor. This function will not be needed
> anymore. But legacy code may still use the old constructor so I don't know
> if I can get rid of it (your opinion?), which means this function is still
> needed.
>
> I struggled with this for way longer than such a trivial detail merits, so
> if you have any good solutions to this problem in general I'd love to hear
> them.
>
> --
> Reply to this email directly or view it on GitHub<https://github.com/ros-planning/moveit_ros/pull/422/files#r9774684>
> .
>