hpp-manipulation  4.9.0
Classes for manipulation planning.
validation.hh
Go to the documentation of this file.
1 // Copyright (c) 2019, LAAS-CNRS
2 // Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3 //
4 // This file is part of hpp-manipulation.
5 // hpp-manipulation is free software: you can redistribute it
6 // and/or modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation, either version
8 // 3 of the License, or (at your option) any later version.
9 //
10 // hpp-manipulation is distributed in the hope that it will be
11 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Lesser Public License for more details. You should have
14 // received a copy of the GNU Lesser General Public License along with
15 // hpp-manipulation. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef HPP_MANIPULATION_GRAPH_VALIDATION_REPORT_HH
18 # define HPP_MANIPULATION_GRAPH_VALIDATION_REPORT_HH
19 
20 # include <string>
21 # include <vector>
22 # include <hpp/core/validation-report.hh>
23 
24 # include <hpp/manipulation/config.hh>
25 # include <hpp/manipulation/fwd.hh>
27 
28 namespace hpp {
29  namespace manipulation {
30  namespace graph {
33 
38  class HPP_MANIPULATION_DLLAPI Validation
39  {
40  public:
42  : problem_ (problem) {}
43 
44  void clear ()
45  {
46  warnings_.clear();
47  errors_.clear();
48  }
49 
50  bool hasWarnings () const { return !warnings_.empty(); }
51 
52  bool hasErrors () const { return !errors_.empty(); }
53 
54  virtual std::ostream& print (std::ostream& os) const;
55 
62  bool validate (const GraphComponentPtr_t& comp);
63 
67  bool validateState (const StatePtr_t& state);
68 
72  bool validateEdge (const EdgePtr_t & edge);
73 
77  bool validateGraph (const GraphPtr_t& graph);
78 
79 
80  private:
81  void addWarning (const GraphComponentPtr_t& c, const std::string& w)
82  {
83  warnings_.push_back (Message (c, w));
84  }
85 
86  void addError (const GraphComponentPtr_t& c, const std::string& w)
87  {
88  errors_.push_back (Message (c, w));
89  }
90 
91  typedef std::pair<GraphComponentPtr_t, std::string> Message;
92  std::vector<Message> warnings_, errors_;
93 
94  core::ProblemPtr_t problem_;
95  };
96 
97  inline std::ostream& operator<< (std::ostream& os, const Validation& v)
98  {
99  return v.print(os);
100  }
101 
103  } // namespace graph
104  } // namespace manipulation
105 
106 } // namespace hpp
107 
108 #endif // HPP_MANIPULATION_GRAPH_VALIDATION_REPORT_HH
boost::shared_ptr< GraphComponent > GraphComponentPtr_t
Definition: fwd.hh:43
void clear()
Definition: validation.hh:44
bool hasErrors() const
Definition: validation.hh:52
Validation(const core::ProblemPtr_t &problem)
Definition: validation.hh:41
boost::shared_ptr< State > StatePtr_t
Definition: fwd.hh:36
Vec3f c
Definition: validation.hh:38
virtual std::ostream & print(std::ostream &os) const
std::ostream & operator<<(std::ostream &os, const GraphComponent &graphComp)
const Problem & problem() const
boost::shared_ptr< Edge > EdgePtr_t
Definition: fwd.hh:37
bool hasWarnings() const
Definition: validation.hh:50
boost::shared_ptr< Graph > GraphPtr_t
Definition: fwd.hh:35
boost::shared_ptr< Problem > ProblemPtr_t