From d85a437c9045c64b5b183b9357b45b9c56f6e205 Mon Sep 17 00:00:00 2001 From: Richard Roberts Date: Mon, 17 Jun 2013 21:16:08 +0000 Subject: [PATCH] public/protected/private visibility fixes and fixes with base/derived classes --- gtsam/inference/BayesTreeCliqueBaseUnordered.h | 2 +- gtsam/inference/BayesTreeUnordered.h | 4 ++++ gtsam/inference/FactorGraphUnordered.h | 10 ++++------ gtsam/inference/FactorUnordered.h | 8 +++----- gtsam/symbolic/SymbolicBayesTreeUnordered.h | 13 +++++++++++++ gtsam/symbolic/SymbolicConditionalUnordered.h | 1 - gtsam/symbolic/SymbolicFactorGraphUnordered.h | 8 ++++++++ 7 files changed, 33 insertions(+), 13 deletions(-) diff --git a/gtsam/inference/BayesTreeCliqueBaseUnordered.h b/gtsam/inference/BayesTreeCliqueBaseUnordered.h index a04fa0499..220a139ff 100644 --- a/gtsam/inference/BayesTreeCliqueBaseUnordered.h +++ b/gtsam/inference/BayesTreeCliqueBaseUnordered.h @@ -84,7 +84,7 @@ namespace gtsam { /// @{ /** check equality */ - bool equals(const This& other, double tol = 1e-9) const { + bool equals(const DERIVED& other, double tol = 1e-9) const { return (!conditional_ && !other.conditional()) || conditional_->equals(*other.conditional(), tol); } diff --git a/gtsam/inference/BayesTreeUnordered.h b/gtsam/inference/BayesTreeUnordered.h index 06978af0f..c5557a49f 100644 --- a/gtsam/inference/BayesTreeUnordered.h +++ b/gtsam/inference/BayesTreeUnordered.h @@ -104,9 +104,11 @@ namespace gtsam { /** Copy constructor */ BayesTreeUnordered(const This& other); + protected: /** Assignment operator */ This& operator=(const This& other); + public: /// @} /// @name Advanced Constructors /// @{ @@ -118,6 +120,7 @@ namespace gtsam { /// @name Testable /// @{ + protected: /** check equality */ bool equals(const This& other, double tol = 1e-9) const; @@ -125,6 +128,7 @@ namespace gtsam { void print(const std::string& s = "", const KeyFormatter& keyFormatter = DefaultKeyFormatter) const; + public: /// @} /// @name Standard Interface /// @{ diff --git a/gtsam/inference/FactorGraphUnordered.h b/gtsam/inference/FactorGraphUnordered.h index 4d1562402..580b27fba 100644 --- a/gtsam/inference/FactorGraphUnordered.h +++ b/gtsam/inference/FactorGraphUnordered.h @@ -39,19 +39,18 @@ namespace gtsam { class FactorGraphUnordered { public: - typedef FactorGraphUnordered This; typedef FACTOR FactorType; ///< factor type typedef boost::shared_ptr sharedFactor; ///< Shared pointer to a factor typedef boost::shared_ptr sharedConditional; ///< Shared pointer to a conditional - - typedef FactorGraphUnordered This; ///< Typedef for this class - typedef boost::shared_ptr shared_ptr; ///< Shared pointer for this class typedef typename std::vector::iterator iterator; typedef typename std::vector::const_iterator const_iterator; - protected: + private: + typedef FactorGraphUnordered This; ///< Typedef for this class + typedef boost::shared_ptr shared_ptr; ///< Shared pointer for this class + protected: /** concept check, makes sure FACTOR defines print and equals */ GTSAM_CONCEPT_TESTABLE_TYPE(FACTOR) @@ -59,7 +58,6 @@ namespace gtsam { std::vector factors_; public: - /// @name Standard Constructors /// @{ diff --git a/gtsam/inference/FactorUnordered.h b/gtsam/inference/FactorUnordered.h index d1b49b139..a03776284 100644 --- a/gtsam/inference/FactorUnordered.h +++ b/gtsam/inference/FactorUnordered.h @@ -50,13 +50,13 @@ namespace gtsam { */ class GTSAM_EXPORT FactorUnordered { -public: - +private: typedef FactorUnordered This; ///< This class /// A shared_ptr to this class, derived classes must redefine this. typedef boost::shared_ptr shared_ptr; +public: /// Iterator over keys typedef std::vector::iterator iterator; @@ -68,8 +68,6 @@ protected: /// The keys involved in this factor std::vector keys_; -public: - /// @name Standard Constructors /// @{ @@ -118,7 +116,7 @@ public: /// @} - +public: /// @name Standard Interface /// @{ diff --git a/gtsam/symbolic/SymbolicBayesTreeUnordered.h b/gtsam/symbolic/SymbolicBayesTreeUnordered.h index 597393ead..1b1dfa5ea 100644 --- a/gtsam/symbolic/SymbolicBayesTreeUnordered.h +++ b/gtsam/symbolic/SymbolicBayesTreeUnordered.h @@ -42,11 +42,24 @@ namespace gtsam { class GTSAM_EXPORT SymbolicBayesTreeUnordered : public BayesTreeUnordered { + private: + typedef BayesTreeUnordered Base; public: + typedef SymbolicBayesTreeUnordered This; + typedef boost::shared_ptr shared_ptr; + /** Insert a new conditional */ //void insert(const sharedConditional& conditional); + /** check equality */ + bool equals(const This& other, double tol = 1e-9) const { return Base::equals(other, tol); } + + /** print */ + void print(const std::string& s = "", + const KeyFormatter& keyFormatter = DefaultKeyFormatter) const { Base::print(s, keyFormatter); } + + protected: /** diff --git a/gtsam/symbolic/SymbolicConditionalUnordered.h b/gtsam/symbolic/SymbolicConditionalUnordered.h index c31ea8a37..188203e6b 100644 --- a/gtsam/symbolic/SymbolicConditionalUnordered.h +++ b/gtsam/symbolic/SymbolicConditionalUnordered.h @@ -35,7 +35,6 @@ namespace gtsam { class GTSAM_EXPORT SymbolicConditionalUnordered : public SymbolicFactorUnordered, public ConditionalUnordered { public: - typedef SymbolicConditionalUnordered This; /// Typedef to this class typedef SymbolicFactorUnordered BaseFactor; /// Typedef to the factor base class typedef ConditionalUnordered BaseConditional; /// Typedef to the conditional base class diff --git a/gtsam/symbolic/SymbolicFactorGraphUnordered.h b/gtsam/symbolic/SymbolicFactorGraphUnordered.h index 202359115..fcd42f4ad 100644 --- a/gtsam/symbolic/SymbolicFactorGraphUnordered.h +++ b/gtsam/symbolic/SymbolicFactorGraphUnordered.h @@ -22,6 +22,7 @@ #include #include #include +// NOTE: Additional headers included at end of file for user convenience namespace gtsam { class SymbolicConditionalUnordered; } namespace gtsam { class SymbolicBayesNetUnordered; } @@ -47,6 +48,7 @@ namespace gtsam { typedef EliminateableFactorGraph< SymbolicFactorUnordered, SymbolicFactorGraphUnordered, SymbolicConditionalUnordered, SymbolicBayesNetUnordered, SymbolicEliminationTreeUnordered, SymbolicBayesTreeUnordered, SymbolicJunctionTreeUnordered> BaseEliminateable; + typedef boost::shared_ptr shared_ptr; typedef BaseEliminateable::Eliminate Eliminate; /// @name Standard Constructors @@ -83,3 +85,9 @@ namespace gtsam { }; } // namespace gtsam + +// These are not needed for this file but are returned from EliminateableFactorGraph functions so +// are included here for user convenience +#include +#include +