Fawkes API  Fawkes Development Version
constraint_repo.h
1 /***************************************************************************
2  * constraint_repo.h - navgraph constraint repository
3  *
4  * Created: Fr Mar 14 10:47:35 2014
5  * Copyright 2014 Sebastian Reuter
6  * 2014 Tim Niemueller
7  ****************************************************************************/
8 
9 /* This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Library General Public License for more details.
18  *
19  * Read the full text in the LICENSE.GPL file in the doc directory.
20  */
21 
22 #ifndef __NAVGRAPH_CONSTRAINTS_CONSTRAINT_REPO_H_
23 #define __NAVGRAPH_CONSTRAINTS_CONSTRAINT_REPO_H_
24 
25 #include <navgraph/constraints/node_constraint.h>
26 #include <navgraph/constraints/edge_constraint.h>
27 #include <navgraph/constraints/edge_cost_constraint.h>
28 
29 #include <navgraph/navgraph_edge.h>
30 
31 #include <vector>
32 #include <tuple>
33 #include <list>
34 #include <map>
35 
36 namespace fawkes{
37 #if 0 /* just to make Emacs auto-indent happy */
38 }
39 #endif
40 
42 {
43  public:
44  /** List of navgraph node constraints. */
45  typedef std::vector<fawkes::NavGraphNodeConstraint*> NodeConstraintList;
46  /** List of navgraph edge constraints. */
47  typedef std::vector<fawkes::NavGraphEdgeConstraint*> EdgeConstraintList;
48  /** List of navgraph edge cost constraints. */
49  typedef std::vector<fawkes::NavGraphEdgeCostConstraint*> EdgeCostConstraintList;
50 
53 
57  void unregister_constraint(std::string name);
58 
59  bool has_constraint(std::string &name);
63 
64  const NodeConstraintList & node_constraints() const;
65  const EdgeConstraintList & edge_constraints() const;
66  const EdgeCostConstraintList & edge_cost_constraints() const;
67 
68  bool has_constraints() const;
69 
70  bool compute();
71 
74  const fawkes::NavGraphNode &to);
75 
77  const fawkes::NavGraphNode &to);
78 
80  const fawkes::NavGraphNode &to,
81  float & cost_factor);
82 
83  float cost_factor(const fawkes::NavGraphNode &from,
84  const fawkes::NavGraphNode &to);
85 
86  std::map<std::string, std::string>
87  blocks(const std::vector<fawkes::NavGraphNode> &nodes);
88 
89  std::map<std::pair<std::string, std::string>, std::string>
90  blocks(const std::vector<fawkes::NavGraphEdge> &edges);
91 
92  std::list<std::tuple<std::string, std::string, std::string, float>>
93  cost_factor(const std::vector<fawkes::NavGraphEdge> &edges);
94 
95  bool modified(bool reset_modified = false);
96 
97  private:
98 
99  NodeConstraintList node_constraints_;
100  EdgeConstraintList edge_constraints_;
101  EdgeCostConstraintList edge_cost_constraints_;
102  bool modified_;
103 };
104 } // namespace
105 
106 #endif
std::vector< fawkes::NavGraphNodeConstraint * > NodeConstraintList
List of navgraph node constraints.
Constraint that can be queried to check if an edge is blocked.
bool compute()
Call compute method on all registered constraints.
fawkes::NavGraphNodeConstraint * get_node_constraint(std::string &name)
Get a node constraint by name.
float cost_factor(const fawkes::NavGraphNode &from, const fawkes::NavGraphNode &to)
Get the highest increasing cost factor for an edge.
Fawkes library namespace.
std::vector< fawkes::NavGraphEdgeConstraint * > EdgeConstraintList
List of navgraph edge constraints.
NavGraphEdgeCostConstraint * increases_cost(const fawkes::NavGraphNode &from, const fawkes::NavGraphNode &to)
Check if any constraint in the repo increases the cost of the edge.
const NodeConstraintList & node_constraints() const
Get a list of registered node constraints.
Constraint that can be queried for an edge cost factor.
fawkes::NavGraphEdgeCostConstraint * get_edge_cost_constraint(std::string &name)
Get an edge cost constraint by name.
Constraint repository to maintain blocks on nodes.
const EdgeCostConstraintList & edge_cost_constraints() const
Get a list of registered edge cost constraints.
const EdgeConstraintList & edge_constraints() const
Get a list of registered edge constraints.
Topological graph node.
Definition: navgraph_node.h:38
void unregister_constraint(std::string name)
Unregister a constraint by name.
bool has_constraints() const
Check if there are any constraints at all.
bool modified(bool reset_modified=false)
Check if the constraint repo has been modified.
void register_constraint(NavGraphNodeConstraint *constraint)
Register a constraint.
bool has_constraint(std::string &name)
Check by name if a constraint has been registered.
Constraint that can be queried to check if a node is blocked.
fawkes::NavGraphEdgeConstraint * get_edge_constraint(std::string &name)
Get an edge constraint by name.
NavGraphNodeConstraint * blocks(const fawkes::NavGraphNode &node)
Check if any constraint in the repo blocks the node.
std::vector< fawkes::NavGraphEdgeCostConstraint * > EdgeCostConstraintList
List of navgraph edge cost constraints.