20 #include <gtsam/base/Value.h> 21 #include <boost/make_shared.hpp> 25 #include <boost/pool/singleton_pool.hpp> 43 template<
class DERIVED>
58 virtual gtsam::Value*
clone_()
const {
59 void *place = boost::singleton_pool<PoolTag, sizeof(DERIVED)>::malloc();
60 DERIVED* ptr =
new(place) DERIVED(static_cast<const DERIVED&>(*
this));
69 boost::singleton_pool<PoolTag, sizeof(DERIVED)>::free((
void*)
this);
76 return boost::make_shared<DERIVED>(
static_cast<const DERIVED&
>(*this));
80 virtual bool equals_(
const gtsam::Value& p,
double tol = 1
e-9)
const {
82 const DERIVED& derivedValue2 =
dynamic_cast<const DERIVED&
>(p);
85 return (static_cast<const DERIVED*>(
this))->equals(derivedValue2, tol);
89 virtual gtsam::Value*
retract_(
const gtsam::Vector& delta)
const {
91 const DERIVED retractResult = (
static_cast<const DERIVED*
>(
this))->retract(delta);
94 void* resultAsValuePlace = boost::singleton_pool<PoolTag, sizeof(DERIVED)>::malloc();
95 gtsam::Value* resultAsValue =
new(resultAsValuePlace) DERIVED(retractResult);
104 const DERIVED& derivedValue2 =
dynamic_cast<const DERIVED&
>(value2);
107 return (static_cast<const DERIVED*>(
this))->localCoordinates(derivedValue2);
111 virtual gtsam::Value&
operator=(
const gtsam::Value& rhs) {
113 const DERIVED& derivedRhs =
dynamic_cast<const DERIVED&
>(rhs);
116 return (static_cast<DERIVED*>(
this))->
operator=(derivedRhs);
120 operator const DERIVED& ()
const {
121 return static_cast<const DERIVED&
>(*this);
125 operator DERIVED& () {
126 return static_cast<DERIVED&
>(*this);
DerivedValue< DERIVED > & operator=(const DerivedValue< DERIVED > &)
virtual bool equals_(const gtsam::Value &p, double tol=1e-9) const
equals implementing generic Value interface
virtual gtsam::Vector localCoordinates_(const gtsam::Value &value2) const
Generic Value interface version of localCoordinates.
GLM_FUNC_DECL genType e()
virtual gtsam::Value * retract_(const gtsam::Vector &delta) const
Generic Value interface version of retract.
virtual void deallocate_() const
virtual gtsam::Value * clone_() const
virtual gtsam::Value & operator=(const gtsam::Value &rhs)
Assignment operator.
virtual boost::shared_ptr< gtsam::Value > clone() const
Fake Tag struct for singleton pool allocator. In fact, it is never used!