26#include <boost/make_shared.hpp>
27#include <boost/pool/pool_alloc.hpp>
34#define GENERICVALUE_VISIBILITY
38#define GENERICVALUE_VISIBILITY GTSAM_EXPORT
94 void print(
const std::string& str)
const override {
95 std::cout <<
"(" <<
demangle(
typeid(T).name()) <<
")\n";
117 boost::shared_ptr<Value>
clone()
const override {
118 return boost::allocate_shared<GenericValue>(Eigen::aligned_allocator<GenericValue>(), *
this);
129 return resultAsValue;
153 size_t dim()
const override {
181 template<
class ARCHIVE>
182 void serialize(ARCHIVE & ar,
const unsigned int ) {
183 ar & boost::serialization::make_nvp(
"GenericValue",
184 boost::serialization::base_object<Value>(*
this));
185 ar & boost::serialization::make_nvp(
"value",
value_);
190 enum { NeedsToAlign = (
sizeof(T) % 16) == 0 };
196#define GTSAM_VALUE_EXPORT(Type) BOOST_CLASS_EXPORT(gtsam::GenericValue<Type>)
199template <
typename ValueType>
201 :
public Testable<GenericValue<ValueType> > {};
204template<
typename ValueType>
Typedefs for easier changing of types.
#define GTSAM_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign)
This marks a GTSAM object to require alignment.
Definition: types.h:286
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:212
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition: concepts.h:30
Wraps any type T so it can play as a Value.
Definition: GenericValue.h:47
Value * clone_() const override
Create a duplicate object returned as a pointer to the generic Value interface.
Definition: GenericValue.h:102
Value * retract_(const Vector &delta) const override
Generic Value interface version of retract.
Definition: GenericValue.h:122
Value & operator=(const Value &rhs) override
Assignment operator.
Definition: GenericValue.h:158
void print(const std::string &str) const override
Virtual print function, uses traits.
Definition: GenericValue.h:94
bool equals(const GenericValue &other, double tol=1e-9) const
non virtual equals function, uses traits
Definition: GenericValue.h:89
size_t dim() const override
Return run-time dimensionality.
Definition: GenericValue.h:153
GenericValue(const T &value)
Construct from value.
Definition: GenericValue.h:62
void deallocate_() const override
Destroy and deallocate this object, only if it was originally allocated using clone_().
Definition: GenericValue.h:110
T value_
The wrapped value.
Definition: GenericValue.h:55
GenericValue< T > & operator=(const GenericValue< T > &rhs)
Assignment operator, protected because only the Value or DERIVED assignment operators should be used.
Definition: GenericValue.h:171
Vector localCoordinates(const GenericValue &value2) const
Non-virtual version of localCoordinates.
Definition: GenericValue.h:148
friend class boost::serialization::access
Serialization function.
Definition: GenericValue.h:180
bool equals_(const Value &p, double tol=1e-9) const override
equals implementing generic Value interface
Definition: GenericValue.h:81
const T & value() const
Return a constant value.
Definition: GenericValue.h:67
~GenericValue() override
Destructor.
Definition: GenericValue.h:77
GenericValue retract(const Vector &delta) const
Non-virtual version of retract.
Definition: GenericValue.h:143
Vector localCoordinates_(const Value &value2) const override
Generic Value interface version of localCoordinates.
Definition: GenericValue.h:133
boost::shared_ptr< Value > clone() const override
Clone this value (normal clone on the heap, delete with 'delete' operator)
Definition: GenericValue.h:117
A helper that implements the traits interface for GTSAM types.
Definition: Testable.h:151
This is the base class for any type to be stored in Values.
Definition: Value.h:36
const ValueType & cast() const
Cast to known ValueType.
Definition: GenericValue.h:205
virtual Value & operator=(const Value &)
Assignment operator.
Definition: Value.h:78