34#define GENERICVALUE_VISIBILITY
36#define GENERICVALUE_VISIBILITY GTSAM_EXPORT
48class GENERICVALUE_VISIBILITY GenericValue:
public Value {
83 bool equals_(
const Value& p,
double tol = 1e-9)
const override {
85 const GenericValue& genericValue2 =
static_cast<const GenericValue&
>(p);
91 bool equals(
const GenericValue &other,
double tol = 1e-9)
const {
96 void print(
const std::string& str)
const override {
97 std::cout <<
"(" <<
demangle(
typeid(T).name()) <<
")\n";
105 GenericValue* ptr =
new GenericValue(*
this);
119 std::shared_ptr<Value>
clone()
const override {
120 return std::allocate_shared<GenericValue>(Eigen::aligned_allocator<GenericValue>(), *
this);
124 Value*
retract_(
const Vector& delta)
const override {
128 Value* resultAsValue =
new GenericValue(retractResult);
131 return resultAsValue;
137 const GenericValue<T>& genericValue2 =
138 static_cast<const GenericValue<T>&
>(value2);
145 GenericValue
retract(
const Vector& delta)
const {
155 size_t dim()
const override {
162 const GenericValue& derivedRhs =
static_cast<const GenericValue&
>(rhs);
165 *
this = GenericValue(derivedRhs);
173 GenericValue<T>&
operator=(
const GenericValue<T>& rhs) {
181#if GTSAM_ENABLE_BOOST_SERIALIZATION
183 friend class boost::serialization::access;
184 template<
class ARCHIVE>
185 void serialize(ARCHIVE & ar,
const unsigned int ) {
186 ar & boost::serialization::make_nvp(
"GenericValue",
187 boost::serialization::base_object<Value>(*
this));
188 ar & boost::serialization::make_nvp(
"value", value_);
194#define GTSAM_VALUE_EXPORT(Type) BOOST_CLASS_EXPORT(gtsam::GenericValue<Type>)
197template <
typename ValueType>
199 :
public Testable<GenericValue<ValueType> > {};
202template<
typename ValueType>
Typedefs for easier changing of types.
The base class for any variable that can be optimized or used in a factor.
Base class and basic functions for Manifold types.
Global functions in a separate testing namespace.
Definition chartTesting.h:28
std::string demangle(const char *name)
Pretty print Value type name.
Definition types.cpp:37
GenericValue< T > genericValue(const T &v)
Functional constructor of GenericValue<T> so T can be automatically deduced.
Definition GenericValue.h:210
Wraps any type T so it can play as a Value.
Definition GenericValue.h:48
Value * clone_() const override
Create a duplicate object returned as a pointer to the generic Value interface.
Definition GenericValue.h:104
T & value()
Return the value.
Definition GenericValue.h:74
Value * retract_(const Vector &delta) const override
Generic Value interface version of retract.
Definition GenericValue.h:124
Value & operator=(const Value &rhs) override
Assignment operator.
Definition GenericValue.h:160
void print(const std::string &str) const override
Virtual print function, uses traits.
Definition GenericValue.h:96
bool equals(const GenericValue &other, double tol=1e-9) const
non virtual equals function, uses traits
Definition GenericValue.h:91
size_t dim() const override
Return run-time dimensionality.
Definition GenericValue.h:155
GenericValue(const T &value)
Construct from value.
Definition GenericValue.h:63
void deallocate_() const override
Destroy and deallocate this object, only if it was originally allocated using clone_().
Definition GenericValue.h:112
T value_
The wrapped value.
Definition GenericValue.h:56
GenericValue< T > & operator=(const GenericValue< T > &rhs)
Assignment operator, protected because only the Value or DERIVED assignment operators should be used.
Definition GenericValue.h:173
Vector localCoordinates(const GenericValue &value2) const
Non-virtual version of localCoordinates.
Definition GenericValue.h:150
bool equals_(const Value &p, double tol=1e-9) const override
equals implementing generic Value interface
Definition GenericValue.h:83
std::shared_ptr< Value > clone() const override
Clone this value (normal clone on the heap, delete with 'delete' operator).
Definition GenericValue.h:119
const T & value() const
Return a constant value.
Definition GenericValue.h:69
~GenericValue() override
Destructor.
Definition GenericValue.h:79
GenericValue retract(const Vector &delta) const
Non-virtual version of retract.
Definition GenericValue.h:145
Vector localCoordinates_(const Value &value2) const override
Generic Value interface version of localCoordinates.
Definition GenericValue.h:135
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition Group.h:37
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:152
const ValueType & cast() const
Cast to known ValueType.
Definition GenericValue.h:203
virtual Value & operator=(const Value &)
Assignment operator.
Definition Value.h:84