MessageHandling.hpp
Go to the documentation of this file.
00001 /*
00002  *      This file is part of qpOASES.
00003  *
00004  *      qpOASES -- An Implementation of the Online Active Set Strategy.
00005  *      Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved.
00006  *
00007  *      qpOASES is free software; you can redistribute it and/or
00008  *      modify it under the terms of the GNU Lesser General Public
00009  *      License as published by the Free Software Foundation; either
00010  *      version 2.1 of the License, or (at your option) any later version.
00011  *
00012  *      qpOASES is distributed in the hope that it will be useful,
00013  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  *      Lesser General Public License for more details.
00016  *
00017  *      You should have received a copy of the GNU Lesser General Public
00018  *      License along with qpOASES; if not, write to the Free Software
00019  *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020  *
00021  */
00022 
00023 
00034 #ifndef QPOASES_MESSAGEHANDLING_HPP
00035 #define QPOASES_MESSAGEHANDLING_HPP
00036 
00037 // #define PC_DEBUG
00038 
00039 #ifdef PC_DEBUG
00040   #include <stdio.h>
00041 
00043   #define myFILE FILE
00044 
00045   #define myStderr stderr
00046 
00047   #define myStdout stdout
00048 #else
00049 
00050   #define myFILE int
00051 
00052   #define myStderr 0
00053 
00054   #define myStdout 0
00055 #endif
00056 
00057 
00058 #include <Types.hpp>
00059 #include <Constants.hpp>
00060 
00061 
00064 enum returnValue
00065 {
00066 TERMINAL_LIST_ELEMENT = -1,                                             
00067 /* miscellaneous */
00068 SUCCESSFUL_RETURN = 0,                                                  
00069 RET_DIV_BY_ZERO,                                                                
00070 RET_INDEX_OUT_OF_BOUNDS,                                                
00071 RET_INVALID_ARGUMENTS,                                                  
00072 RET_ERROR_UNDEFINED,                                                    
00073 RET_WARNING_UNDEFINED,                                                  
00074 RET_INFO_UNDEFINED,                                                             
00075 RET_EWI_UNDEFINED,                                                              
00076 RET_AVAILABLE_WITH_LINUX_ONLY,                                  
00077 RET_UNKNOWN_BUG,                                                                
00078 RET_PRINTLEVEL_CHANGED,                                                 
00079 RET_NOT_YET_IMPLEMENTED,                                                
00080 /* Indexlist */
00081 RET_INDEXLIST_MUST_BE_REORDERD,                                 
00082 RET_INDEXLIST_EXCEEDS_MAX_LENGTH,                               
00083 RET_INDEXLIST_CORRUPTED,                                                
00084 RET_INDEXLIST_OUTOFBOUNDS,                                              
00085 RET_INDEXLIST_ADD_FAILED,                                               
00086 RET_INDEXLIST_INTERSECT_FAILED,                                 
00087 /* SubjectTo / Bounds / Constraints */
00088 RET_INDEX_ALREADY_OF_DESIRED_STATUS,                    
00089 RET_ADDINDEX_FAILED,                                                    
00090 RET_SWAPINDEX_FAILED,                                                   
00091 RET_NOTHING_TO_DO,                                                              
00092 RET_SETUP_BOUND_FAILED,                                                 
00093 RET_SETUP_CONSTRAINT_FAILED,                                    
00094 RET_MOVING_BOUND_FAILED,                                                
00095 RET_MOVING_CONSTRAINT_FAILED,                                   
00096 /* QProblem */
00097 RET_QP_ALREADY_INITIALISED,                                             
00098 RET_NO_INIT_WITH_STANDARD_SOLVER,                               
00099 RET_RESET_FAILED,                                                               
00100 RET_INIT_FAILED,                                                                
00101 RET_INIT_FAILED_TQ,                                                             
00102 RET_INIT_FAILED_CHOLESKY,                                               
00103 RET_INIT_FAILED_HOTSTART,                                               
00104 RET_INIT_FAILED_INFEASIBILITY,                                  
00105 RET_INIT_FAILED_UNBOUNDEDNESS,                                  
00106 RET_INIT_SUCCESSFUL,                                                    
00107 RET_OBTAINING_WORKINGSET_FAILED,                                
00108 RET_SETUP_WORKINGSET_FAILED,                                    
00109 RET_SETUP_AUXILIARYQP_FAILED,                                   
00110 RET_NO_EXTERN_SOLVER,                                                   
00111 RET_QP_UNBOUNDED,                                                               
00112 RET_QP_INFEASIBLE,                                                              
00113 RET_QP_NOT_SOLVED,                                                              
00114 RET_QP_SOLVED,                                                                  
00115 RET_UNABLE_TO_SOLVE_QP,                                                 
00116 RET_INITIALISATION_STARTED,                                             
00117 RET_HOTSTART_FAILED,                                                    
00118 RET_HOTSTART_FAILED_TO_INIT,                                    
00119 RET_HOTSTART_FAILED_AS_QP_NOT_INITIALISED,              
00120 RET_ITERATION_STARTED,                                                  
00121 RET_SHIFT_DETERMINATION_FAILED,                                 
00122 RET_STEPDIRECTION_DETERMINATION_FAILED,                 
00123 RET_STEPLENGTH_DETERMINATION_FAILED,                    
00124 RET_OPTIMAL_SOLUTION_FOUND,                                             
00125 RET_HOMOTOPY_STEP_FAILED,                                               
00126 RET_HOTSTART_STOPPED_INFEASIBILITY,                             
00127 RET_HOTSTART_STOPPED_UNBOUNDEDNESS,                             
00128 RET_WORKINGSET_UPDATE_FAILED,                                   
00129 RET_MAX_NWSR_REACHED,                                                   
00130 RET_CONSTRAINTS_NOT_SPECIFIED,                                  
00131 RET_INVALID_FACTORISATION_FLAG,                                 
00132 RET_UNABLE_TO_SAVE_QPDATA,                                              
00133 RET_STEPDIRECTION_FAILED_TQ,                                    
00134 RET_STEPDIRECTION_FAILED_CHOLESKY,                              
00135 RET_CYCLING_DETECTED,                                                   
00136 RET_CYCLING_NOT_RESOLVED,                                               
00137 RET_CYCLING_RESOLVED,                                                   
00138 RET_STEPSIZE,                                                                   
00139 RET_STEPSIZE_NONPOSITIVE,                                               
00140 RET_SETUPSUBJECTTOTYPE_FAILED,                                  
00141 RET_ADDCONSTRAINT_FAILED,                                               
00142 RET_ADDCONSTRAINT_FAILED_INFEASIBILITY,                 
00143 RET_ADDBOUND_FAILED,                                                    
00144 RET_ADDBOUND_FAILED_INFEASIBILITY,                              
00145 RET_REMOVECONSTRAINT_FAILED,                                    
00146 RET_REMOVEBOUND_FAILED,                                                 
00147 RET_REMOVE_FROM_ACTIVESET,                                              
00148 RET_ADD_TO_ACTIVESET,                                                   
00149 RET_REMOVE_FROM_ACTIVESET_FAILED,                               
00150 RET_ADD_TO_ACTIVESET_FAILED,                                    
00151 RET_CONSTRAINT_ALREADY_ACTIVE,                                  
00152 RET_ALL_CONSTRAINTS_ACTIVE,                                             
00153 RET_LINEARLY_DEPENDENT,                                                 
00154 RET_LINEARLY_INDEPENDENT,                                               
00155 RET_LI_RESOLVED,                                                                
00156 RET_ENSURELI_FAILED,                                                    
00157 RET_ENSURELI_FAILED_TQ,                                                 
00158 RET_ENSURELI_FAILED_NOINDEX,                                    
00159 RET_ENSURELI_FAILED_CYCLING,                                    
00160 RET_BOUND_ALREADY_ACTIVE,                                               
00161 RET_ALL_BOUNDS_ACTIVE,                                                  
00162 RET_CONSTRAINT_NOT_ACTIVE,                                              
00163 RET_BOUND_NOT_ACTIVE,                                                   
00164 RET_HESSIAN_NOT_SPD,                                                    
00165 RET_MATRIX_SHIFT_FAILED,                                                
00166 RET_MATRIX_FACTORISATION_FAILED,                                
00167 RET_PRINT_ITERATION_FAILED,                                             
00168 RET_NO_GLOBAL_MESSAGE_OUTPUTFILE,                               
00169 /* Utils */
00170 RET_UNABLE_TO_OPEN_FILE,                                                
00171 RET_UNABLE_TO_WRITE_FILE,                                               
00172 RET_UNABLE_TO_READ_FILE,                                                
00173 RET_FILEDATA_INCONSISTENT,                                              
00174 /* SolutionAnalysis */
00175 RET_NO_SOLUTION,                                                                
00176 RET_INACCURATE_SOLUTION                                                 
00177 };
00178 
00179 
00180 
00188 class MessageHandling
00189 {
00190         /*
00191          *      INTERNAL DATA STRUCTURES
00192          */
00193         public:
00195                 typedef struct {
00196                         returnValue key;                                                        
00197                         const char* data;                                                       
00198                         VisibilityStatus globalVisibilityStatus;        
00200                 } ReturnValueList;
00201 
00202 
00203         /*
00204          *      PUBLIC MEMBER FUNCTIONS
00205          */
00206         public:
00208                 MessageHandling( );
00209 
00211                 MessageHandling(  myFILE* _outputFile                                   
00212                                                   );
00213 
00215                 MessageHandling(        VisibilityStatus _errorVisibility,      
00216                                                         VisibilityStatus _warningVisibility,
00217                                                         VisibilityStatus _infoVisibility        
00218                                                         );
00219 
00221                 MessageHandling(        myFILE* _outputFile,                            
00222                                                         VisibilityStatus _errorVisibility,      
00223                                                         VisibilityStatus _warningVisibility,
00224                                                         VisibilityStatus _infoVisibility        
00225                                                         );
00226 
00228                 MessageHandling(        const MessageHandling& rhs      
00229                                                         );
00230 
00232                 ~MessageHandling( );
00233 
00235                 MessageHandling& operator=(     const MessageHandling& rhs      
00236                                                                         );
00237 
00238 
00245                 returnValue throwError(
00246                         returnValue Enumber,                                    
00247                         const char* additionaltext,                             
00248                         const char* functionname,                               
00249                         const char* filename,                                   
00250                         const unsigned long linenumber,                 
00251                         VisibilityStatus localVisibilityStatus  
00254                 );
00255 
00260                 returnValue throwWarning(
00261                         returnValue Wnumber,                                    
00262                         const char* additionaltext,                             
00263                         const char* functionname,                               
00264                         const char* filename,                                   
00265                         const unsigned long linenumber,                 
00266                         VisibilityStatus localVisibilityStatus  
00269                         );
00270 
00274                 returnValue throwInfo(
00275                         returnValue Inumber,                                    
00276                         const char* additionaltext,                             
00277                         const char* functionname,                               
00278                         const char* filename,                                   
00279                         const unsigned long linenumber,                 
00280                         VisibilityStatus localVisibilityStatus  
00283                         );
00284 
00285 
00288                 returnValue reset( );
00289 
00290 
00293                 returnValue listAllMessages( );
00294 
00295 
00298                 inline VisibilityStatus getErrorVisibilityStatus( ) const;
00299 
00302                 inline VisibilityStatus getWarningVisibilityStatus( ) const;
00303 
00306                 inline VisibilityStatus getInfoVisibilityStatus( ) const;
00307 
00310                 inline myFILE* getOutputFile( ) const;
00311 
00314                 inline int getErrorCount( ) const;
00315 
00316 
00318                 inline void setErrorVisibilityStatus(   VisibilityStatus _errorVisibility       
00319                                                                                                 );
00320 
00322                 inline void setWarningVisibilityStatus( VisibilityStatus _warningVisibility     
00323                                                                                                 );
00324 
00326                 inline void setInfoVisibilityStatus(    VisibilityStatus _infoVisibility        
00327                                                                                                 );
00328 
00330                 inline void setOutputFile(      myFILE* _outputFile     
00331                                                                         );
00332 
00336                 inline returnValue setErrorCount(       int _errorCount 
00337                                                                                         );
00338 
00340                 static const char* getErrorString(int error);
00341 
00342         /*
00343          *      PROTECTED MEMBER FUNCTIONS
00344          */
00345         protected:
00349                 returnValue throwMessage(
00350                         returnValue RETnumber,                                  
00351                         const char* additionaltext,                             
00352                         const char* functionname,                               
00353                         const char* filename,                                   
00354                         const unsigned long linenumber,                 
00355                         VisibilityStatus localVisibilityStatus, 
00358                         const char* RETstring                                   
00359                         );
00360 
00361 
00362         /*
00363          *      PROTECTED MEMBER VARIABLES
00364          */
00365         protected:
00366                 VisibilityStatus errorVisibility;               
00367                 VisibilityStatus warningVisibility;             
00368                 VisibilityStatus infoVisibility;                
00370                 myFILE* outputFile;                                             
00372                 int errorCount;                                                 
00373 };
00374 
00375 
00376 #ifndef __FUNCTION__
00377 
00378   #define __FUNCTION__ 0
00379 #endif
00380 
00381 #ifndef __FILE__
00382 
00383   #define __FILE__ 0
00384 #endif
00385 
00386 #ifndef __LINE__
00387 
00388   #define __LINE__ 0
00389 #endif
00390 
00391 
00393 #define THROWERROR(retval) ( getGlobalMessageHandler( )->throwError((retval),0,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE) )
00394 
00396 #define THROWWARNING(retval) ( getGlobalMessageHandler( )->throwWarning((retval),0,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE) )
00397 
00399 #define THROWINFO(retval) ( getGlobalMessageHandler( )->throwInfo((retval),0,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE) )
00400 
00401 
00405 MessageHandling* getGlobalMessageHandler( );
00406 
00407 
00408 #include <MessageHandling.ipp>
00409 
00410 #endif /* QPOASES_MESSAGEHANDLING_HPP */
00411 
00412 
00413 /*
00414  *      end of file
00415  */


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Sat Jun 8 2019 19:38:12