From ce70480ae0366df4f927b1af17595bf575c9fa84 Mon Sep 17 00:00:00 2001 From: Alex Cunningham Date: Wed, 30 Mar 2011 14:09:34 +0000 Subject: [PATCH] Made keys_ protected to allow initialization in a constructor body, added constructor for NonlinearFactor allowing more than two keys --- gtsam/inference/Factor.h | 3 ++- gtsam/nonlinear/NonlinearFactor.h | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gtsam/inference/Factor.h b/gtsam/inference/Factor.h index e9ac657ea..2e8b42603 100644 --- a/gtsam/inference/Factor.h +++ b/gtsam/inference/Factor.h @@ -70,7 +70,8 @@ public: /** Const iterator over keys */ typedef typename std::vector::const_iterator const_iterator; -private: +//private: // FIXME: factors that manually initialize keys_ break in this case +protected: // The keys involved in this factor std::vector keys_; diff --git a/gtsam/nonlinear/NonlinearFactor.h b/gtsam/nonlinear/NonlinearFactor.h index ffd4a2585..5986882e0 100644 --- a/gtsam/nonlinear/NonlinearFactor.h +++ b/gtsam/nonlinear/NonlinearFactor.h @@ -99,6 +99,14 @@ namespace gtsam { Factor(j1,j2), noiseModel_(noiseModel) { } + /** + * Constructor - arbitrary number of keys + * @param keys is the set of Symbols in the factor + */ + NonlinearFactor(const SharedGaussian& noiseModel, const std::set& keys) : + Factor(keys), noiseModel_(noiseModel) { + } + /** print */ virtual void print(const std::string& s = "") const { std::cout << s << ": NonlinearFactor\n";