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/edge_constraint.h>
26 #include <navgraph/constraints/edge_cost_constraint.h>
27 #include <navgraph/constraints/node_constraint.h>
28 #include <navgraph/navgraph_edge.h>
29 
30 #include <list>
31 #include <map>
32 #include <tuple>
33 #include <vector>
34 
35 namespace fawkes {
36 
37 class NavGraphConstraintRepo
38 {
39 public:
40  /** List of navgraph node constraints. */
41  typedef std::vector<fawkes::NavGraphNodeConstraint *> NodeConstraintList;
42  /** List of navgraph edge constraints. */
43  typedef std::vector<fawkes::NavGraphEdgeConstraint *> EdgeConstraintList;
44  /** List of navgraph edge cost constraints. */
45  typedef std::vector<fawkes::NavGraphEdgeCostConstraint *> EdgeCostConstraintList;
46 
49 
53  void unregister_constraint(std::string name);
54 
55  bool has_constraint(std::string &name);
59 
60  const NodeConstraintList & node_constraints() const;
61  const EdgeConstraintList & edge_constraints() const;
63 
64  bool has_constraints() const;
65 
66  bool compute();
67 
70 
72  const fawkes::NavGraphNode &to);
73 
75  const fawkes::NavGraphNode &to,
76  float & cost_factor);
77 
78  float cost_factor(const fawkes::NavGraphNode &from, const fawkes::NavGraphNode &to);
79 
80  std::map<std::string, std::string> blocks(const std::vector<fawkes::NavGraphNode> &nodes);
81 
82  std::map<std::pair<std::string, std::string>, std::string>
83  blocks(const std::vector<fawkes::NavGraphEdge> &edges);
84 
85  std::list<std::tuple<std::string, std::string, std::string, float>>
86  cost_factor(const std::vector<fawkes::NavGraphEdge> &edges);
87 
88  bool modified(bool reset_modified = false);
89 
90 private:
91  NodeConstraintList node_constraints_;
92  EdgeConstraintList edge_constraints_;
93  EdgeCostConstraintList edge_cost_constraints_;
94  bool modified_;
95 };
96 } // namespace fawkes
97 
98 #endif
fawkes::NavGraphConstraintRepo::compute
bool compute()
Call compute method on all registered constraints.
Definition: constraint_repo.cpp:236
fawkes::NavGraphConstraintRepo::get_node_constraint
fawkes::NavGraphNodeConstraint * get_node_constraint(std::string &name)
Get a node constraint by name.
Definition: constraint_repo.cpp:146
fawkes::NavGraphNode
Definition: navgraph_node.h:40
fawkes::NavGraphConstraintRepo::node_constraints
const NodeConstraintList & node_constraints() const
Get a list of registered node constraints.
Definition: constraint_repo.cpp:199
fawkes::NavGraphConstraintRepo::unregister_constraint
void unregister_constraint(std::string name)
Unregister a constraint by name.
Definition: constraint_repo.cpp:80
fawkes::NavGraphConstraintRepo::~NavGraphConstraintRepo
~NavGraphConstraintRepo()
Destructor.
Definition: constraint_repo.cpp:42
fawkes::NavGraphConstraintRepo::has_constraints
bool has_constraints() const
Check if there are any constraints at all.
Definition: constraint_repo.cpp:226
fawkes::NavGraphConstraintRepo::NodeConstraintList
std::vector< fawkes::NavGraphNodeConstraint * > NodeConstraintList
List of navgraph node constraints.
Definition: constraint_repo.h:53
fawkes::NavGraphConstraintRepo::cost_factor
float cost_factor(const fawkes::NavGraphNode &from, const fawkes::NavGraphNode &to)
Get the highest increasing cost factor for an edge.
Definition: constraint_repo.cpp:430
fawkes::NavGraphConstraintRepo::EdgeConstraintList
std::vector< fawkes::NavGraphEdgeConstraint * > EdgeConstraintList
List of navgraph edge constraints.
Definition: constraint_repo.h:55
fawkes::NavGraphNodeConstraint
Definition: node_constraint.h:40
fawkes::NavGraphConstraintRepo::edge_cost_constraints
const EdgeCostConstraintList & edge_cost_constraints() const
Get a list of registered edge cost constraints.
Definition: constraint_repo.cpp:217
fawkes::NavGraphConstraintRepo::NavGraphConstraintRepo
NavGraphConstraintRepo()
Constructor.
Definition: constraint_repo.cpp:36
fawkes::NavGraphConstraintRepo::blocks
NavGraphNodeConstraint * blocks(const fawkes::NavGraphNode &node)
Check if any constraint in the repo blocks the node.
Definition: constraint_repo.cpp:261
fawkes::NavGraphEdgeConstraint
Definition: edge_constraint.h:40
fawkes::NavGraphEdgeCostConstraint
Definition: edge_cost_constraint.h:38
fawkes
fawkes::NavGraphConstraintRepo::edge_constraints
const EdgeConstraintList & edge_constraints() const
Get a list of registered edge constraints.
Definition: constraint_repo.cpp:208
fawkes::NavGraphConstraintRepo::get_edge_cost_constraint
fawkes::NavGraphEdgeCostConstraint * get_edge_cost_constraint(std::string &name)
Get an edge cost constraint by name.
Definition: constraint_repo.cpp:182
fawkes::NavGraphConstraintRepo::modified
bool modified(bool reset_modified=false)
Check if the constraint repo has been modified.
Definition: constraint_repo.cpp:449
fawkes::NavGraphConstraintRepo::increases_cost
NavGraphEdgeCostConstraint * increases_cost(const fawkes::NavGraphNode &from, const fawkes::NavGraphNode &to)
Check if any constraint in the repo increases the cost of the edge.
Definition: constraint_repo.cpp:318
fawkes::NavGraphConstraintRepo::register_constraint
void register_constraint(NavGraphNodeConstraint *constraint)
Register a constraint.
Definition: constraint_repo.cpp:50
fawkes::NavGraphConstraintRepo::has_constraint
bool has_constraint(std::string &name)
Check by name if a constraint has been registered.
Definition: constraint_repo.cpp:115
fawkes::NavGraphConstraintRepo::get_edge_constraint
fawkes::NavGraphEdgeConstraint * get_edge_constraint(std::string &name)
Get an edge constraint by name.
Definition: constraint_repo.cpp:164
fawkes::NavGraphConstraintRepo::EdgeCostConstraintList
std::vector< fawkes::NavGraphEdgeCostConstraint * > EdgeCostConstraintList
List of navgraph edge cost constraints.
Definition: constraint_repo.h:57