hpp-manipulation  9.0.2
Classes for manipulation planning.
graph-component.hh
Go to the documentation of this file.
1 // Copyright (c) 2014, LAAS-CNRS
2 // Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3 //
4 
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // 1. Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // 2. Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
27 // DAMAGE.
28 
29 #ifndef HPP_MANIPULATION_GRAPH_GRAPHCOMPONENT_HH
30 #define HPP_MANIPULATION_GRAPH_GRAPHCOMPONENT_HH
31 
32 #include <ostream>
33 #include <string>
34 
36 #include "hpp/manipulation/fwd.hh"
39 
40 namespace hpp {
41 namespace manipulation {
43 namespace graph {
45 
48 
51  public:
52  virtual ~GraphComponent() {};
53 
55  const std::string& name() const;
56 
58  const std::size_t& id() const { return id_; }
59 
61  virtual void addNumericalConstraint(const ImplicitPtr_t& numConstraint);
62 
64  virtual void addNumericalCost(const ImplicitPtr_t& numCost);
65 
67  virtual void resetNumericalConstraints();
68 
72 
75 
78 
80  void parentGraph(const GraphWkPtr_t& parent);
81 
84 
86  virtual std::ostream& dotPrint(
87  std::ostream& os,
89 
92  virtual void invalidate() { isInit_ = false; }
93 
96  void solveLevelByLevel(bool solveLevelByLevel) {
97  solveLevelByLevel_ = solveLevelByLevel;
98  }
99 
102  bool solveLevelByLevel() const { return solveLevelByLevel_; }
103 
104  protected:
106  void init(const GraphComponentWkPtr_t& weak);
107 
108  GraphComponent(const std::string& name)
109  : isInit_(false), name_(name), id_(-1), solveLevelByLevel_(false) {}
110 
116  GraphWkPtr_t graph_;
117 
118  bool isInit_;
119 
120  void throwIfNotInitialized() const;
121 
123  virtual std::ostream& print(std::ostream& os) const;
124  friend std::ostream& operator<<(std::ostream&, const GraphComponent&);
125 
127  virtual void populateTooltip(dot::Tooltip& tp) const;
128 
129  virtual void initialize() = 0;
130 
131  private:
133  std::string name_;
135  GraphComponentWkPtr_t wkPtr_;
137  std::size_t id_;
139  bool solveLevelByLevel_;
140  friend class Graph;
141 };
142 
143 std::ostream& operator<<(std::ostream& os, const GraphComponent& graphComp);
144 
146 } // namespace graph
147 } // namespace manipulation
148 
149 } // namespace hpp
150 
151 #endif // HPP_MANIPULATION_GRAPH_GRAPHCOMPONENT_HH
Define common methods of the graph components.
Definition: graph-component.hh:50
virtual std::ostream & dotPrint(std::ostream &os, dot::DrawingAttributes da=dot::DrawingAttributes()) const
Print the component in DOT language.
bool solveLevelByLevel() const
Definition: graph-component.hh:102
NumericalConstraints_t numericalCosts_
Stores the numerical costs.
Definition: graph-component.hh:114
void init(const GraphComponentWkPtr_t &weak)
Initialize the component.
const std::string & name() const
Get the component name.
GraphPtr_t parentGraph() const
Set the parent graph.
void solveLevelByLevel(bool solveLevelByLevel)
Definition: graph-component.hh:96
GraphComponent(const std::string &name)
Definition: graph-component.hh:108
virtual void populateTooltip(dot::Tooltip &tp) const
Populate DrawingAttributes tooltip.
NumericalConstraints_t numericalConstraints_
Stores the numerical constraints.
Definition: graph-component.hh:112
virtual std::ostream & print(std::ostream &os) const
Print the object in a stream.
GraphWkPtr_t graph_
A weak pointer to the parent graph.
Definition: graph-component.hh:116
virtual ~GraphComponent()
Definition: graph-component.hh:52
const NumericalConstraints_t & numericalCosts() const
Get a reference to the NumericalConstraints_t.
bool insertNumericalConstraints(ConfigProjectorPtr_t &proj) const
const std::size_t & id() const
Return the component id.
Definition: graph-component.hh:58
virtual void invalidate()
Definition: graph-component.hh:92
friend std::ostream & operator<<(std::ostream &, const GraphComponent &)
virtual void addNumericalCost(const ImplicitPtr_t &numCost)
Add a cost function Implicit to the component.
void parentGraph(const GraphWkPtr_t &parent)
Set the parent graph.
const NumericalConstraints_t & numericalConstraints() const
Get a reference to the NumericalConstraints_t.
virtual void addNumericalConstraint(const ImplicitPtr_t &numConstraint)
Add constraint to the component.
bool isInit_
Definition: graph-component.hh:118
virtual void resetNumericalConstraints()
Reset the numerical constraints stored in the component.
Definition: graph.hh:61
#define HPP_MANIPULATION_DLLAPI
Definition: config.hh:88
std::ostream & operator<<(std::ostream &os, const GraphComponent &graphComp)
shared_ptr< Implicit > ImplicitPtr_t
hpp::core::NumericalConstraints_t NumericalConstraints_t
Definition: fwd.hh:64
shared_ptr< Graph > GraphPtr_t
Definition: fwd.hh:47
constraints::ImplicitPtr_t ImplicitPtr_t
Definition: fwd.hh:131
core::ConfigProjectorPtr_t ConfigProjectorPtr_t
Definition: fwd.hh:136