[GIT] ppl/ppl(master): Declare pure virtual methods in abstract base classes.

Module: ppl/ppl Branch: master Commit: 7214979d8337182cd1592292abdaabc772c0f94c URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=7214979d83371...
Author: Enea Zaffanella zaffanella@cs.unipr.it Date: Wed Feb 22 09:21:44 2012 +0100
Declare pure virtual methods in abstract base classes. Override them only once in derived classes. Detected by ECLAIR service ovrdonce.
---
src/PIP_Tree.cc | 16 ++++++++-------- src/PIP_Tree.defs.hh | 14 ++++++++++---- 2 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/src/PIP_Tree.cc b/src/PIP_Tree.cc index 77bd698..f4b2f28 100644 --- a/src/PIP_Tree.cc +++ b/src/PIP_Tree.cc @@ -1051,23 +1051,23 @@ PIP_Decision_Node::check_ownership(const PIP_Problem* owner) const { && (true_child == 0 || true_child->check_ownership(owner)); }
-const PIP_Solution_Node* -PIP_Tree_Node::as_solution() const { - return 0; +const PIP_Decision_Node* +PIP_Decision_Node::as_decision() const { + return this; }
const PIP_Decision_Node* -PIP_Tree_Node::as_decision() const { +PIP_Solution_Node::as_decision() const { return 0; }
const PIP_Solution_Node* -PIP_Solution_Node::as_solution() const { - return this; +PIP_Decision_Node::as_solution() const { + return 0; }
-const PIP_Decision_Node* -PIP_Decision_Node::as_decision() const { +const PIP_Solution_Node* +PIP_Solution_Node::as_solution() const { return this; }
diff --git a/src/PIP_Tree.defs.hh b/src/PIP_Tree.defs.hh index 043895b..226d439 100644 --- a/src/PIP_Tree.defs.hh +++ b/src/PIP_Tree.defs.hh @@ -74,13 +74,13 @@ public: virtual ~PIP_Tree_Node();
//! Returns \c true if and only if \p *this is well formed. - virtual bool OK() const; + virtual bool OK() const = 0;
//! Returns \p this if \p *this is a solution node, 0 otherwise. - virtual const PIP_Solution_Node* as_solution() const; + virtual const PIP_Solution_Node* as_solution() const = 0;
//! Returns \p this if \p *this is a decision node, 0 otherwise. - virtual const PIP_Decision_Node* as_decision() const; + virtual const PIP_Decision_Node* as_decision() const = 0;
/*! \brief Returns the system of parameter constraints controlling \p *this. @@ -242,7 +242,7 @@ protected: virtual void print_tree(std::ostream& s, unsigned indent, const std::vector<bool>& pip_dim_is_param, - dimension_type first_art_dim) const; + dimension_type first_art_dim) const = 0;
//! A helper function used when printing PIP trees. static void @@ -368,6 +368,9 @@ public: //! Returns \p this. virtual const PIP_Solution_Node* as_solution() const;
+ //! Returns 0, since \p this is not a decision node. + virtual const PIP_Decision_Node* as_decision() const; + /*! \brief Returns a parametric expression for the values of problem variable \p var.
@@ -708,6 +711,9 @@ public: //! Returns \p this. virtual const PIP_Decision_Node* as_decision() const;
+ //! Returns 0, since \p this is not a solution node. + virtual const PIP_Solution_Node* as_solution() const; + //! Returns a const pointer to the \p b (true or false) branch of \p *this. const PIP_Tree_Node* child_node(bool b) const;
participants (1)
-
Enea Zaffanella