iRoCS Toolbox  1.1.0
SVMError.hh
Go to the documentation of this file.
1 /**************************************************************************
2  *
3  * Copyright (C) 2004-2015 Olaf Ronneberger, Florian Pigorsch, Jörg Mechnich,
4  * Thorsten Falk
5  *
6  * Image Analysis Lab, University of Freiburg, Germany
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software Foundation,
20  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  **************************************************************************/
23 
24 /**************************************************************************
25 ** Title: simple exception class
26 ** $RCSfile$
27 ** $Revision: 2827 $$Name$
28 ** $Date: 2009-09-16 11:49:43 +0200 (Wed, 16 Sep 2009) $
29 ** Copyright: LGPL $Author: ronneber $
30 ** Description:
31 **
32 **
33 **
34 **-------------------------------------------------------------------------
35 **
36 ** $Log$
37 ** Revision 1.5 2007/01/10 09:50:27 fehr
38 ** cache size bug sixed
39 **
40 ** Revision 1.4 2006/10/06 13:50:05 fehr
41 ** linear model optimizer added
42 **
43 ** Revision 1.3 2004/09/13 10:04:04 ronneber
44 ** - documentation update
45 **
46 ** Revision 1.2 2004/09/01 14:43:36 ronneber
47 ** changed IterToPointerTraits stuff to
48 ** DirectAccessor and DereferencingAccessor, to make code more
49 ** intuitive understandable
50 **
51 ** Revision 1.1 2004/08/26 08:36:59 ronneber
52 ** initital import
53 **
54 ** Revision 1.3 2003/05/19 11:11:27 ronneber
55 ** - now inherits from std::exception
56 ** - therfore changed str() method to what()
57 **
58 ** Revision 1.2 2003/03/06 14:18:53 ronneber
59 ** - moved some local Error classes to this file
60 **
61 ** Revision 1.1 2002/09/04 10:27:24 pigorsch
62 ** - initial revision
63 **
64 **
65 **
66 **************************************************************************/
67 
68 #ifndef SVMERROR_HH
69 #define SVMERROR_HH
70 
71 #ifdef HAVE_CONFIG_H
72 #include <config.hh>
73 #endif
74 
75 // std includes
76 #include <iostream>
77 #include <sstream>
78 #include <string>
79 #include <exception>
80 
81 namespace svt
82 {
83  /*======================================================================*/
89  /*======================================================================*/
90  class SVMError : public std::exception
91  {
92  public:
94  {}
95 
96  SVMError(const SVMError& copy)
97  :std::exception( copy),
98  pMessage(copy.pMessage)
99 
100  {}
101 
102  virtual ~SVMError() throw()
103  {}
104 
105 
106 
107  template<typename T>
108  SVMError& operator<<(const T& data)
109  {
110  std::ostringstream oss;
111  oss << data;
112  pMessage+=oss.str();
113  return *this;
114  }
115 
116  virtual const char* what() const throw()
117  {
118  return pMessage.c_str();
119  }
120 
121  protected:
122  std::string pMessage;
123  };
124 
125 
126  /*-----------------------------------------------------------------------
127  * General Error Classes
128  *-----------------------------------------------------------------------*/
129  class WrongParameterError : public SVMError {};
130  class LoadError : public SVMError {};
131  class SaveError : public SVMError {};
132 
133  /*-----------------------------------------------------------------------
134  * Error classes for ParamMapWrapper
135  *-----------------------------------------------------------------------*/
136  class KeyNotFoundError : public SVMError {};
137  class InvalidDataTypeError : public SVMError {};
138  class ContainerTooSmallError : public SVMError {};
139  class NotEnoughValuesError : public SVMError {};
140 
141  /*-----------------------------------------------------------------------
142  * Error classes for SVMFactroy
143  *-----------------------------------------------------------------------*/
144  class UnknownClassNameError : public SVMError {};
145  class SVMRuntimeError: public SVMError {};
146 
147 
148  /*-----------------------------------------------------------------------
149  * Error classes for StData
150  *-----------------------------------------------------------------------*/
151  class ParseCmdLineError : public SVMError {};
152  class CmdLineError : public SVMError {};
153 
154  /*-----------------------------------------------------------------------
155  * Error classes for GridAxis
156  *-----------------------------------------------------------------------*/
157  class ParseError : public SVMError {};
158  class GridSearchError : public SVMError {};
159 
160  /*-----------------------------------------------------------------------
161  * Error classes for SparseFV
162  * --------------------------------------------------------------------*/
163  class SparseError : public SVMError {};
164 
165  /*-----------------------------------------------------------------------
166  * Assertions
167  *-----------------------------------------------------------------------*/
168  class SVMAssertionFailed: public SVMError {};
169 
170 
171  /*-----------------------------------------------------------------
172  * Cache to small Error
173  * --------------------------------------------------------------*/
174  class CacheToSmall : public SVMError {};
175 
176 #define SVM_ASSERT( condition) \
177 if (!(condition)) \
178 { \
179  svt::SVMAssertionFailed err; \
180  err << __FILE__ << ":" << __LINE__ << ": " "assertion '" \
181  << (#condition) << "' failed"; \
182  std::cerr << std::endl << err.what() << std::endl; \
183  throw( err); \
184 } \
185 
186 
187 
188 }
189 
190 #endif
virtual ~SVMError()
Definition: SVMError.hh:102
std::string pMessage
Definition: SVMError.hh:122
STL namespace.
virtual const char * what() const
Definition: SVMError.hh:116
The SVMError class is the parent class for all errors that are thrown by the LIBSVMTL.
Definition: SVMError.hh:90
SVMError & operator<<(const T &data)
Definition: SVMError.hh:108
SVMError(const SVMError &copy)
Definition: SVMError.hh:96