diff --git a/gtsam/hybrid/HybridDiscreteFactor.cpp b/gtsam/hybrid/HybridDiscreteFactor.cpp index 54b193196..989127a28 100644 --- a/gtsam/hybrid/HybridDiscreteFactor.cpp +++ b/gtsam/hybrid/HybridDiscreteFactor.cpp @@ -24,25 +24,28 @@ namespace gtsam { +/* ************************************************************************ */ // TODO(fan): THIS IS VERY VERY DIRTY! We need to get DiscreteFactor right! HybridDiscreteFactor::HybridDiscreteFactor(DiscreteFactor::shared_ptr other) : Base(boost::dynamic_pointer_cast(other) - ->discreteKeys()) { - inner = other; -} + ->discreteKeys()), + inner_(other) {} +/* ************************************************************************ */ HybridDiscreteFactor::HybridDiscreteFactor(DecisionTreeFactor &&dtf) : Base(dtf.discreteKeys()), - inner(boost::make_shared(std::move(dtf))) {} + inner_(boost::make_shared(std::move(dtf))) {} +/* ************************************************************************ */ bool HybridDiscreteFactor::equals(const HybridFactor &lf, double tol) const { - return false; + return Base::equals(lf, tol); } +/* ************************************************************************ */ void HybridDiscreteFactor::print(const std::string &s, const KeyFormatter &formatter) const { HybridFactor::print(s, formatter); - inner->print("inner: ", formatter); + inner_->print("inner: ", formatter); }; -} // namespace gtsam \ No newline at end of file +} // namespace gtsam diff --git a/gtsam/hybrid/HybridDiscreteFactor.h b/gtsam/hybrid/HybridDiscreteFactor.h index 0f731f8b5..572ddfbcd 100644 --- a/gtsam/hybrid/HybridDiscreteFactor.h +++ b/gtsam/hybrid/HybridDiscreteFactor.h @@ -13,6 +13,7 @@ * @file HybridDiscreteFactor.h * @date Mar 11, 2022 * @author Fan Jiang + * @author Varun Agrawal */ #pragma once @@ -29,12 +30,16 @@ namespace gtsam { * inheritance. */ class HybridDiscreteFactor : public HybridFactor { + private: + DiscreteFactor::shared_ptr inner_; + public: using Base = HybridFactor; using This = HybridDiscreteFactor; using shared_ptr = boost::shared_ptr; - DiscreteFactor::shared_ptr inner; + /// @name Constructors + /// @{ // Implicit conversion from a shared ptr of DF HybridDiscreteFactor(DiscreteFactor::shared_ptr other); @@ -42,11 +47,18 @@ class HybridDiscreteFactor : public HybridFactor { // Forwarding constructor from concrete DecisionTreeFactor HybridDiscreteFactor(DecisionTreeFactor &&dtf); - public: + /// @} + /// @name Testable + /// @{ virtual bool equals(const HybridFactor &lf, double tol) const override; void print( const std::string &s = "HybridFactor\n", const KeyFormatter &formatter = DefaultKeyFormatter) const override; + + /// @} + + /// Return pointer to the internal discrete factor + DiscreteFactor::shared_ptr inner() const { return inner_; } }; } // namespace gtsam