gtsam  4.1.0
gtsam
Value.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
19 #pragma once
20 
21 #include <gtsam/config.h> // Configuration from CMake
22 
23 #include <gtsam/base/Vector.h>
24 #include <boost/serialization/assume_abstract.hpp>
25 #include <memory>
26 
27 namespace gtsam {
28 
36  class GTSAM_EXPORT Value {
37  public:
38 
40  virtual Value* clone_() const = 0;
41 
43  virtual void deallocate_() const = 0;
44 
46  virtual boost::shared_ptr<Value> clone() const = 0;
47 
49  virtual bool equals_(const Value& other, double tol = 1e-9) const = 0;
50 
52  virtual void print(const std::string& str = "") const = 0;
53 
59  virtual size_t dim() const = 0;
60 
67  virtual Value* retract_(const Vector& delta) const = 0;
68 
75  virtual Vector localCoordinates_(const Value& value) const = 0;
76 
78  virtual Value& operator=(const Value& /*rhs*/) {
79  //needs a empty definition so recursion in implicit derived assignment operators work
80  return *this;
81  }
82 
84  template<typename ValueType>
85  const ValueType& cast() const;
86 
88  virtual ~Value() {}
89 
90  private:
121  friend class boost::serialization::access;
122  template<class ARCHIVE>
123  void serialize(ARCHIVE & /*ar*/, const unsigned int /*version*/) {
124  }
125 
126  };
127 
128 } /* namespace gtsam */
129 
130 BOOST_SERIALIZATION_ASSUME_ABSTRACT(gtsam::Value)
gtsam::Value
This is the base class for any type to be stored in Values.
Definition: Value.h:36
gtsam::Value::clone
virtual boost::shared_ptr< Value > clone() const =0
Clone this value (normal clone on the heap, delete with 'delete' operator)
gtsam::Value::print
virtual void print(const std::string &str="") const =0
Print this value, for debugging and unit tests.
gtsam::Value::clone_
virtual Value * clone_() const =0
Clone this value in a special memory pool, must be deleted with Value::deallocate_,...
gtsam::serialize
std::string serialize(const T &input)
serializes to a string
Definition: serialization.h:100
gtsam
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
gtsam::Value::dim
virtual size_t dim() const =0
Return the dimensionality of the tangent space of this value.
Vector.h
typedef and functions to augment Eigen's VectorXd
gtsam::Value::equals_
virtual bool equals_(const Value &other, double tol=1e-9) const =0
Compare this Value with another for equality.
gtsam::Value::~Value
virtual ~Value()
Virutal destructor.
Definition: Value.h:88
gtsam::Value::localCoordinates_
virtual Vector localCoordinates_(const Value &value) const =0
Compute the coordinates in the tangent space of this value that retract() would map to value.
gtsam::Value::retract_
virtual Value * retract_(const Vector &delta) const =0
Increment the value, by mapping from the vector delta in the tangent space of the current value back ...
gtsam::Value::operator=
virtual Value & operator=(const Value &)
Assignment operator.
Definition: Value.h:78
gtsam::Value::deallocate_
virtual void deallocate_() const =0
Deallocate a raw pointer of this value.