AlgorithmEval.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2009 by Ulrich Friedrich Klank <klank@in.tum.de>
00003  *
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  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 
00019 #include "AlgorithmEval.h"
00020 #include "XMLTag.h"
00021 
00022 
00023 using namespace cop;
00024 
00025 
00026 template<typename T>
00027 AlgorithmEval<T>::AlgorithmEval(XMLTag* tag)
00028 {
00029     XMLTag* nodealgType = tag->GetChild(XML_NODE_ALGTYPE);
00030     if(nodealgType != NULL)
00031     {
00032         m_algorithmType = XMLTag::Load(nodealgType, &m_algorithmType);
00033         m_eval = XMLTag::Load(tag->GetChild(XML_NODE_EVAL), &m_eval);
00034         m_avgRunTime = XMLTag::Load(tag->GetChild(XML_NODE_AVGTIME), &m_avgRunTime);
00035         m_algorithm = XMLTag::Load(tag->GetChild(0), &m_algorithm);
00036     }
00037     else
00038     {
00039         printf("Deprecated XML entry\n");
00040         std::pair < Algorithm<std::vector<RelPose*> >*, std::pair<int, std::pair< double , double > > > loader;
00041         loader = XMLTag::Load(tag, &loader);
00042         m_algorithm = (Algorithm<T>*)loader.first;
00043         m_algorithmType = loader.second.first;
00044         m_eval = loader.second.second.first;
00045         m_avgRunTime = loader.second.second.second;
00046     }
00047 
00048     XMLTag* nodeMap = tag->GetChild(XML_NODE_OBJECTEVALMAP);
00049     if(nodeMap != NULL)
00050       m_objectEval = XMLTag::Load(nodeMap, &m_objectEval);
00051     if(m_algorithm == NULL)
00052     {
00053        if(tag != NULL && tag->GetChild(0) != NULL)
00054        {
00055          ROS_WARN("AlgorithmEval::AlgorithmEval XMLFile contains an unknown Algorithm: %s\n", tag->GetChild(0)->GetName().c_str());
00056        }
00057        else if(tag != NULL)
00058        {
00059          printf("Node: %s\n", tag->GetName().c_str());
00060        }
00061        throw "Algorithm not implemented";
00062     }
00063 }
00064 
00065 template<typename T>
00066 XMLTag* AlgorithmEval<T>::Save(std::string name)
00067 {
00068     XMLTag* tag = new XMLTag(name.compare("") == 0 ? XML_NODE_ALGORITHMEVAL : name);
00069     tag->AddChild(m_algorithm->Save());
00070     tag->AddChild(XMLTag::Tag(m_algorithmType, XML_NODE_ALGTYPE));
00071     tag->AddChild(XMLTag::Tag(m_eval, XML_NODE_EVAL));
00072     tag->AddChild(XMLTag::Tag(m_avgRunTime, XML_NODE_AVGTIME));
00073     tag->AddChild(XMLTag::Tag(m_objectEval, XML_NODE_OBJECTEVALMAP));
00074     return tag;
00075 }
00076 
00077 #ifndef WIN32
00078 template class AlgorithmEval<std::vector<Signature* > >;
00079 template class AlgorithmEval<std::vector<RelPose* > >;
00080 template class AlgorithmEval<Descriptor*>;
00081 template class AlgorithmEval<ImprovedPose>;
00082 template class AlgorithmEval<double>;
00083 #else
00084 template AlgorithmEval<std::vector<Signature* > >;
00085 template AlgorithmEval<std::vector<RelPose* > >;
00086 template AlgorithmEval<Descriptor*>;
00087 template AlgorithmEval<ImprovedPose>;
00088 template AlgorithmEval<double>;
00089 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


cognitive_perception
Author(s): Ulrich F Klank
autogenerated on Thu May 23 2013 07:38:34