ethz-asl / curves

A library of curves for estimation.
BSD 3-Clause "New" or "Revised" License
74 stars 28 forks source link

EvaluatorTypePtr and Evaluator #23

Closed rdube closed 10 years ago

rdube commented 10 years ago

I am trying to populate the LinearInterpolationVectorSpaceEvaluator.cpp to create an evaluator object for our linearly interpolated 1d curve. Currently the class is defined as :

class LinearInterpolationVectorSpaceEvaluator : public Evaluator< VectorSpaceConfig >

However, in LinearInterpolationVectorSpaceEvaluator.hpp the getter function is:

virtual EvaluatorTypePtr getEvaluator(Time time) const;

This functions returns a boost::shared_ptr< Evaluator< VectorSpaceConfig > > ;

Could someone comment on how to make the link between the LinearInterpolationVectorSpaceEvaluator class and the boost::shared_ptr? Am I right by trying to create a LinearInterpolationVectorSpaceEvaluator object or am I getting something wrong?

Thanks!

furgalep commented 10 years ago

No, you are right. I would do something like:

EvaluatorTypePtr getEvaluator(Time time) const {
  boost::shared_ptr< Evaluator< VectorSpaceConfig > > rval( new LinearInterpolationVectorSpaceEvaluator(arg1, arg2, arg3) );

  return rval;
}

This works because LinearInterpolationVectorSpaceEvaluator is a child class of Evaluator< VectorSpaceConfig >. Does that make sense?

rdube commented 10 years ago

Ok cool it works! Thanks!