From 6c3aca8cac62989eee3c1d23db77e25ddc1f4b87 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Fri, 30 Apr 2021 12:58:52 -0400 Subject: [PATCH] remove virtual from overridden methods, add virtual destructors to appease compiler --- gtsam/discrete/DiscreteBayesNet.h | 3 +++ gtsam/discrete/DiscreteFactor.h | 2 +- gtsam/discrete/DiscreteFactorGraph.h | 3 +++ gtsam/linear/GaussianBayesNet.h | 5 ++++- gtsam/linear/GaussianFactor.h | 2 +- gtsam/linear/Preconditioner.h | 4 ++-- gtsam/nonlinear/NonlinearFactor.h | 5 ++--- gtsam/nonlinear/NonlinearFactorGraph.h | 3 +++ gtsam/sfm/BinaryMeasurement.h | 3 +++ gtsam/symbolic/SymbolicBayesNet.h | 3 +++ gtsam/symbolic/SymbolicConditional.h | 2 +- gtsam/symbolic/SymbolicFactorGraph.h | 3 +++ gtsam_unstable/discrete/Scheduler.cpp | 5 ++--- gtsam_unstable/discrete/Scheduler.h | 18 +++++++++++------- .../ConcurrentFilteringAndSmoothing.h | 8 ++++++-- gtsam_unstable/nonlinear/FixedLagSmoother.h | 4 +++- .../EquivInertialNavFactor_GlobalVel_NoBias.h | 4 +++- 17 files changed, 54 insertions(+), 23 deletions(-) diff --git a/gtsam/discrete/DiscreteBayesNet.h b/gtsam/discrete/DiscreteBayesNet.h index 237caf745..d5ba30584 100644 --- a/gtsam/discrete/DiscreteBayesNet.h +++ b/gtsam/discrete/DiscreteBayesNet.h @@ -55,6 +55,9 @@ namespace gtsam { template DiscreteBayesNet(const FactorGraph& graph) : Base(graph) {} + /// Destructor + virtual ~DiscreteBayesNet() {} + /// @} /// @name Testable diff --git a/gtsam/discrete/DiscreteFactor.h b/gtsam/discrete/DiscreteFactor.h index f8b3fc0bb..6b0919507 100644 --- a/gtsam/discrete/DiscreteFactor.h +++ b/gtsam/discrete/DiscreteFactor.h @@ -78,7 +78,7 @@ public: virtual bool equals(const DiscreteFactor& lf, double tol = 1e-9) const = 0; /// print - virtual void print( + void print( const std::string& s = "DiscreteFactor\n", const KeyFormatter& formatter = DefaultKeyFormatter) const override { Base::print(s, formatter); diff --git a/gtsam/discrete/DiscreteFactorGraph.h b/gtsam/discrete/DiscreteFactorGraph.h index 8df602af5..f39adc9a8 100644 --- a/gtsam/discrete/DiscreteFactorGraph.h +++ b/gtsam/discrete/DiscreteFactorGraph.h @@ -91,6 +91,9 @@ public: template DiscreteFactorGraph(const FactorGraph& graph) : Base(graph) {} + /// Destructor + virtual ~DiscreteFactorGraph() {} + /// @name Testable /// @{ diff --git a/gtsam/linear/GaussianBayesNet.h b/gtsam/linear/GaussianBayesNet.h index a45168e0b..e55a89bcd 100644 --- a/gtsam/linear/GaussianBayesNet.h +++ b/gtsam/linear/GaussianBayesNet.h @@ -55,6 +55,9 @@ namespace gtsam { template GaussianBayesNet(const FactorGraph& graph) : Base(graph) {} + /// Destructor + virtual ~GaussianBayesNet() {} + /// @} /// @name Testable @@ -178,7 +181,7 @@ namespace gtsam { VectorValues backSubstituteTranspose(const VectorValues& gx) const; /// print graph - virtual void print( + void print( const std::string& s = "", const KeyFormatter& formatter = DefaultKeyFormatter) const override { Base::print(s, formatter); diff --git a/gtsam/linear/GaussianFactor.h b/gtsam/linear/GaussianFactor.h index 72ad69693..334722868 100644 --- a/gtsam/linear/GaussianFactor.h +++ b/gtsam/linear/GaussianFactor.h @@ -56,7 +56,7 @@ namespace gtsam { // Implementing Testable interface /// print - virtual void print( + void print( const std::string& s = "", const KeyFormatter& formatter = DefaultKeyFormatter) const override = 0; diff --git a/gtsam/linear/Preconditioner.h b/gtsam/linear/Preconditioner.h index 3a406c0a5..1a5a08090 100644 --- a/gtsam/linear/Preconditioner.h +++ b/gtsam/linear/Preconditioner.h @@ -44,9 +44,9 @@ struct GTSAM_EXPORT PreconditionerParameters { inline Kernel kernel() const { return kernel_; } inline Verbosity verbosity() const { return verbosity_; } - void print() const ; + void print() const; - virtual void print(std::ostream &os) const ; + virtual void print(std::ostream &os) const; static Kernel kernelTranslator(const std::string &s); static Verbosity verbosityTranslator(const std::string &s); diff --git a/gtsam/nonlinear/NonlinearFactor.h b/gtsam/nonlinear/NonlinearFactor.h index adb6310e8..21c05dc2c 100644 --- a/gtsam/nonlinear/NonlinearFactor.h +++ b/gtsam/nonlinear/NonlinearFactor.h @@ -70,9 +70,8 @@ public: /// @{ /** print */ - virtual void print( - const std::string& s = "", - const KeyFormatter& keyFormatter = DefaultKeyFormatter) const override; + void print(const std::string& s = "", const KeyFormatter& keyFormatter = + DefaultKeyFormatter) const override; /** Check if two factors are equal */ virtual bool equals(const NonlinearFactor& f, double tol = 1e-9) const; diff --git a/gtsam/nonlinear/NonlinearFactorGraph.h b/gtsam/nonlinear/NonlinearFactorGraph.h index 9bca4a29d..4d321f8ab 100644 --- a/gtsam/nonlinear/NonlinearFactorGraph.h +++ b/gtsam/nonlinear/NonlinearFactorGraph.h @@ -98,6 +98,9 @@ namespace gtsam { template NonlinearFactorGraph(const FactorGraph& graph) : Base(graph) {} + /// Destructor + virtual ~NonlinearFactorGraph() {} + /** print */ void print( const std::string& str = "NonlinearFactorGraph: ", diff --git a/gtsam/sfm/BinaryMeasurement.h b/gtsam/sfm/BinaryMeasurement.h index 7e102fee7..bdb45d622 100644 --- a/gtsam/sfm/BinaryMeasurement.h +++ b/gtsam/sfm/BinaryMeasurement.h @@ -52,6 +52,9 @@ private: measured_(measured), noiseModel_(model) {} + /// Destructor + virtual ~BinaryMeasurement() {} + /// @name Standard Interface /// @{ diff --git a/gtsam/symbolic/SymbolicBayesNet.h b/gtsam/symbolic/SymbolicBayesNet.h index 45df56abd..464af060b 100644 --- a/gtsam/symbolic/SymbolicBayesNet.h +++ b/gtsam/symbolic/SymbolicBayesNet.h @@ -55,6 +55,9 @@ namespace gtsam { template SymbolicBayesNet(const FactorGraph& graph) : Base(graph) {} + /// Destructor + virtual ~SymbolicBayesNet() {} + /// @} /// @name Testable diff --git a/gtsam/symbolic/SymbolicConditional.h b/gtsam/symbolic/SymbolicConditional.h index 4088cbfb6..3abec92b8 100644 --- a/gtsam/symbolic/SymbolicConditional.h +++ b/gtsam/symbolic/SymbolicConditional.h @@ -105,7 +105,7 @@ namespace gtsam { /// @name Testable /** Print with optional formatter */ - virtual void print( + void print( const std::string& str = "", const KeyFormatter& keyFormatter = DefaultKeyFormatter) const override; diff --git a/gtsam/symbolic/SymbolicFactorGraph.h b/gtsam/symbolic/SymbolicFactorGraph.h index 7f4c84631..36379fd83 100644 --- a/gtsam/symbolic/SymbolicFactorGraph.h +++ b/gtsam/symbolic/SymbolicFactorGraph.h @@ -81,6 +81,9 @@ namespace gtsam { template SymbolicFactorGraph(const FactorGraph& graph) : Base(graph) {} + /// Destructor + virtual ~SymbolicFactorGraph() {} + /// @} /// @name Testable diff --git a/gtsam_unstable/discrete/Scheduler.cpp b/gtsam_unstable/discrete/Scheduler.cpp index a81048291..3273778c4 100644 --- a/gtsam_unstable/discrete/Scheduler.cpp +++ b/gtsam_unstable/discrete/Scheduler.cpp @@ -178,8 +178,7 @@ namespace gtsam { } // buildGraph /** print */ - void Scheduler::print(const string& s) const { - + void Scheduler::print(const string& s, const KeyFormatter& formatter) const { cout << s << " Faculty:" << endl; for(const string& name: facultyName_) cout << name << '\n'; @@ -210,7 +209,7 @@ namespace gtsam { CSP::print(s + " Factor graph"); cout << endl; - } // print + } // print /** Print readable form of assignment */ void Scheduler::printAssignment(sharedValues assignment) const { diff --git a/gtsam_unstable/discrete/Scheduler.h b/gtsam_unstable/discrete/Scheduler.h index 15ba60f46..6faf9956f 100644 --- a/gtsam_unstable/discrete/Scheduler.h +++ b/gtsam_unstable/discrete/Scheduler.h @@ -66,15 +66,17 @@ namespace gtsam { /** * Constructor - * WE need to know the number of students in advance for ordering keys. + * We need to know the number of students in advance for ordering keys. * then add faculty, slots, areas, availability, students, in that order */ - Scheduler(size_t maxNrStudents):maxNrStudents_(maxNrStudents) { - } + Scheduler(size_t maxNrStudents) : maxNrStudents_(maxNrStudents) {} - void addFaculty(const std::string& facultyName) { - facultyIndex_[facultyName] = nrFaculty(); - facultyName_.push_back(facultyName); + /// Destructor + virtual ~Scheduler() {} + + void addFaculty(const std::string& facultyName) { + facultyIndex_[facultyName] = nrFaculty(); + facultyName_.push_back(facultyName); } size_t nrFaculty() const { @@ -140,7 +142,9 @@ namespace gtsam { void buildGraph(size_t mutexBound = 7); /** print */ - void print(const std::string& s = "Scheduler") const; + void print( + const std::string& s = "Scheduler", + const KeyFormatter& formatter = DefaultKeyFormatter) const override; /** Print readable form of assignment */ void printAssignment(sharedValues assignment) const; diff --git a/gtsam_unstable/nonlinear/ConcurrentFilteringAndSmoothing.h b/gtsam_unstable/nonlinear/ConcurrentFilteringAndSmoothing.h index 316db921a..c87b99275 100644 --- a/gtsam_unstable/nonlinear/ConcurrentFilteringAndSmoothing.h +++ b/gtsam_unstable/nonlinear/ConcurrentFilteringAndSmoothing.h @@ -47,7 +47,9 @@ public: virtual ~ConcurrentFilter() {}; /** Implement a standard 'print' function */ - virtual void print(const std::string& s = "Concurrent Filter:\n", const KeyFormatter& keyFormatter = DefaultKeyFormatter) const = 0; + virtual void print( + const std::string& s = "Concurrent Filter:\n", + const KeyFormatter& keyFormatter = DefaultKeyFormatter) const = 0; /** Check if two Concurrent Smoothers are equal */ virtual bool equals(const ConcurrentFilter& rhs, double tol = 1e-9) const = 0; @@ -107,7 +109,9 @@ public: virtual ~ConcurrentSmoother() {}; /** Implement a standard 'print' function */ - virtual void print(const std::string& s = "Concurrent Smoother:\n", const KeyFormatter& keyFormatter = DefaultKeyFormatter) const = 0; + virtual void print( + const std::string& s = "Concurrent Smoother:\n", + const KeyFormatter& keyFormatter = DefaultKeyFormatter) const = 0; /** Check if two Concurrent Smoothers are equal */ virtual bool equals(const ConcurrentSmoother& rhs, double tol = 1e-9) const = 0; diff --git a/gtsam_unstable/nonlinear/FixedLagSmoother.h b/gtsam_unstable/nonlinear/FixedLagSmoother.h index 362cfae96..17fcf3908 100644 --- a/gtsam_unstable/nonlinear/FixedLagSmoother.h +++ b/gtsam_unstable/nonlinear/FixedLagSmoother.h @@ -69,7 +69,9 @@ public: virtual ~FixedLagSmoother() { } /** Print the factor for debugging and testing (implementing Testable) */ - virtual void print(const std::string& s = "FixedLagSmoother:\n", const KeyFormatter& keyFormatter = DefaultKeyFormatter) const; + virtual void print( + const std::string& s = "FixedLagSmoother:\n", + const KeyFormatter& keyFormatter = DefaultKeyFormatter) const; /** Check if two IncrementalFixedLagSmoother Objects are equal */ virtual bool equals(const FixedLagSmoother& rhs, double tol = 1e-9) const; diff --git a/gtsam_unstable/slam/EquivInertialNavFactor_GlobalVel_NoBias.h b/gtsam_unstable/slam/EquivInertialNavFactor_GlobalVel_NoBias.h index 9f5d800db..40dc81c9a 100644 --- a/gtsam_unstable/slam/EquivInertialNavFactor_GlobalVel_NoBias.h +++ b/gtsam_unstable/slam/EquivInertialNavFactor_GlobalVel_NoBias.h @@ -132,7 +132,9 @@ public: /** implement functions needed for Testable */ /** print */ - virtual void print(const std::string& s = "EquivInertialNavFactor_GlobalVel_NoBias", const KeyFormatter& keyFormatter = DefaultKeyFormatter) const { + virtual void print( + const std::string& s = "EquivInertialNavFactor_GlobalVel_NoBias", + const KeyFormatter& keyFormatter = DefaultKeyFormatter) const { std::cout << s << "(" << keyFormatter(this->key1()) << "," << keyFormatter(this->key2()) << ","