21 #include <boost/make_shared.hpp> 25 #include <boost/pool/singleton_pool.hpp> 43 template<
class DERIVED>
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);
75 virtual boost::shared_ptr<Value>
clone()
const {
76 return boost::make_shared<DERIVED>(
static_cast<const DERIVED&
>(*this));
82 const DERIVED& derivedValue2 =
dynamic_cast<const DERIVED&
>(p);
85 return (static_cast<const DERIVED*>(
this))->
equals(derivedValue2, tol);
91 const DERIVED retractResult = (
static_cast<const DERIVED*
>(
this))->retract(delta);
94 void* resultAsValuePlace = boost::singleton_pool<PoolTag, sizeof(DERIVED)>::malloc();
95 Value* resultAsValue =
new(resultAsValuePlace) DERIVED(retractResult);
104 const DERIVED& derivedValue2 =
dynamic_cast<const DERIVED&
>(value2);
107 return (static_cast<const DERIVED*>(
this))->localCoordinates(derivedValue2);
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 > &)
Assignment operator, protected because only the Value or DERIVED assignment operators should be used...
Definition: DerivedValue.h:132
virtual bool equals_(const Value &p, double tol=1e-9) const
equals implementing generic Value interface
Definition: DerivedValue.h:80
virtual Value * retract_(const Vector &delta) const
Generic Value interface version of retract.
Definition: DerivedValue.h:89
virtual boost::shared_ptr< Value > clone() const
Clone this value (normal clone on the heap, delete with 'delete' operator)
Definition: DerivedValue.h:75
Template to create a binary predicate.
Definition: Testable.h:110
virtual void deallocate_() const
Destroy and deallocate this object, only if it was originally allocated using clone_().
Definition: DerivedValue.h:67
virtual Value & operator=(const Value &rhs)
Assignment operator.
Definition: DerivedValue.h:111
virtual Vector localCoordinates_(const Value &value2) const
Generic Value interface version of localCoordinates.
Definition: DerivedValue.h:102
virtual Value * clone_() const
Create a duplicate object returned as a pointer to the generic Value interface.
Definition: DerivedValue.h:58
Definition: DerivedValue.h:44
The interface class for any variable that can be optimized or used in a factor.
This is the interface class for any value that may be used as a variable assignment in a factor graph...
Definition: Value.h:83
Global functions in a separate testing namespace.
Definition: chartTesting.h:28