stdr_parser_node.cpp
Go to the documentation of this file.
00001 /******************************************************************************
00002    STDR Simulator - Simple Two DImensional Robot Simulator
00003    Copyright (C) 2013 STDR Simulator
00004    This program is free software; you can redistribute it and/or modify
00005    it under the terms of the GNU General Public License as published by
00006    the Free Software Foundation; either version 3 of the License, or
00007    (at your option) any later version.
00008    This program is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011    GNU General Public License for more details.
00012    You should have received a copy of the GNU General Public License
00013    along with this program; if not, write to the Free Software Foundation,
00014    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
00015    
00016    Authors : 
00017    * Manos Tsardoulias, etsardou@gmail.com
00018    * Aris Thallas, aris.thallas@gmail.com
00019    * Chris Zalidis, zalidis@gmail.com 
00020 ******************************************************************************/
00021 
00022 #include "stdr_parser/stdr_parser_node.h"
00023 
00024 namespace stdr_parser
00025 {
00030   Node::Node(void)
00031   {
00032     priority = 0;
00033   }
00034   
00039   bool Node::checkForFilename(std::string base)
00040   {
00041     if(elements.size() == 1)
00042     {
00043       if(elements[0]->tag == base)
00044       {
00045         return true;
00046       }
00047     }
00048     return false;
00049   }
00050   
00056   std::vector<int> Node::getTag(std::string tag)
00057   {
00058     std::vector<int> ret;
00059     for(unsigned int i = 0 ; i < elements.size() ; i++)
00060     {
00061       if(elements[i]->tag == tag)
00062       {
00063         ret.push_back(i);
00064       }
00065     }
00066     return ret;
00067   }
00068   
00073   void Node::increasePriority(void)
00074   {
00075     priority ++;
00076     for(unsigned int i = 0 ; i < elements.size() ; i++)
00077     {
00078       elements[i]->increasePriority();
00079     }
00080   }
00081   
00088   void Node::printParsedXml(Node *n,std::string indent)
00089   {
00090     if(n->value != "")
00091     {  
00092       ROS_ERROR("%s- '%s' (%d) - %d %s",indent.c_str(),n->value.c_str(),
00093         n->priority, n->file_row, extractFilename(n->file_origin).c_str());
00094     }
00095     else
00096     {
00097       ROS_ERROR("%s[%s] (%d) - %d %s",indent.c_str(),n->tag.c_str(),
00098         n->priority, n->file_row, extractFilename(n->file_origin).c_str());
00099     }  
00100     for(unsigned int i = 0 ; i < n->elements.size() ; i++)
00101     {
00102       printParsedXml(n->elements[i],indent+std::string("| "));
00103     }
00104   }
00105   
00110   void Node::unallocateChildren(void)
00111   {
00112     for(unsigned int i = 0 ; i < elements.size() ; i++)
00113     {
00114       elements[i]->unallocateChildren();
00115       delete elements[i];
00116     }
00117   }
00118 }


stdr_parser
Author(s): Manos Tsardoulias, Chris Zalidis, Aris Thallas
autogenerated on Wed Sep 2 2015 03:36:18