]> ruin.nu Git - germs.git/blob - fann/src/include/fann_error.h
Make it possible to build statically against the included fann library.
[germs.git] / fann / src / include / fann_error.h
1 /*
2 Fast Artificial Neural Network Library (fann)
3 Copyright (C) 2003 Steffen Nissen (lukesky@diku.dk)
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 */
19
20 #ifndef __fann_error_h__
21 #define __fann_error_h__
22
23 #include <stdio.h>
24
25 #define FANN_ERRSTR_MAX 128
26 struct fann_error;
27
28 /* Section: FANN Error Handling
29
30    Errors from the fann library are usually reported on stderr. 
31    It is however possible to redirect these error messages to a file, 
32    or completely ignore them by the <fann_set_error_log> function.
33    
34    It is also possible to inspect the last error message by using the
35    <fann_get_errno> and <fann_get_errstr> functions.
36  */
37
38 /* Enum: fann_errno_enum
39         Used to define error events on <struct fann> and <struct fann_train_data>. 
40
41         See also:
42                 <fann_get_errno>, <fann_reset_errno>, <fann_get_errstr>
43
44         FANN_E_NO_ERROR - No error 
45         FANN_E_CANT_OPEN_CONFIG_R - Unable to open configuration file for reading 
46         FANN_E_CANT_OPEN_CONFIG_W - Unable to open configuration file for writing
47         FANN_E_WRONG_CONFIG_VERSION - Wrong version of configuration file 
48         FANN_E_CANT_READ_CONFIG - Error reading info from configuration file
49         FANN_E_CANT_READ_NEURON - Error reading neuron info from configuration file
50         FANN_E_CANT_READ_CONNECTIONS - Error reading connections from configuration file
51         FANN_E_WRONG_NUM_CONNECTIONS - Number of connections not equal to the number expected
52         FANN_E_CANT_OPEN_TD_W - Unable to open train data file for writing
53         FANN_E_CANT_OPEN_TD_R - Unable to open train data file for reading
54         FANN_E_CANT_READ_TD - Error reading training data from file
55         FANN_E_CANT_ALLOCATE_MEM - Unable to allocate memory
56         FANN_E_CANT_TRAIN_ACTIVATION - Unable to train with the selected activation function
57         FANN_E_CANT_USE_ACTIVATION - Unable to use the selected activation function
58         FANN_E_TRAIN_DATA_MISMATCH - Irreconcilable differences between two <struct fann_train_data> structures
59         FANN_E_CANT_USE_TRAIN_ALG - Unable to use the selected training algorithm
60         FANN_E_TRAIN_DATA_SUBSET - Trying to take subset which is not within the training set
61         FANN_E_INDEX_OUT_OF_BOUND - Index is out of bound
62 */
63 enum fann_errno_enum
64 {
65         FANN_E_NO_ERROR = 0,
66         FANN_E_CANT_OPEN_CONFIG_R,
67         FANN_E_CANT_OPEN_CONFIG_W,
68         FANN_E_WRONG_CONFIG_VERSION,
69         FANN_E_CANT_READ_CONFIG,
70         FANN_E_CANT_READ_NEURON,
71         FANN_E_CANT_READ_CONNECTIONS,
72         FANN_E_WRONG_NUM_CONNECTIONS,
73         FANN_E_CANT_OPEN_TD_W,
74         FANN_E_CANT_OPEN_TD_R,
75         FANN_E_CANT_READ_TD,
76         FANN_E_CANT_ALLOCATE_MEM,
77         FANN_E_CANT_TRAIN_ACTIVATION,
78         FANN_E_CANT_USE_ACTIVATION,
79         FANN_E_TRAIN_DATA_MISMATCH,
80         FANN_E_CANT_USE_TRAIN_ALG,
81         FANN_E_TRAIN_DATA_SUBSET,
82         FANN_E_INDEX_OUT_OF_BOUND
83 };
84
85 /* Group: Error Handling */
86         
87 /* Function: fann_set_error_log
88
89    Change where errors are logged to. Both <struct fann> and <struct fann_data> can be 
90    casted to <struct fann_error>, so this function can be used to set either of these.
91    
92    If log_file is NULL, no errors will be printed.
93    
94    If errdata is NULL, the default log will be set. The default log is the log used when creating 
95    <struct fann> and <struct fann_data>. This default log will also be the default for all new structs
96    that are created.
97    
98    The default behavior is to log them to stderr.
99    
100    See also:
101     <struct fann_error>
102    
103    This function appears in FANN >= 1.1.0.   
104  */ 
105 FANN_EXTERNAL void FANN_API fann_set_error_log(struct fann_error *errdat, FILE * log_file);
106
107
108 /* Function: fann_get_errno
109
110    Returns the last error number.
111    
112    See also:
113     <fann_errno_enum>, <fann_reset_errno>
114     
115    This function appears in FANN >= 1.1.0.   
116  */ 
117 FANN_EXTERNAL enum fann_errno_enum FANN_API fann_get_errno(struct fann_error *errdat);
118
119
120 /* Function: fann_reset_errno
121
122    Resets the last error number.
123    
124    This function appears in FANN >= 1.1.0.   
125  */ 
126 FANN_EXTERNAL void FANN_API fann_reset_errno(struct fann_error *errdat);
127
128
129 /* Function: fann_reset_errstr
130
131    Resets the last error string.
132
133    This function appears in FANN >= 1.1.0.   
134  */ 
135 FANN_EXTERNAL void FANN_API fann_reset_errstr(struct fann_error *errdat);
136
137
138 /* Function: fann_get_errstr
139
140    Returns the last errstr.
141   
142    This function calls <fann_reset_errno> and <fann_reset_errstr>
143
144    This function appears in FANN >= 1.1.0.   
145  */ 
146 FANN_EXTERNAL char *FANN_API fann_get_errstr(struct fann_error *errdat);
147
148
149 /* Function: fann_print_error
150
151    Prints the last error to stderr.
152
153    This function appears in FANN >= 1.1.0.   
154  */ 
155 FANN_EXTERNAL void FANN_API fann_print_error(struct fann_error *errdat);
156
157 extern FILE * fann_default_error_log;
158
159 #endif