IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 3, 2004, 3:05:00 PM (22 years ago)
Author:
desonia
Message:

changed the psError signature to match SDRS. Also made misc. cleanups as
I was combing the files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/dataManip/psConstants.h

    r2272 r2273  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-11-03 22:58:53 $
     8 *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-11-04 01:04:57 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3232#define PS_INT_CHECK_NON_NEGATIVE(NAME, RVAL) \
    3333if (NAME < 0) { \
    34     psError(__func__,"Error: %s is less than 0.", #NAME); \
     34    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
     35            "Error: %s is less than 0.", #NAME); \
    3536    return(RVAL); \
    3637}
     
    3839#define PS_INT_CHECK_POSITIVE(NAME, RVAL) \
    3940if (NAME < 1) { \
    40     psError(__func__,"Error: %s is 0 or less.", #NAME); \
    41     return(RVAL); \
    42 }
    43 
    44 // Produce an error if ((NAME1 > NAME2)
     41    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
     42            "Error: %s is 0 or less.", #NAME); \
     43    return(RVAL); \
     44}
     45
     46#define PS_INT_CHECK_RANGE(NAME, LOWER, UPPER, RVAL) \
     47if ((int)NAME < LOWER || (int)NAME > UPPER) { \
     48    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
     49            "Error: %s, %d, is out of range.  Must be between %d and %d.", \
     50            #NAME,(int)NAME,LOWER,UPPER); \
     51    return RVAL; \
     52}
     53
     54// Produce an error if (NAME1 > NAME2)
    4555#define PS_INT_COMPARE(NAME1, NAME2, RVAL) \
    4656if (NAME1 > NAME2) { \
    47     psError(__func__,"Error: (%s > %s) (%d %d).", #NAME1, #NAME2, NAME1, NAME2); \
     57    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
     58            "Error: (%s > %s) (%d %d).", \
     59            #NAME1, #NAME2, NAME1, NAME2); \
    4860    return(RVAL); \
    4961}
     
    5365#define PS_FLOAT_COMPARE(NAME1, NAME2, RVAL) \
    5466if (NAME1 > NAME2) { \
    55     psError(__func__,"Error: (%s > %s) (%f %f)", #NAME1, #NAME2, NAME1, NAME2); \
     67    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
     68            "Error: (%s > %s) (%f %f)", \
     69            #NAME1, #NAME2, NAME1, NAME2); \
    5670    return(RVAL); \
    5771}
     
    5973#define PS_FLOAT_CHECK_NON_EQUAL(NAME1, NAME2, RVAL) \
    6074if (fabs(NAME2 - NAME1) < FLT_EPSILON) { \
    61     psError(__func__,"Error: %s and %s are equal.", #NAME1, #NAME2); \
     75    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
     76            "Error: %s and %s are equal.", \
     77            #NAME1, #NAME2); \
    6278    return(RVAL); \
    6379}
     
    6783the wrong type.
    6884*****************************************************************************/
    69 #define PS_PTR_CHECK_NULL(NAME, RVAL) \
     85#define PS_PTR_CHECK_NULL(NAME, RVAL) PS_PTR_CHECK_NULL_GENERAL(NAME, return RVAL)
     86#define PS_PTR_CHECK_NULL_GENERAL(NAME, CLEANUP) \
    7087if (NAME == NULL) { \
    71     psError(__func__,"Unallowable operation: %s is NULL.", #NAME); \
    72     return(RVAL); \
     88    psError(PS_ERR_BAD_PARAMETER_NULL, true, \
     89            "Unallowable operation: %s is NULL.", \
     90            #NAME); \
     91    CLEANUP; \
    7392}
    7493
    7594#define PS_PTR_CHECK_TYPE(NAME, TYPE, RVAL) \
    7695if (NAME->type.type != TYPE) { \
    77     psError(__func__,"Unallowable operation: %s has incorrect type.", #NAME); \
    78     return(RVAL); \
    79 }
     96    psError(PS_ERR_BAD_PARAMETER_TYPE, true, \
     97            "Unallowable operation: %s has incorrect type.", \
     98            #NAME); \
     99    return(RVAL); \
     100}
     101
     102#define PS_PTR_CHECK_DIMEN(NAME, DIMEN, RVAL) PS_PTR_CHECK_DIMEN_GENERAL(NAME, DIMEN, return RVAL)
     103#define PS_PTR_CHECK_DIMEN_GENERAL(NAME, DIMEN, CLEANUP) \
     104if (NAME->type.dimen != DIMEN) { \
     105    psError(PS_ERR_BAD_PARAMETER_TYPE, true, \
     106            "Unallowable operation: %s has incorrect dimensionality.", \
     107            #NAME); \
     108    CLEANUP; \
     109}
     110
    80111
    81112#define PS_PTR_CHECK_SIZE_EQUAL(PTR1, PTR2, RVAL) \
    82113if (PTR1->n != PTR2->n) { \
    83     psError(__func__,"ptr %s has size %d, ptr %s has size %d.", #PTR1, PTR1->n, #PTR2, PTR2->n); \
    84     return(RVAL); \
    85 }
    86 
    87 #define PS_PTR_CHECK_TYPE_EQUAL(PTR1, PTR2, RVAL) \
     114    psError(PS_ERR_BAD_PARAMETER_SIZE, true, \
     115            "ptr %s has size %d, ptr %s has size %d.", \
     116            #PTR1, PTR1->n, #PTR2, PTR2->n); \
     117    return(RVAL); \
     118}
     119
     120#define PS_PTR_CHECK_TYPE_EQUAL(PTR1, PTR2, RVAL) PS_PTR_CHECK_TYPE_EQUAL_GENERAL(PTR1, PTR2, return RVAL)
     121
     122#define PS_PTR_CHECK_TYPE_EQUAL_GENERAL(PTR1, PTR2, CLEANUP) \
    88123if (PTR1->type.type != PTR2->type.type) { \
    89     psError(__func__,"ptr %s has type %d, ptr %s has type %d.", #PTR1, PTR1->type.type, #PTR2, PTR2->type.type); \
    90     return(RVAL); \
     124    psError(PS_ERR_BAD_PARAMETER_TYPE, true, \
     125            "ptr %s has type %d, ptr %s has type %d.", \
     126            #PTR1, PTR1->type.type, #PTR2, PTR2->type.type); \
     127    CLEANUP; \
    91128}
    92129
     
    95132    PS_VECTOR macros:
    96133 *****************************************************************************/
    97 #define PS_VECTOR_CHECK_NULL(NAME, RVAL) \
     134#define PS_VECTOR_CHECK_NULL(NAME, RVAL) PS_VECTOR_CHECK_NULL_GENERAL(NAME, return RVAL)
     135#define PS_VECTOR_CHECK_NULL_GENERAL(NAME, CLEANUP) \
    98136if (NAME == NULL || NAME->data.V == NULL) { \
    99     psError(__func__,"Unallowable operation: psVector %s or its data is NULL.", #NAME); \
    100     return(RVAL); \
     137    psError(PS_ERR_BAD_PARAMETER_NULL, true, \
     138            "Unallowable operation: psVector %s or its data is NULL.", \
     139            #NAME); \
     140    CLEANUP; \
    101141} \
    102142
    103143#define PS_VECTOR_CHECK_EMPTY(NAME, RVAL) \
    104144if (NAME->n < 1) { \
    105     psError(__func__,"Unallowable operation: psVector %s has no elements.", #NAME); \
     145    psError(PS_ERR_BAD_PARAMETER_SIZE, true, \
     146            "Unallowable operation: psVector %s has no elements.", \
     147            #NAME); \
    106148    return(RVAL); \
    107149} \
     
    109151#define PS_VECTOR_CHECK_TYPE_F32_OR_F64(NAME, RVAL) \
    110152if ((NAME->type.type != PS_TYPE_F32) && (NAME->type.type != PS_TYPE_F64)) { \
    111     psError(__func__, "psVector %s: bad type(%d)", #NAME, NAME->type.type); \
     153    psError(PS_ERR_BAD_PARAMETER_TYPE, true, \
     154            "psVector %s: bad type(%d)", \
     155            #NAME, NAME->type.type); \
    112156    return(RVAL); \
    113157} \
     
    115159#define PS_VECTOR_CHECK_TYPE(NAME, TYPE, RVAL) \
    116160if (NAME->type.type != TYPE) { \
    117     psError(__func__,"Unallowable operation: psVector %s has incorrect type.", #NAME); \
     161    psError(PS_ERR_BAD_PARAMETER_TYPE, true, \
     162            "Unallowable operation: psVector %s has incorrect type.", \
     163            #NAME); \
    118164    return(RVAL); \
    119165}
     
    121167#define PS_VECTOR_CHECK_SIZE_EQUAL(VEC1, VEC2, RVAL) \
    122168if (VEC1->n != VEC2->n) { \
    123     psError(__func__,"psVector %s has size %d, psVector %s has size %d.", #VEC1, VEC1->n, #VEC2, VEC2->n); \
     169    psError(PS_ERR_BAD_PARAMETER_SIZE, true, \
     170            "psVector %s has size %d, psVector %s has size %d.", \
     171            #VEC1, VEC1->n, #VEC2, VEC2->n); \
    124172    return(RVAL); \
    125173}
     
    221269#define PS_POLY_CHECK_NULL(NAME, RVAL) \
    222270if (NAME == NULL || NAME->coeff == NULL) { \
    223     psError(__func__,"Unallowable operation: polynomial %s or its coeffs is NULL.", #NAME); \
     271    psError(PS_ERR_BAD_PARAMETER_NULL, true, \
     272            "Unallowable operation: polynomial %s or its coeffs is NULL.", \
     273            #NAME); \
    224274    return(RVAL); \
    225275} \
     
    227277#define PS_POLY_CHECK_TYPE(NAME, TYPE, RVAL) \
    228278if (NAME->type != TYPE) { \
    229     psError(__func__,"Unallowable operation: polynomial %s has wrong type.", #NAME); \
     279    psError(PS_ERR_BAD_PARAMETER_TYPE, true, \
     280            "Unallowable operation: polynomial %s has wrong type.", #NAME); \
    230281    return(RVAL); \
    231282} \
     
    234285    PS_IMAGE macros:
    235286*****************************************************************************/
    236 #define PS_IMAGE_CHECK_NULL(NAME, RVAL) \
     287#define PS_IMAGE_CHECK_NULL(NAME, RVAL) PS_IMAGE_CHECK_NULL_GENERAL(NAME, return RVAL)
     288#define PS_IMAGE_CHECK_NULL_GENERAL(NAME, CLEANUP) \
    237289if (NAME == NULL || NAME->data.V == NULL) { \
    238     psError(__func__,"Unallowable operation: psImage %s or its data is NULL.", #NAME); \
    239     return(RVAL); \
    240 }
    241 
    242 #define PS_IMAGE_CHECK_EMPTY(NAME, RVAL) \
     290    psError(PS_ERR_BAD_PARAMETER_NULL, true, \
     291            "Unallowable operation: psImage %s or its data is NULL.", \
     292            #NAME); \
     293    CLEANUP; \
     294}
     295
     296#define PS_IMAGE_CHECK_EMPTY(NAME, RVAL) PS_IMAGE_CHECK_EMPTY_GENERAL(NAME, return RVAL)
     297#define PS_IMAGE_CHECK_EMPTY_GENERAL(NAME, CLEANUP) \
    243298if (NAME->numCols < 1 || NAME->numRows < 1) { \
    244     psError(__func__,"Unallowable operation: psImage %s has zero rows or columns (%dx%d).", #NAME, \
    245             NAME->numCols, NAME->numRows); \
    246     return(RVAL); \
     299    psError(PS_ERR_BAD_PARAMETER_SIZE, true, \
     300            "Unallowable operation: psImage %s has zero rows or columns (%dx%d).", \
     301            #NAME, NAME->numCols, NAME->numRows); \
     302    CLEANUP; \
    247303}
    248304
    249305#define PS_IMAGE_CHECK_TYPE(NAME, TYPE, RVAL) \
    250306if (NAME->type.type != TYPE) { \
    251     psError(__func__,"Unallowable operation: psImage %s has incorrect type.", #NAME); \
     307    psError(PS_ERR_BAD_PARAMETER_TYPE, true, \
     308            "Unallowable operation: psImage %s has incorrect type.", \
     309            #NAME); \
    252310    return(RVAL); \
    253311}
     
    260318#define PS_READOUT_CHECK_NULL(NAME, RVAL) \
    261319if (NAME == NULL || NAME->image == NULL) { \
    262     psError(__func__,"Unallowable operation: psReadout %s or its data is NULL.", #NAME); \
     320    psError(PS_ERR_BAD_PARAMETER_NULL, true, \
     321            "Unallowable operation: psReadout %s or its data is NULL.", \
     322            #NAME); \
    263323    return(RVAL); \
    264324}
Note: See TracChangeset for help on using the changeset viewer.