Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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