1 /*
2  *  This file is part of qpOASES.
3  *
4  *  qpOASES -- An Implementation of the Online Active Set Strategy.
5  *  Copyright (C) 2007-2015 by Hans Joachim Ferreau, Andreas Potschka,
6  *  Christian Kirches et al. All rights reserved.
7  *
8  *  qpOASES is free software; you can redistribute it and/or
9  *  modify it under the terms of the GNU Lesser General Public
10  *  License as published by the Free Software Foundation; either
11  *  version 2.1 of the License, or (at your option) any later version.
12  *
13  *  qpOASES 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.
16  *  See the GNU Lesser General Public License for more details.
17  *
18  *  You should have received a copy of the GNU Lesser General Public
19  *  License along with qpOASES; if not, write to the Free Software
20  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21  *
22  */
23 
24 
25 /**
26  *  \file include/qpOASES/MessageHandling.hpp
27  *  \author Hans Joachim Ferreau, Andreas Potschka, Christian Kirches (thanks to Leonard Wirsching)
28  *  \version 3.2
29  *  \date 2007-2015
30  *
31  *  Declaration of the MessageHandling class including global return values.
32  */
33 
34 
35 #ifndef QPOASES_MESSAGEHANDLING_HPP
36 #define QPOASES_MESSAGEHANDLING_HPP
37 
38 
39 #include <stdio.h>
40 #include <string.h>
41 
42 #ifdef __DEBUG__
43 #include <assert.h>
44 #endif
45 
46 #include <qpOASES/Constants.hpp>
47 
48 
49 BEGIN_NAMESPACE_QPOASES
50 
51 
52 /** Default file to display messages. */
53 extern FILE* stdFile;
54 
55 
56 /**
57  *  \brief Defines all symbols for global return values.
58  *
59  *  The enumeration returnValueType defines all symbols for global return values.
60  *  Important: All return values are assumed to be nonnegative!
61  *
62  *  \author Hans Joachim Ferreau
63  */
64 enum returnValue
65 {
66 TERMINAL_LIST_ELEMENT = -1,                     /**< Terminal list element, internal usage only! */
67 /* miscellaneous */
68 SUCCESSFUL_RETURN = 0,                          /**< Successful return. */
69 RET_DIV_BY_ZERO,                                /**< Division by zero. */
70 RET_INDEX_OUT_OF_BOUNDS,                        /**< Index out of bounds. */
71 RET_INVALID_ARGUMENTS,                          /**< At least one of the arguments is invalid. */
72 RET_ERROR_UNDEFINED,                            /**< Error number undefined. */
73 RET_WARNING_UNDEFINED,                          /**< Warning number undefined. */
74 RET_INFO_UNDEFINED,                             /**< Info number undefined. */
75 RET_EWI_UNDEFINED,                              /**< Error/warning/info number undefined. */
76 RET_AVAILABLE_WITH_LINUX_ONLY,                  /**< This function is available under Linux only. */
77 RET_UNKNOWN_BUG,                                /**< The error occurred is not yet known. */
78 RET_PRINTLEVEL_CHANGED,                         /**< Print level changed. (10) */
79 RET_NOT_YET_IMPLEMENTED,                        /**< Requested function is not yet implemented in this version of qpOASES. */
80 /* Indexlist */
81 RET_INDEXLIST_MUST_BE_REORDERD,                 /**< Index list has to be reordered. */
82 RET_INDEXLIST_EXCEEDS_MAX_LENGTH,               /**< Index list exceeds its maximal physical length. */
83 RET_INDEXLIST_CORRUPTED,                        /**< Index list corrupted. */
84 RET_INDEXLIST_OUTOFBOUNDS,                      /**< Physical index is out of bounds. */
85 RET_INDEXLIST_ADD_FAILED,                       /**< Adding indices from another index set failed. */
86 RET_INDEXLIST_INTERSECT_FAILED,                 /**< Intersection with another index set failed. */
87 /* SubjectTo / Bounds / Constraints */
88 RET_INDEX_ALREADY_OF_DESIRED_STATUS,            /**< Index is already of desired status. (18) */
89 RET_ADDINDEX_FAILED,                            /**< Adding index to index set failed. */
90 RET_REMOVEINDEX_FAILED,                         /**< Removing index from index set failed. (20) */
91 RET_SWAPINDEX_FAILED,                           /**< Cannot swap between different indexsets. */
92 RET_NOTHING_TO_DO,                              /**< Nothing to do. */
93 RET_SETUP_BOUND_FAILED,                         /**< Setting up bound index failed. */
94 RET_SETUP_CONSTRAINT_FAILED,                    /**< Setting up constraint index failed. */
95 RET_MOVING_BOUND_FAILED,                        /**< Moving bound between index sets failed. */
96 RET_MOVING_CONSTRAINT_FAILED,                   /**< Moving constraint between index sets failed. */
97 RET_SHIFTING_FAILED,                            /**< Shifting of bounds/constraints failed. */
98 RET_ROTATING_FAILED,                            /**< Rotating of bounds/constraints failed. */
99 /* QProblem */
100 RET_QPOBJECT_NOT_SETUP,                         /**< The QP object has not been setup correctly, use another constructor. */
101 RET_QP_ALREADY_INITIALISED,                     /**< QProblem has already been initialised. (30) */
102 RET_NO_INIT_WITH_STANDARD_SOLVER,               /**< Initialisation via extern QP solver is not yet implemented. */
103 RET_RESET_FAILED,                               /**< Reset failed. */
104 RET_INIT_FAILED,                                /**< Initialisation failed. */
105 RET_INIT_FAILED_TQ,                             /**< Initialisation failed due to TQ factorisation. */
106 RET_INIT_FAILED_CHOLESKY,                       /**< Initialisation failed due to Cholesky decomposition. */
107 RET_INIT_FAILED_HOTSTART,                       /**< Initialisation failed! QP could not be solved! */
108 RET_INIT_FAILED_INFEASIBILITY,                  /**< Initial QP could not be solved due to infeasibility! */
109 RET_INIT_FAILED_UNBOUNDEDNESS,                  /**< Initial QP could not be solved due to unboundedness! */
110 RET_INIT_FAILED_REGULARISATION,                 /**< Initialisation failed as Hessian matrix could not be regularised. */
111 RET_INIT_SUCCESSFUL,                            /**< Initialisation done. (40) */
112 RET_OBTAINING_WORKINGSET_FAILED,                /**< Failed to obtain working set for auxiliary QP. */
113 RET_SETUP_WORKINGSET_FAILED,                    /**< Failed to setup working set for auxiliary QP. */
114 RET_SETUP_AUXILIARYQP_FAILED,                   /**< Failed to setup auxiliary QP for initialised homotopy. */
115 RET_NO_CHOLESKY_WITH_INITIAL_GUESS,             /**< Externally computed Cholesky factor cannot be combined with an initial guess. */
116 RET_NO_EXTERN_SOLVER,                           /**< No extern QP solver available. */
117 RET_QP_UNBOUNDED,                               /**< QP is unbounded. */
118 RET_QP_INFEASIBLE,                              /**< QP is infeasible. */
119 RET_QP_NOT_SOLVED,                              /**< Problems occurred while solving QP with standard solver. */
120 RET_QP_SOLVED,                                  /**< QP successfully solved. */
121 RET_UNABLE_TO_SOLVE_QP,                         /**< Problems occurred while solving QP. (50) */
122 RET_INITIALISATION_STARTED,                     /**< Starting problem initialisation... */
123 RET_HOTSTART_FAILED,                            /**< Unable to perform homotopy due to internal error. */
124 RET_HOTSTART_FAILED_TO_INIT,                    /**< Unable to initialise problem. */
125 RET_HOTSTART_FAILED_AS_QP_NOT_INITIALISED,      /**< Unable to perform homotopy as previous QP is not solved. */
126 RET_ITERATION_STARTED,                          /**< Iteration... */
127 RET_SHIFT_DETERMINATION_FAILED,                 /**< Determination of shift of the QP data failed. */
128 RET_STEPDIRECTION_DETERMINATION_FAILED,         /**< Determination of step direction failed. */
129 RET_STEPLENGTH_DETERMINATION_FAILED,            /**< Determination of step direction failed. */
130 RET_OPTIMAL_SOLUTION_FOUND,                     /**< Optimal solution of neighbouring QP found. */
131 RET_HOMOTOPY_STEP_FAILED,                       /**< Unable to perform homotopy step. (60) */
132 RET_HOTSTART_STOPPED_INFEASIBILITY,             /**< Premature homotopy termination because QP is infeasible. */
133 RET_HOTSTART_STOPPED_UNBOUNDEDNESS,             /**< Premature homotopy termination because QP is unbounded. */
134 RET_WORKINGSET_UPDATE_FAILED,                   /**< Unable to update working sets according to initial guesses. */
135 RET_MAX_NWSR_REACHED,                           /**< Maximum number of working set recalculations performed. */
136 RET_CONSTRAINTS_NOT_SPECIFIED,                  /**< Problem does comprise constraints! You also have to specify new constraints' bounds. */
137 RET_INVALID_FACTORISATION_FLAG,                 /**< Invalid factorisation flag. */
138 RET_UNABLE_TO_SAVE_QPDATA,                      /**< Unable to save QP data. */
139 RET_STEPDIRECTION_FAILED_TQ,                    /**< Abnormal termination due to TQ factorisation. */
140 RET_STEPDIRECTION_FAILED_CHOLESKY,              /**< Abnormal termination due to Cholesky factorisation. */
141 RET_CYCLING_DETECTED,                           /**< Cycling detected. (70) */
142 RET_CYCLING_NOT_RESOLVED,                       /**< Cycling cannot be resolved, QP probably infeasible. */
143 RET_CYCLING_RESOLVED,                           /**< Cycling probably resolved. */
144 RET_STEPSIZE,                                   /**< For displaying performed stepsize. */
145 RET_STEPSIZE_NONPOSITIVE,                       /**< For displaying non-positive stepsize. */
146 RET_SETUPSUBJECTTOTYPE_FAILED,                  /**< Setup of SubjectToTypes failed. */
147 RET_ADDCONSTRAINT_FAILED,                       /**< Addition of constraint to working set failed. */
148 RET_ADDCONSTRAINT_FAILED_INFEASIBILITY,         /**< Addition of constraint to working set failed (due to QP infeasibility). */
149 RET_ADDBOUND_FAILED,                            /**< Addition of bound to working set failed. */
150 RET_ADDBOUND_FAILED_INFEASIBILITY,              /**< Addition of bound to working set failed (due to QP infeasibility). */
151 RET_REMOVECONSTRAINT_FAILED,                    /**< Removal of constraint from working set failed. (80) */
152 RET_REMOVEBOUND_FAILED,                         /**< Removal of bound from working set failed. */
153 RET_REMOVE_FROM_ACTIVESET,                      /**< Removing from active set... */
154 RET_ADD_TO_ACTIVESET,                           /**< Adding to active set... */
155 RET_REMOVE_FROM_ACTIVESET_FAILED,               /**< Removing from active set failed. */
156 RET_ADD_TO_ACTIVESET_FAILED,                    /**< Adding to active set failed. */
157 RET_CONSTRAINT_ALREADY_ACTIVE,                  /**< Constraint is already active. */
158 RET_ALL_CONSTRAINTS_ACTIVE,                     /**< All constraints are active, no further constraint can be added. */
159 RET_LINEARLY_DEPENDENT,                         /**< New bound/constraint is linearly dependent. */
160 RET_LINEARLY_INDEPENDENT,                       /**< New bound/constraint is linearly independent. */
161 RET_LI_RESOLVED,                                /**< Linear independence of active constraint matrix successfully resolved. (90) */
162 RET_ENSURELI_FAILED,                            /**< Failed to ensure linear independence of active constraint matrix. */
163 RET_ENSURELI_FAILED_TQ,                         /**< Abnormal termination due to TQ factorisation. */
164 RET_ENSURELI_FAILED_NOINDEX,                    /**< QP is infeasible. */
165 RET_ENSURELI_FAILED_CYCLING,                    /**< QP is infeasible. */
166 RET_BOUND_ALREADY_ACTIVE,                       /**< Bound is already active. */
167 RET_ALL_BOUNDS_ACTIVE,                          /**< All bounds are active, no further bound can be added. */
168 RET_CONSTRAINT_NOT_ACTIVE,                      /**< Constraint is not active. */
169 RET_BOUND_NOT_ACTIVE,                           /**< Bound is not active. */
170 RET_HESSIAN_NOT_SPD,                            /**< Projected Hessian matrix not positive definite. */
171 RET_HESSIAN_INDEFINITE,                         /**< Hessian matrix is indefinite. (100) */
172 RET_MATRIX_SHIFT_FAILED,                        /**< Unable to update matrices or to transform vectors. */
173 RET_MATRIX_FACTORISATION_FAILED,                /**< Unable to calculate new matrix factorisations. */
174 RET_PRINT_ITERATION_FAILED,                     /**< Unable to print information on current iteration. */
175 RET_NO_GLOBAL_MESSAGE_OUTPUTFILE,               /**< No global message output file initialised. */
176 RET_DISABLECONSTRAINTS_FAILED,                  /**< Unable to disbable constraints. */
177 RET_ENABLECONSTRAINTS_FAILED,                   /**< Unable to enbable constraints. */
178 RET_ALREADY_ENABLED,                            /**< Bound or constraint is already enabled. */
179 RET_ALREADY_DISABLED,                           /**< Bound or constraint is already disabled. */
180 RET_NO_HESSIAN_SPECIFIED,                       /**< No Hessian matrix has been specified. */
181 RET_USING_REGULARISATION,                       /**< Using regularisation as Hessian matrix is not positive definite. (110) */
182 RET_EPS_MUST_BE_POSITVE,                        /**< Eps for regularisation must be sufficiently positive. */
183 RET_REGSTEPS_MUST_BE_POSITVE,                   /**< Maximum number of regularisation steps must be non-negative. */
184 RET_HESSIAN_ALREADY_REGULARISED,                /**< Hessian has been already regularised. */
185 RET_CANNOT_REGULARISE_IDENTITY,                 /**< Identity Hessian matrix cannot be regularised. */
186 RET_CANNOT_REGULARISE_SPARSE,                   /**< Sparse matrix cannot be regularised as diagonal entry is missing. */
187 RET_NO_REGSTEP_NWSR,                            /**< No additional regularisation step could be performed due to limits. */
188 RET_FEWER_REGSTEPS_NWSR,                        /**< Fewer additional regularisation steps have been performed due to limits. */
189 RET_CHOLESKY_OF_ZERO_HESSIAN,                   /**< Cholesky decomposition of (unregularised) zero Hessian matrix. */
190 RET_ZERO_HESSIAN_ASSUMED,                       /**< Zero Hessian matrix assumed as null pointer passed without specifying hessianType. */
191 RET_CONSTRAINTS_ARE_NOT_SCALED,                 /**< (no longer in use) (120) */
192 RET_INITIAL_BOUNDS_STATUS_NYI,                  /**< (no longer in use) */
193 RET_ERROR_IN_CONSTRAINTPRODUCT,                 /**< Error in user-defined constraint product function. */
194 RET_FIX_BOUNDS_FOR_LP,                          /**< All initial bounds must be fixed when solving an (unregularised) LP. */
195 RET_USE_REGULARISATION_FOR_LP,                  /**< Set options.enableRegularisation=BT_TRUE for solving LPs. */
196 /* SQProblem */
197 RET_UPDATEMATRICES_FAILED,                      /**< Unable to update QP matrices. */
198 RET_UPDATEMATRICES_FAILED_AS_QP_NOT_SOLVED,     /**< Unable to update matrices as previous QP is not solved. */
199 /* Utils */
200 RET_UNABLE_TO_OPEN_FILE,                        /**< Unable to open file. */
201 RET_UNABLE_TO_WRITE_FILE,                       /**< Unable to write into file. */
202 RET_UNABLE_TO_READ_FILE,                        /**< Unable to read from file. */
203 RET_FILEDATA_INCONSISTENT,                      /**< File contains inconsistent data. (130) */
204 /* Options */
205 RET_OPTIONS_ADJUSTED,                           /**< Options needed to be adjusted for consistency reasons. */
206 /* SolutionAnalysis */
207 RET_UNABLE_TO_ANALYSE_QPROBLEM,                 /**< Unable to analyse (S)QProblem(B) object. */
208 /* Benchmark */
209 RET_NWSR_SET_TO_ONE,                            /**< Maximum number of working set changes was set to 1. */
210 RET_UNABLE_TO_READ_BENCHMARK,                   /**< Unable to read benchmark data. */
211 RET_BENCHMARK_ABORTED,                          /**< Benchmark aborted. */
212 RET_INITIAL_QP_SOLVED,                          /**< Initial QP solved. */
213 RET_QP_SOLUTION_STARTED,                        /**< Solving QP... */
214 RET_BENCHMARK_SUCCESSFUL,                       /**< Benchmark terminated successfully. */
215 /* Sparse matrices */
216 RET_NO_DIAGONAL_AVAILABLE,                      /**< Sparse matrix does not have entries on full diagonal. */
217 RET_DIAGONAL_NOT_INITIALISED,                   /**< Diagonal data of sparse matrix has not been initialised. (140) */
218 /* Dropping of infeasible constraints */
219 RET_ENSURELI_DROPPED,                           /**< Linear independence resolved by dropping blocking constraint. */
220 /* Schur complement computations */
221 RET_KKT_MATRIX_SINGULAR,                        /**< KKT matrix is singular. */
222 RET_QR_FACTORISATION_FAILED,                    /**< QR factorization of Schur complement failed. */
223 RET_INERTIA_CORRECTION_FAILED,                  /**< Inertia correction failed after KKT matrix had too many negative eigenvalues. */
224 RET_NO_SPARSE_SOLVER,                           /**< No factorization routine for the KKT matrix installed. */
225 /* Simple exitflags */
226 RET_SIMPLE_STATUS_P1,                           /**< QP problem could not be solved within given number of iterations. */
227 RET_SIMPLE_STATUS_P0,                           /**< QP problem solved. */
228 RET_SIMPLE_STATUS_M1,                           /**< QP problem could not be solved due to an internal error. */
229 RET_SIMPLE_STATUS_M2,                           /**< QP problem is infeasible (and thus could not be solved). */
230 RET_SIMPLE_STATUS_M3                            /**< QP problem is unbounded (and thus could not be solved). (150) */
231 };
232 
233 
234 /**
235  *  \brief Handles all kind of error messages, warnings and other information.
236  *
237  *  This class handles all kinds of messages (errors, warnings, infos) initiated
238  *  by qpOASES modules and stores the corresponding global preferences.
239  *
240  *  \author Hans Joachim Ferreau (thanks to Leonard Wirsching)
241  *  \version 3.2
242  *  \date 2007-2015
243  */
244 class MessageHandling
245 {
246     /*
247      *  INTERNAL DATA STRUCTURES
248      */
249     public:
250         /**
251         *   \brief Data structure for entries in global message list.
252         *
253         *   Data structure for entries in global message list.
254         *
255         *   \author Hans Joachim Ferreau
256         */
257         typedef struct {
258             returnValue key;                            /**< Global return value. */
259             const char* data;                           /**< Corresponding message. */
260             VisibilityStatus globalVisibilityStatus;    /**< Determines if message can be printed.
261                                                         *    If this value is set to VS_HIDDEN, no message is printed! */
262         } ReturnValueList;
263 
264 
265     /*
266      *  PUBLIC MEMBER FUNCTIONS
267      */
268     public:
269         /** Default constructor. */
270         MessageHandling( );
271 
272         /** Constructor which takes the desired output file. */
273         MessageHandling(  FILE* _outputFile                     /**< Output file. */
274                           );
275 
276         /** Constructor which takes the desired visibility states. */
277         MessageHandling(    VisibilityStatus _errorVisibility,  /**< Visibility status for error messages. */
278                             VisibilityStatus _warningVisibility,/**< Visibility status for warning messages. */
279                             VisibilityStatus _infoVisibility    /**< Visibility status for info messages. */
280                             );
281 
282         /** Constructor which takes the desired output file and desired visibility states. */
283         MessageHandling(    FILE* _outputFile,                  /**< Output file. */
284                             VisibilityStatus _errorVisibility,  /**< Visibility status for error messages. */
285                             VisibilityStatus _warningVisibility,/**< Visibility status for warning messages. */
286                             VisibilityStatus _infoVisibility    /**< Visibility status for info messages. */
287                             );
288 
289         /** Copy constructor (deep copy). */
290         MessageHandling(    const MessageHandling& rhs  /**< Rhs object. */
291                             );
292 
293         /** Destructor. */
294         ~MessageHandling( );
295 
296         /** Assignment operator (deep copy). */
297         MessageHandling& operator=( const MessageHandling& rhs  /**< Rhs object. */
298                                     );
299 
300 
301         /** Prints an error message(a simplified macro THROWERROR is also provided). \n
302          *  Errors are defined as abnormal events which cause an immediate termination of the current (sub) function.
303          *  Errors of a sub function should be commented by the calling function by means of a warning message
304          *  (if this error does not cause an error of the calling function, either)!
305          *  \return Error number returned by sub function call
306          */
307         returnValue throwError( returnValue Enumber,                    /**< Error number returned by sub function call. */
308                                 const char* additionaltext,             /**< Additional error text (0, if none). */
309                                 const char* functionname,               /**< Name of function which caused the error. */
310                                 const char* filename,                   /**< Name of file which caused the error. */
311                                 const unsigned long linenumber,         /**< Number of line which caused the error.incompatible binary file */
312                                 VisibilityStatus localVisibilityStatus  /**< Determines (locally) if error message can be printed to stdFile.
313                                                                     *   If GLOBAL visibility status of the message is set to VS_HIDDEN,
314                                                                     *   no message is printed, anyway! */
315                                 );
316 
317         /** Prints a warning message (a simplified macro THROWWARNING is also provided).
318          *  Warnings are definied as abnormal events which does NOT cause an immediate termination of the current (sub) function.
319          *  \return Warning number returned by sub function call
320          */
321         returnValue throwWarning(   returnValue Wnumber,                    /**< Warning number returned by sub function call. */
322                                     const char* additionaltext,             /**< Additional warning text (0, if none). */
323                                     const char* functionname,               /**< Name of function which caused the warning. */
324                                     const char* filename,                   /**< Name of file which caused the warning. */
325                                     const unsigned long linenumber,         /**< Number of line which caused the warning. */
326                                     VisibilityStatus localVisibilityStatus  /**< Determines (locally) if warning message can be printed to stdFile.
327                                                                             *   If GLOBAL visibility status of the message is set to VS_HIDDEN,
328                                                                             *   no message is printed, anyway! */
329                                     );
330 
331        /** Prints a info message (a simplified macro THROWINFO is also provided).
332          *  \return Info number returned by sub function call
333          */
334         returnValue throwInfo(  returnValue Inumber,                    /**< Info number returned by sub function call. */
335                                 const char* additionaltext,             /**< Additional warning text (0, if none). */
336                                 const char* functionname,               /**< Name of function which submitted the info. */
337                                 const char* filename,                   /**< Name of file which submitted the info. */
338                                 const unsigned long linenumber,         /**< Number of line which submitted the info. */
339                                 VisibilityStatus localVisibilityStatus  /**< Determines (locally) if info message can be printed to stdFile.
340                                                                         *   If GLOBAL visibility status of the message is set to VS_HIDDEN,
341                                                                         *   no message is printed, anyway! */
342                                 );
343 
344 
345         /** Resets all preferences to default values.
346          *  \return SUCCESSFUL_RETURN */
347         returnValue reset( );
348 
349 
350         /** Prints a complete list of all messages to output file.
351          *  \return SUCCESSFUL_RETURN */
352         returnValue listAllMessages( );
353 
354 
355         /** Returns visibility status for error messages.
356          *  \return Visibility status for error messages. */
357         inline VisibilityStatus getErrorVisibilityStatus( ) const;
358 
359         /** Returns visibility status for warning messages.
360          *  \return Visibility status for warning messages. */
361         inline VisibilityStatus getWarningVisibilityStatus( ) const;
362 
363         /** Returns visibility status for info messages.
364          *  \return Visibility status for info messages. */
365         inline VisibilityStatus getInfoVisibilityStatus( ) const;
366 
367         /** Returns pointer to output file.
368          *  \return Pointer to output file. */
369         inline FILE* getOutputFile( ) const;
370 
371         /** Returns error count value.
372          *  \return Error count value. */
373         inline int_t getErrorCount( ) const;
374 
375 
376         /** Changes visibility status for error messages. */
377         inline void setErrorVisibilityStatus(   VisibilityStatus _errorVisibility   /**< New visibility status for error messages. */
378                                                 );
379 
380         /** Changes visibility status for warning messages. */
381         inline void setWarningVisibilityStatus( VisibilityStatus _warningVisibility /**< New visibility status for warning messages. */
382                                                 );
383 
384         /** Changes visibility status for info messages. */
385         inline void setInfoVisibilityStatus(    VisibilityStatus _infoVisibility    /**< New visibility status for info messages. */
386                                                 );
387 
388         /** Changes output file for messages. */
389         inline void setOutputFile(  FILE* _outputFile   /**< New output file for messages. */
390                                     );
391 
392         /** Changes error count.
393          * \return SUCCESSFUL_RETURN \n
394          *         RET_INVALID_ARGUMENT */
395         inline returnValue setErrorCount(   int_t _errorCount   /**< New error count value. */
396                                             );
397 
398         /** Provides message text corresponding to given \a returnValue.
399          * \return String containing message text. */
400         static const char* getErrorCodeMessage( const returnValue _returnValue
401                                                 );
402 
403 
404     /*
405      *  PROTECTED MEMBER FUNCTIONS
406      */
407     protected:
408         /** Prints a info message to stdFile (auxiliary function).
409          *  \return Error/warning/info number returned by sub function call
410          */
411         returnValue throwMessage(
412             returnValue RETnumber,                  /**< Error/warning/info number returned by sub function call. */
413             const char* additionaltext,             /**< Additional warning text (0, if none). */
414             const char* functionname,               /**< Name of function which caused the error/warning/info. */
415             const char* filename,                   /**< Name of file which caused the error/warning/info. */
416             const unsigned long linenumber,         /**< Number of line which caused the error/warning/info. */
417             VisibilityStatus localVisibilityStatus, /**< Determines (locally) if info message can be printed to stdFile.
418                                                      *   If GLOBAL visibility status of the message is set to VS_HIDDEN,
419                                                      *   no message is printed, anyway! */
420             const char* RETstring                   /**< Leading string of error/warning/info message. */
421             );
422 
423 
424     /*
425      *  PROTECTED MEMBER VARIABLES
426      */
427     protected:
428         VisibilityStatus errorVisibility;       /**< Error messages visible? */
429         VisibilityStatus warningVisibility;     /**< Warning messages visible? */
430         VisibilityStatus infoVisibility;        /**< Info messages visible? */
431 
432         FILE* outputFile;                       /**< Output file for messages. */
433 
434         int_t errorCount;                       /**< Counts number of errors (for nicer output only). */
435 };
436 
437 
438 #ifndef __FILE__
439   /** Ensures that __FILE__ macro is defined. */
440   #define __FILE__ 0
441 #endif
442 
443 #ifndef __LINE__
444   /** Ensures that __LINE__ macro is defined. */
445   #define __LINE__ 0
446 #endif
447 
448 /** Define __FUNC__ macro providing current function for debugging. */
449 /*#define __FUNC__ 0*/
450 #define __FUNC__ ("(no function name provided)")
451 /*#define __FUNC__ __func__*/
452 /*#define __FUNC__ __FUNCTION__*/
453 
454 
455 /** Short version of throwError with default values, only returnValue is needed */
456 #define THROWERROR(retval) ( getGlobalMessageHandler( )->throwError((retval),0,__FUNC__,__FILE__,__LINE__,VS_VISIBLE) )
457 
458 /** Short version of throwWarning with default values, only returnValue is needed */
459 #define THROWWARNING(retval) ( getGlobalMessageHandler( )->throwWarning((retval),0,__FUNC__,__FILE__,__LINE__,VS_VISIBLE) )
460 
461 /** Short version of throwInfo with default values, only returnValue is needed */
462 #define THROWINFO(retval) ( getGlobalMessageHandler( )->throwInfo((retval),0,__FUNC__,__FILE__,__LINE__,VS_VISIBLE) )
463 
464 
465 /** Returns a pointer to global message handler.
466  *  \return Pointer to global message handler.
467  */
468 MessageHandling* getGlobalMessageHandler( );
469 
470 
471 END_NAMESPACE_QPOASES
472 
473 #include <qpOASES/MessageHandling.ipp>
474 
475 #endif /* QPOASES_MESSAGEHANDLING_HPP */
476 
477 
478 /*
479  *  end of file
480  */
481