Fawkes API  Fawkes Development Version
rcsoft_map_node.cpp
00001 
00002 /***************************************************************************
00003  *  rcsoft_map_node.cpp - Node used in RCSoftMapGraph
00004  *
00005  *  Created: Tue Jun 30 09:33:03 2009 (RoboCup 2009, Graz)
00006  *  Copyright  2009  Tim Niemueller [www.niemueller.de]
00007  *
00008  *  $Id: rcsoft_map_node.cpp 2828 2009-07-06 09:11:16Z tim $
00009  *
00010  ****************************************************************************/
00011 
00012 /*  This program is free software; you can redistribute it and/or modify
00013  *  it under the terms of the GNU General Public License as published by
00014  *  the Free Software Foundation; either version 2 of the License, or
00015  *  (at your option) any later version. A runtime exception applies to
00016  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00017  *
00018  *  This program is distributed in the hope that it will be useful,
00019  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  *  GNU Library General Public License for more details.
00022  *
00023  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00024  */
00025 
00026 #include "rcsoft_map_node.h"
00027 
00028 #include <algorithm>
00029 
00030 namespace fawkes {
00031 #if 0 /* just to make Emacs auto-indent happy */
00032 }
00033 #endif
00034 
00035 /** @class RCSoftMapNode <utils/graph/rcsoft_map_node.h>
00036  * RCSoft map node representation.
00037  * @author Tim Niemueller
00038  */
00039 
00040 /** Constructor for invalid node. */
00041 RCSoftMapNode::RCSoftMapNode()
00042 {
00043   __name       = "";
00044   __x          = 0.0;
00045   __y          = 0.0;
00046   __children.clear();
00047   __properties.clear();
00048   __aliases.clear();
00049 }
00050 
00051 
00052 /** Constructor.
00053  * @param name name of the node
00054  * @param x World X coordinate of the node
00055  * @param y World Y position of the node
00056  * @param children vector of child nodes
00057  * @param properties vector of properties
00058  * @param aliases vector of aliases
00059  */
00060 RCSoftMapNode::RCSoftMapNode(std::string name, float x, float y,
00061                              std::vector< std::string > children,
00062                              std::vector< std::string > properties,
00063                              std::vector< std::string > aliases)
00064 {
00065   __name       = name;
00066   __x          = x;
00067   __y          = y;
00068   __children   = children,
00069   __properties = properties;
00070   __aliases    = aliases;
00071 }
00072 
00073 
00074 /** Get node name.
00075  * @return node name
00076  */
00077 const std::string &
00078 RCSoftMapNode::name() const
00079 {
00080   return __name;
00081 }
00082 
00083 
00084 /** Get node X coordinate.
00085  * @return node X coordinate
00086  */
00087 float
00088 RCSoftMapNode::x() const
00089 {
00090   return __x;
00091 }
00092 
00093 
00094 /** Get node Y coordinate.
00095  * @return node Y coordinate
00096  */
00097 float
00098 RCSoftMapNode::y() const
00099 {
00100   return __y;
00101 }
00102 
00103 
00104 /** Get children of node.
00105  * @return reference to vector of child node names
00106  */
00107 std::vector<std::string> &
00108 RCSoftMapNode::children()
00109 {
00110   return __children;
00111 }
00112 
00113 
00114 /** Get properties of node.
00115  * @return reference to vector of properties
00116  */
00117 std::vector<std::string> &
00118 RCSoftMapNode::properties()
00119 {
00120   return __properties;
00121 }
00122 
00123 
00124 /** Get aliases.
00125  * @return reference to vector of aliases
00126  */
00127 std::vector<std::string> &
00128 RCSoftMapNode::aliases()
00129 {
00130   return __aliases;
00131 }
00132 
00133 
00134 /** Check if node has a specific property.
00135  * @param property property to check for
00136  * @return true if the node has the specified property, false otherwise
00137  */
00138 bool
00139 RCSoftMapNode::has_property(std::string property)
00140 {
00141   return (std::find(__properties.begin(), __properties.end(), property) != __properties.end());
00142 }
00143 
00144 
00145 /** Check if node has a specific alias.
00146  * @param alias alias to check for
00147  * @return true if the node has the specified alias, false otherwise
00148  */
00149 bool
00150 RCSoftMapNode::has_alias(std::string alias)
00151 {
00152   return (std::find(__aliases.begin(), __aliases.end(), alias) != __aliases.end());
00153 }
00154 
00155 
00156 /** Check if the node is valid.
00157  * @return true if the node is valid, false otherwise
00158  */
00159 bool 
00160 RCSoftMapNode::is_valid() const
00161 {
00162   return (__name != "");
00163 }
00164 
00165 } // end of namespace fawkes