Virtual destructor
parent
68d26ad2af
commit
41a1aab0e2
|
@ -60,7 +60,9 @@ private:
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Expressions wrap trees of functions that can evaluate their own derivatives.
|
// Expressions wrap trees of functions that can evaluate their own derivatives.
|
||||||
// The meta-functions below provide a handy to specify the type of those functions
|
// The meta-functions below are useful to specify the type of those functions.
|
||||||
|
// Example, a function taking a camera and a 3D point and yielding a 2D point:
|
||||||
|
// Expression<Point2>::BinaryFunction<SimpleCamera,Point3>::type
|
||||||
template<class A1>
|
template<class A1>
|
||||||
struct UnaryFunction {
|
struct UnaryFunction {
|
||||||
typedef boost::function<
|
typedef boost::function<
|
||||||
|
@ -135,6 +137,10 @@ public:
|
||||||
typename MakeOptionalJacobian<T, A3>::type) const,
|
typename MakeOptionalJacobian<T, A3>::type) const,
|
||||||
const Expression<A2>& expression2, const Expression<A3>& expression3);
|
const Expression<A2>& expression2, const Expression<A3>& expression3);
|
||||||
|
|
||||||
|
/// Destructor
|
||||||
|
virtual ~Expression() {
|
||||||
|
}
|
||||||
|
|
||||||
/// Return keys that play in this expression
|
/// Return keys that play in this expression
|
||||||
std::set<Key> keys() const;
|
std::set<Key> keys() const;
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,10 @@ class ConstantExpression: public ExpressionNode<T> {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
/// Destructor
|
||||||
|
virtual ~ConstantExpression() {
|
||||||
|
}
|
||||||
|
|
||||||
/// Return value
|
/// Return value
|
||||||
virtual T value(const Values& values) const {
|
virtual T value(const Values& values) const {
|
||||||
return constant_;
|
return constant_;
|
||||||
|
@ -154,12 +158,15 @@ class LeafExpression: public ExpressionNode<T> {
|
||||||
LeafExpression(Key key) :
|
LeafExpression(Key key) :
|
||||||
key_(key) {
|
key_(key) {
|
||||||
}
|
}
|
||||||
// todo: do we need a virtual destructor here too?
|
|
||||||
|
|
||||||
friend class Expression<T> ;
|
friend class Expression<T> ;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
/// Destructor
|
||||||
|
virtual ~LeafExpression() {
|
||||||
|
}
|
||||||
|
|
||||||
/// Return keys that play in this expression
|
/// Return keys that play in this expression
|
||||||
virtual std::set<Key> keys() const {
|
virtual std::set<Key> keys() const {
|
||||||
std::set<Key> keys;
|
std::set<Key> keys;
|
||||||
|
@ -205,18 +212,23 @@ class UnaryExpression: public ExpressionNode<T> {
|
||||||
boost::shared_ptr<ExpressionNode<A1> > expression1_;
|
boost::shared_ptr<ExpressionNode<A1> > expression1_;
|
||||||
Function function_;
|
Function function_;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// Constructor with a unary function f, and input argument e1
|
/// Constructor with a unary function f, and input argument e1
|
||||||
UnaryExpression(Function f, const Expression<A1>& e1) :
|
UnaryExpression(Function f, const Expression<A1>& e1) :
|
||||||
expression1_(e1.root()), function_(f) {
|
expression1_(e1.root()), function_(f) {
|
||||||
ExpressionNode<T>::traceSize_ = upAligned(sizeof(Record)) + e1.traceSize();
|
ExpressionNode<T>::traceSize_ = upAligned(sizeof(Record)) + e1.traceSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
friend class Expression<T> ;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// Destructor
|
||||||
|
virtual ~UnaryExpression() {
|
||||||
|
}
|
||||||
|
|
||||||
/// Return value
|
/// Return value
|
||||||
virtual T value(const Values& values) const {
|
virtual T value(const Values& values) const {
|
||||||
using boost::none;
|
return function_(expression1_->value(values), boost::none);
|
||||||
return function_(expression1_->value(values), none);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return keys that play in this expression
|
/// Return keys that play in this expression
|
||||||
|
@ -300,8 +312,6 @@ class BinaryExpression: public ExpressionNode<T> {
|
||||||
boost::shared_ptr<ExpressionNode<A2> > expression2_;
|
boost::shared_ptr<ExpressionNode<A2> > expression2_;
|
||||||
Function function_;
|
Function function_;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// Constructor with a binary function f, and two input arguments
|
/// Constructor with a binary function f, and two input arguments
|
||||||
BinaryExpression(Function f, const Expression<A1>& e1,
|
BinaryExpression(Function f, const Expression<A1>& e1,
|
||||||
const Expression<A2>& e2) :
|
const Expression<A2>& e2) :
|
||||||
|
@ -310,8 +320,15 @@ public:
|
||||||
upAligned(sizeof(Record)) + e1.traceSize() + e2.traceSize();
|
upAligned(sizeof(Record)) + e1.traceSize() + e2.traceSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
friend class Expression<T> ;
|
||||||
friend class ::ExpressionFactorBinaryTest;
|
friend class ::ExpressionFactorBinaryTest;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// Destructor
|
||||||
|
virtual ~BinaryExpression() {
|
||||||
|
}
|
||||||
|
|
||||||
/// Return value
|
/// Return value
|
||||||
virtual T value(const Values& values) const {
|
virtual T value(const Values& values) const {
|
||||||
using boost::none;
|
using boost::none;
|
||||||
|
@ -394,8 +411,6 @@ class TernaryExpression: public ExpressionNode<T> {
|
||||||
boost::shared_ptr<ExpressionNode<A3> > expression3_;
|
boost::shared_ptr<ExpressionNode<A3> > expression3_;
|
||||||
Function function_;
|
Function function_;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// Constructor with a ternary function f, and two input arguments
|
/// Constructor with a ternary function f, and two input arguments
|
||||||
TernaryExpression(Function f, const Expression<A1>& e1,
|
TernaryExpression(Function f, const Expression<A1>& e1,
|
||||||
const Expression<A2>& e2, const Expression<A3>& e3) :
|
const Expression<A2>& e2, const Expression<A3>& e3) :
|
||||||
|
@ -405,6 +420,14 @@ public:
|
||||||
e1.traceSize() + e2.traceSize() + e3.traceSize();
|
e1.traceSize() + e2.traceSize() + e3.traceSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
friend class Expression<T> ;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// Destructor
|
||||||
|
virtual ~TernaryExpression() {
|
||||||
|
}
|
||||||
|
|
||||||
/// Return value
|
/// Return value
|
||||||
virtual T value(const Values& values) const {
|
virtual T value(const Values& values) const {
|
||||||
using boost::none;
|
using boost::none;
|
||||||
|
|
Loading…
Reference in New Issue