Fixed factor graph construction and push_back from iterators and containers over plain and shared_ptr objects
parent
e9f30660b3
commit
333903c4aa
|
|
@ -25,6 +25,7 @@
|
||||||
#include <boost/serialization/nvp.hpp>
|
#include <boost/serialization/nvp.hpp>
|
||||||
#include <boost/assign/list_inserter.hpp>
|
#include <boost/assign/list_inserter.hpp>
|
||||||
#include <boost/make_shared.hpp>
|
#include <boost/make_shared.hpp>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
#include <gtsam/base/Testable.h>
|
#include <gtsam/base/Testable.h>
|
||||||
#include <gtsam/inference/Key.h>
|
#include <gtsam/inference/Key.h>
|
||||||
|
|
@ -123,9 +124,10 @@ namespace gtsam {
|
||||||
void push_back(const This& factors) {
|
void push_back(const This& factors) {
|
||||||
factors_.insert(end(), factors.begin(), factors.end()); }
|
factors_.insert(end(), factors.begin(), factors.end()); }
|
||||||
|
|
||||||
/** push back many factors with an iterator */
|
/** push back many factors with an iterator over shared_ptr (factors are not copied) */
|
||||||
template<typename ITERATOR>
|
template<typename ITERATOR>
|
||||||
void push_back(ITERATOR firstFactor, ITERATOR lastFactor) {
|
typename std::enable_if<std::is_base_of<FactorType, typename ITERATOR::value_type::element_type>::value>::type
|
||||||
|
push_back(ITERATOR firstFactor, ITERATOR lastFactor) {
|
||||||
factors_.insert(end(), firstFactor, lastFactor); }
|
factors_.insert(end(), firstFactor, lastFactor); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -138,6 +140,14 @@ namespace gtsam {
|
||||||
void push_back(const DERIVEDFACTOR& factor) {
|
void push_back(const DERIVEDFACTOR& factor) {
|
||||||
add(factor); }
|
add(factor); }
|
||||||
|
|
||||||
|
/** push back many factors with an iterator over plain factors (factors are copied) */
|
||||||
|
template<typename ITERATOR>
|
||||||
|
typename std::enable_if<std::is_base_of<FactorType, typename ITERATOR::value_type>::value>::type
|
||||||
|
push_back(ITERATOR firstFactor, ITERATOR lastFactor) {
|
||||||
|
for(ITERATOR f = firstFactor; f != lastFactor; ++f)
|
||||||
|
add(*f);
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** += syntax for push_back, e.g. graph += f1, f2, f3 */
|
/** += syntax for push_back, e.g. graph += f1, f2, f3 */
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,14 @@ namespace gtsam {
|
||||||
template<typename ITERATOR>
|
template<typename ITERATOR>
|
||||||
SymbolicBayesNetUnordered(ITERATOR firstConditional, ITERATOR lastConditional) : Base(firstConditional, lastConditional) {}
|
SymbolicBayesNetUnordered(ITERATOR firstConditional, ITERATOR lastConditional) : Base(firstConditional, lastConditional) {}
|
||||||
|
|
||||||
|
/** Construct from container of factors (shared_ptr or plain objects) */
|
||||||
|
template<class CONTAINER>
|
||||||
|
explicit SymbolicBayesNetUnordered(const CONTAINER& conditionals) : Base(conditionals) {}
|
||||||
|
|
||||||
|
/** Implicit copy/downcast constructor to override explicit template container constructor */
|
||||||
|
template<class DERIVEDCONDITIONAL>
|
||||||
|
SymbolicBayesNetUnordered(const FactorGraphUnordered<DERIVEDCONDITIONAL>& graph) : Base(graph) {}
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
/// @name Testable
|
/// @name Testable
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue