SemanticNode.cpp

Go to the documentation of this file.
00001 /*
00002 Copyright 2007, 2008, 2009, 2010, 2011 Instituto de Sistemas e Robotica, Instituto Superior Tecnico
00003 
00004 This file is part of MeRMaID.
00005 
00006 MeRMaID is free software: you can redistribute it and/or modify
00007 it under the terms of the GNU Lesser General Public License as published by
00008 the Free Software Foundation, either version 3 of the License, or
00009 (at your option) any later version.
00010 
00011 MeRMaID is distributed in the hope that it will be useful,
00012 but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 GNU Lesser General Public License for more details.
00015 
00016 You should have received a copy of the GNU Lesser General Public License
00017 along with MeRMaID.  If not, see <http://www.gnu.org/licenses/>.
00018 */
00019 
00020 
00021 
00022 /**
00023 * @Filename SemanticNode.cpp
00024 * @Description SemanticNode class implementation.
00025 * @Status Implementing
00026 * @Version $Id: SemanticNode.cpp 1 2011-03-04 18:13:18Z jreis $
00027 * @Maintainer Marco Barbosa + Nelson Ramos
00028 */
00029 
00030 #include "config.h"
00031 
00032 #include "SemanticNode.hpp"
00033 
00034 #include <Exception.hpp>
00035 
00036 using namespace mermaid::support::data;
00037 using mermaid::support::errorhandling::Exception;
00038 
00039 SemanticNode::SemanticNode()
00040 {
00041   name_ = "undefined";
00042 };
00043 
00044 SemanticNode::SemanticNode (std::string name)
00045 {
00046   name_ = name;
00047 };
00048 
00049 SemanticNodeVector SemanticNode::getChildren()
00050 {
00051   return children_;
00052 };
00053 
00054 void SemanticNode::addChild (shared_ptr<SemanticNode> child)
00055 {
00056   children_.push_back (child);
00057 };
00058 
00059 std::string SemanticNode::getName()
00060 {
00061   return name_;
00062 };
00063 
00064 shared_ptr<SemanticNode> SemanticNode::getChildWithName (std::string name)
00065 {
00066   SemanticNodeVector children = getChildren();
00067   
00068   SemanticNodeVector::iterator it;
00069   for (it = children.begin(); it != children.end(); it++) {
00070     shared_ptr<SemanticNode> child = *it;
00071     if (child->getName().compare (name) == 0) {
00072       return child;
00073     }
00074     else {
00075       shared_ptr<SemanticNode> tmp;
00076       tmp = child->getChildWithName (name);
00077       if (tmp) {
00078         return tmp;
00079       }
00080     }
00081   }
00082   
00083   return shared_ptr<SemanticNode>();
00084 };
Generated on Fri Mar 4 22:14:58 2011 for MeRMaID::support by  doxygen 1.6.3