Home | History | Annotate | Download | only in include
      1 /*M///////////////////////////////////////////////////////////////////////////////////////
      2 //
      3 //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
      4 //
      5 //  By downloading, copying, installing or using the software you agree to this license.
      6 //  If you do not agree to this license, do not download, install,
      7 //  copy or use the software.
      8 //
      9 //
     10 //                        Intel License Agreement
     11 //                For Open Source Computer Vision Library
     12 //
     13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
     14 // Third party copyrights are property of their respective owners.
     15 //
     16 // Redistribution and use in source and binary forms, with or without modification,
     17 // are permitted provided that the following conditions are met:
     18 //
     19 //   * Redistribution's of source code must retain the above copyright notice,
     20 //     this list of conditions and the following disclaimer.
     21 //
     22 //   * Redistribution's in binary form must reproduce the above copyright notice,
     23 //     this list of conditions and the following disclaimer in the documentation
     24 //     and/or other materials provided with the distribution.
     25 //
     26 //   * The name of Intel Corporation may not be used to endorse or promote products
     27 //     derived from this software without specific prior written permission.
     28 //
     29 // This software is provided by the copyright holders and contributors "as is" and
     30 // any express or implied warranties, including, but not limited to, the implied
     31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
     32 // In no event shall the Intel Corporation or contributors be liable for any direct,
     33 // indirect, incidental, special, exemplary, or consequential damages
     34 // (including, but not limited to, procurement of substitute goods or services;
     35 // loss of use, data, or profits; or business interruption) however caused
     36 // and on any theory of liability, whether in contract, strict liability,
     37 // or tort (including negligence or otherwise) arising in any way out of
     38 // the use of this software, even if advised of the possibility of such damage.
     39 //
     40 //M*/
     41 
     42 #ifndef _CXCORE_ERROR_H_
     43 #define _CXCORE_ERROR_H_
     44 
     45 /************Below is declaration of error handling stuff in PLSuite manner**/
     46 
     47 typedef int CVStatus;
     48 
     49 /* this part of CVStatus is compatible with IPLStatus
     50   Some of below symbols are not [yet] used in OpenCV
     51 */
     52 #define CV_StsOk                    0  /* everithing is ok                */
     53 #define CV_StsBackTrace            -1  /* pseudo error for back trace     */
     54 #define CV_StsError                -2  /* unknown /unspecified error      */
     55 #define CV_StsInternal             -3  /* internal error (bad state)      */
     56 #define CV_StsNoMem                -4  /* insufficient memory             */
     57 #define CV_StsBadArg               -5  /* function arg/param is bad       */
     58 #define CV_StsBadFunc              -6  /* unsupported function            */
     59 #define CV_StsNoConv               -7  /* iter. didn't converge           */
     60 #define CV_StsAutoTrace            -8  /* tracing                         */
     61 
     62 #define CV_HeaderIsNull            -9  /* image header is NULL            */
     63 #define CV_BadImageSize            -10 /* image size is invalid           */
     64 #define CV_BadOffset               -11 /* offset is invalid               */
     65 #define CV_BadDataPtr              -12 /**/
     66 #define CV_BadStep                 -13 /**/
     67 #define CV_BadModelOrChSeq         -14 /**/
     68 #define CV_BadNumChannels          -15 /**/
     69 #define CV_BadNumChannel1U         -16 /**/
     70 #define CV_BadDepth                -17 /**/
     71 #define CV_BadAlphaChannel         -18 /**/
     72 #define CV_BadOrder                -19 /**/
     73 #define CV_BadOrigin               -20 /**/
     74 #define CV_BadAlign                -21 /**/
     75 #define CV_BadCallBack             -22 /**/
     76 #define CV_BadTileSize             -23 /**/
     77 #define CV_BadCOI                  -24 /**/
     78 #define CV_BadROISize              -25 /**/
     79 
     80 #define CV_MaskIsTiled             -26 /**/
     81 
     82 #define CV_StsNullPtr                -27 /* null pointer */
     83 #define CV_StsVecLengthErr           -28 /* incorrect vector length */
     84 #define CV_StsFilterStructContentErr -29 /* incorr. filter structure content */
     85 #define CV_StsKernelStructContentErr -30 /* incorr. transform kernel content */
     86 #define CV_StsFilterOffsetErr        -31 /* incorrect filter ofset value */
     87 
     88 /*extra for CV */
     89 #define CV_StsBadSize                -201 /* the input/output structure size is incorrect  */
     90 #define CV_StsDivByZero              -202 /* division by zero */
     91 #define CV_StsInplaceNotSupported    -203 /* in-place operation is not supported */
     92 #define CV_StsObjectNotFound         -204 /* request can't be completed */
     93 #define CV_StsUnmatchedFormats       -205 /* formats of input/output arrays differ */
     94 #define CV_StsBadFlag                -206 /* flag is wrong or not supported */
     95 #define CV_StsBadPoint               -207 /* bad CvPoint */
     96 #define CV_StsBadMask                -208 /* bad format of mask (neither 8uC1 nor 8sC1)*/
     97 #define CV_StsUnmatchedSizes         -209 /* sizes of input/output structures do not match */
     98 #define CV_StsUnsupportedFormat      -210 /* the data format/type is not supported by the function*/
     99 #define CV_StsOutOfRange             -211 /* some of parameters are out of range */
    100 #define CV_StsParseError             -212 /* invalid syntax/structure of the parsed file */
    101 #define CV_StsNotImplemented         -213 /* the requested function/feature is not implemented */
    102 #define CV_StsBadMemBlock            -214 /* an allocated block has been corrupted */
    103 
    104 /********************************* Error handling Macros ********************************/
    105 
    106 #define OPENCV_ERROR(status,func,context)                           \
    107                 cvError((status),(func),(context),__FILE__,__LINE__)
    108 
    109 #define OPENCV_ERRCHK(func,context)                                 \
    110                 {if (cvGetErrStatus() >= 0)                         \
    111                  {OPENCV_ERROR(CV_StsBackTrace,(func),(context));}}
    112 
    113 #define OPENCV_ASSERT(expr,func,context)                            \
    114                 {if (! (expr))                                      \
    115                  {OPENCV_ERROR(CV_StsInternal,(func),(context));}}
    116 
    117 #define OPENCV_RSTERR() (cvSetErrStatus(CV_StsOk))
    118 
    119 #define OPENCV_CALL( Func )                                         \
    120 {                                                                   \
    121     Func;                                                           \
    122 }
    123 
    124 
    125 /**************************** OpenCV-style error handling *******************************/
    126 
    127 /* CV_FUNCNAME macro defines icvFuncName constant which is used by CV_ERROR macro */
    128 #ifdef CV_NO_FUNC_NAMES
    129     #define CV_FUNCNAME( Name )
    130     #define cvFuncName ""
    131 #else
    132     #define CV_FUNCNAME( Name )  \
    133     static char cvFuncName[] = Name
    134 #endif
    135 
    136 
    137 /*
    138   CV_ERROR macro unconditionally raises error with passed code and message.
    139   After raising error, control will be transferred to the exit label.
    140 */
    141 #define CV_ERROR( Code, Msg )                                       \
    142 {                                                                   \
    143      cvError( (Code), cvFuncName, Msg, __FILE__, __LINE__ );        \
    144      EXIT;                                                          \
    145 }
    146 
    147 /* Simplified form of CV_ERROR */
    148 #define CV_ERROR_FROM_CODE( code )   \
    149     CV_ERROR( code, "" )
    150 
    151 /*
    152  CV_CHECK macro checks error status after CV (or IPL)
    153  function call. If error detected, control will be transferred to the exit
    154  label.
    155 */
    156 #define CV_CHECK()                                                  \
    157 {                                                                   \
    158     if( cvGetErrStatus() < 0 )                                      \
    159         CV_ERROR( CV_StsBackTrace, "Inner function failed." );      \
    160 }
    161 
    162 
    163 /*
    164  CV_CALL macro calls CV (or IPL) function, checks error status and
    165  signals a error if the function failed. Useful in "parent node"
    166  error procesing mode
    167 */
    168 #define CV_CALL( Func )                                             \
    169 {                                                                   \
    170     Func;                                                           \
    171     CV_CHECK();                                                     \
    172 }
    173 
    174 
    175 /* Runtime assertion macro */
    176 #define CV_ASSERT( Condition )                                          \
    177 {                                                                       \
    178     if( !(Condition) )                                                  \
    179         CV_ERROR( CV_StsInternal, "Assertion: " #Condition " failed" ); \
    180 }
    181 
    182 #define __BEGIN__       {
    183 #define __END__         goto exit; exit: ; }
    184 #define __CLEANUP__
    185 #define EXIT            goto exit
    186 
    187 #endif /* _CXCORE_ERROR_H_ */
    188 
    189 /* End of file. */
    190