Fawkes API  Fawkes Development Version
rcsoft_map_node.cpp
1 
2 /***************************************************************************
3  * rcsoft_map_node.cpp - Node used in RCSoftMapGraph
4  *
5  * Created: Tue Jun 30 09:33:03 2009 (RoboCup 2009, Graz)
6  * Copyright 2009 Tim Niemueller [www.niemueller.de]
7  *
8  * $Id: rcsoft_map_node.cpp 2828 2009-07-06 09:11:16Z tim $
9  *
10  ****************************************************************************/
11 
12 /* This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version. A runtime exception applies to
16  * this software (see LICENSE.GPL_WRE file mentioned below for details).
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU Library General Public License for more details.
22  *
23  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
24  */
25 
26 #include "rcsoft_map_node.h"
27 
28 #include <algorithm>
29 
30 namespace fawkes {
31 #if 0 /* just to make Emacs auto-indent happy */
32 }
33 #endif
34 
35 /** @class RCSoftMapNode <utils/graph/rcsoft_map_node.h>
36  * RCSoft map node representation.
37  * @author Tim Niemueller
38  */
39 
40 /** Constructor for invalid node. */
41 RCSoftMapNode::RCSoftMapNode()
42 {
43  __name = "";
44  __x = 0.0;
45  __y = 0.0;
46  __children.clear();
47  __properties.clear();
48  __aliases.clear();
49 }
50 
51 
52 /** Constructor.
53  * @param name name of the node
54  * @param x World X coordinate of the node
55  * @param y World Y position of the node
56  * @param children vector of child nodes
57  * @param properties vector of properties
58  * @param aliases vector of aliases
59  */
60 RCSoftMapNode::RCSoftMapNode(std::string name, float x, float y,
61  std::vector< std::string > children,
62  std::vector< std::string > properties,
63  std::vector< std::string > aliases)
64 {
65  __name = name;
66  __x = x;
67  __y = y;
68  __children = children,
69  __properties = properties;
70  __aliases = aliases;
71 }
72 
73 
74 /** Get node name.
75  * @return node name
76  */
77 const std::string &
78 RCSoftMapNode::name() const
79 {
80  return __name;
81 }
82 
83 
84 /** Get node X coordinate.
85  * @return node X coordinate
86  */
87 float
88 RCSoftMapNode::x() const
89 {
90  return __x;
91 }
92 
93 
94 /** Get node Y coordinate.
95  * @return node Y coordinate
96  */
97 float
98 RCSoftMapNode::y() const
99 {
100  return __y;
101 }
102 
103 
104 /** Get children of node.
105  * @return reference to vector of child node names
106  */
107 std::vector<std::string> &
108 RCSoftMapNode::children()
109 {
110  return __children;
111 }
112 
113 
114 /** Get properties of node.
115  * @return reference to vector of properties
116  */
117 std::vector<std::string> &
118 RCSoftMapNode::properties()
119 {
120  return __properties;
121 }
122 
123 
124 /** Get aliases.
125  * @return reference to vector of aliases
126  */
127 std::vector<std::string> &
128 RCSoftMapNode::aliases()
129 {
130  return __aliases;
131 }
132 
133 
134 /** Check if node has a specific property.
135  * @param property property to check for
136  * @return true if the node has the specified property, false otherwise
137  */
138 bool
139 RCSoftMapNode::has_property(std::string property)
140 {
141  return (std::find(__properties.begin(), __properties.end(), property) != __properties.end());
142 }
143 
144 
145 /** Check if node has a specific alias.
146  * @param alias alias to check for
147  * @return true if the node has the specified alias, false otherwise
148  */
149 bool
150 RCSoftMapNode::has_alias(std::string alias)
151 {
152  return (std::find(__aliases.begin(), __aliases.end(), alias) != __aliases.end());
153 }
154 
155 
156 /** Check if the node is valid.
157  * @return true if the node is valid, false otherwise
158  */
159 bool
160 RCSoftMapNode::is_valid() const
161 {
162  return (__name != "");
163 }
164 
165 } // end of namespace fawkes
Fawkes library namespace.