00001 // Copyright (C) 2013 Stephen Roderick <kiwi dot net at mac dot com> 00002 00003 // This library is free software; you can redistribute it and/or 00004 // modify it under the terms of the GNU Lesser General Public 00005 // License as published by the Free Software Foundation; either 00006 // version 2.1 of the License, or (at your option) any later version. 00007 00008 // This library 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 GNU 00011 // Lesser General Public License for more details. 00012 00013 // You should have received a copy of the GNU Lesser General Public 00014 // License along with this library; if not, write to the Free Software 00015 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00016 00017 #ifndef __SOLVERI_HPP 00018 #define __SOLVERI_HPP 00019 00020 namespace KDL { 00021 00084 class SolverI 00085 { 00086 public: 00087 enum { 00089 E_DEGRADED = +1, 00091 E_NOERROR = 0, 00093 E_NO_CONVERGE = -1, 00095 E_UNDEFINED = -2, 00097 E_SIZE_MISMATCH = -4, 00099 E_MAX_ITERATIONS_EXCEEDED = -5, 00101 E_OUT_OF_RANGE = -6, 00103 E_NOT_IMPLEMENTED = -7, 00105 E_SVD_FAILED = -8 00106 }; 00107 00109 SolverI() : 00110 error(E_NOERROR) 00111 {} 00112 00113 virtual ~SolverI() 00114 {} 00115 00117 virtual int getError() const { return error; } 00118 00123 virtual const char* strError(const int error) const 00124 { 00125 if (E_NOERROR == error) return "No error"; 00126 else if (E_NO_CONVERGE == error) return "Failed to converge"; 00127 else if (E_UNDEFINED == error) return "Undefined value"; 00128 else if (E_DEGRADED == error) return "Converged but degraded solution"; 00129 else if (E_SIZE_MISMATCH == error) return "The size of the input does not match the internal state"; 00130 else if (E_MAX_ITERATIONS_EXCEEDED == error) return "The maximum number of iterations is exceeded"; 00131 else if (E_OUT_OF_RANGE == error) return "The requested index is out of range"; 00132 else if (E_NOT_IMPLEMENTED == error) return "The requested function is not yet implemented"; 00133 else if (E_SVD_FAILED == error) return "SVD failed"; 00134 else return "UNKNOWN ERROR"; 00135 } 00136 00137 protected: 00139 int error; 00140 }; 00141 00142 } // namespaces 00143 00144 #endif