psType.h

Go to the documentation of this file.
00001 /** @file  psType.h
00002 *
00003 *  @brief Contains support for basic types
00004 *
00005 *  This file defines common datatypes used throughout psLib.
00006 *
00007 *  @ingroup DataContainer
00008 *
00009 *  @author Robert DeSonia, MHPCC
00010 *  @author Ross Harman, MHPCC
00011 *
00012 *  @version $Revision: 1.54 $ $Name:  $
00013 *  @date $Date: 2007/01/24 22:14:48 $
00014 *
00015 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
00016 */
00017 
00018 #ifndef PS_TYPE_H
00019 #define PS_TYPE_H
00020 
00021 /// @addtogroup DataContainer Data Containers
00022 /// @{
00023 
00024 #include <complex.h>
00025 #include <stdint.h>
00026 #include <float.h>
00027 #include <stdbool.h>
00028 
00029 /******************************************************************************/
00030 
00031 /*  TYPE DEFINITIONS                                                          */
00032 
00033 /******************************************************************************/
00034 
00035 /** Basic data types used by the containers.
00036  *
00037  * The basic types of the primitives used by psLib are defined within this enum. This enum is in turn used by
00038  * the psType struct.
00039  *
00040  */
00041 
00042 typedef uint8_t psU8;                  ///< 8-bit unsigned int
00043 typedef uint16_t psU16;                ///< 16-bit unsigned int
00044 typedef uint32_t psU32;                ///< 32-bit unsigned int
00045 typedef uint64_t psU64;                ///< 64-bit unsigned int
00046 typedef int8_t psS8;                   ///< 8-bit signed int
00047 typedef int16_t psS16;                 ///< 16-bit signed int
00048 typedef int32_t psS32;                 ///< 32-bit signed int
00049 typedef int64_t psS64;                 ///< 64-bit signed int
00050 typedef float psF32;                   ///< 32-bit floating point
00051 typedef double psF64;                  ///< 64-bit floating point
00052 
00053 #ifdef SWIG
00054 /** 32-bit complex value */
00055 typedef struct
00056 {
00057     float re, im;
00058 }
00059 psC32;
00060 
00061 /** 64-bit complex value */
00062 typedef struct
00063 {
00064     double re,im;
00065 }
00066 psC64;
00067 
00068 #else // SWIG
00069 typedef float complex psC32;          ///< complex with 32-bit floating point Real and Imagary numbers
00070 typedef double complex psC64;         ///< complex with 64-bit floating point Real and Imagary numbers
00071 #endif // !SWIG
00072 
00073 typedef char* psString;                ///< string value
00074 typedef void* psPtr;                   ///< void pointer
00075 typedef bool psBool;                   ///< boolean value
00076 
00077 /** Enumeration of data types for function elements.
00078  *  Contains replacements for native types.
00079  */
00080 typedef enum {
00081     PS_TYPE_S8   = 0x0101,             ///< Character.
00082     PS_TYPE_S16  = 0x0102,             ///< Short integer.
00083     PS_TYPE_S32  = 0x0104,             ///< Integer.
00084     PS_TYPE_S64  = 0x0108,             ///< Long integer.
00085     PS_TYPE_U8   = 0x0301,             ///< Unsigned character.
00086     PS_TYPE_U16  = 0x0302,             ///< Unsigned psS16 integer.
00087     PS_TYPE_U32  = 0x0304,             ///< Unsigned integer.
00088     PS_TYPE_U64  = 0x0308,             ///< Unsigned psS64 integer.
00089     PS_TYPE_F32  = 0x0404,             ///< Single-precision Floating point.
00090     PS_TYPE_F64  = 0x0408,             ///< Double-precision floating point.
00091     PS_TYPE_C32  = 0x0808,             ///< Complex numbers consisting of single-precision floating point.
00092     PS_TYPE_C64  = 0x0810,             ///< Complex numbers consisting of double-precision floating point.
00093     PS_TYPE_BOOL = 0x1301              ///< Boolean.
00094 } psElemType;
00095 
00096 /** Enumeration primarily used with metadata which defines a data structure
00097  *  e.g., list, array, FITS file, etc.
00098 */
00099 typedef enum {
00100     PS_DATA_S8   = PS_TYPE_S8,         ///< psS8
00101     PS_DATA_S16  = PS_TYPE_S16,        ///< psS16
00102     PS_DATA_S32  = PS_TYPE_S32,        ///< psS32
00103     PS_DATA_S64  = PS_TYPE_S64,        ///< psS64
00104     PS_DATA_U8   = PS_TYPE_U8,         ///< psU8
00105     PS_DATA_U16  = PS_TYPE_U16,        ///< psU16
00106     PS_DATA_U32  = PS_TYPE_U32,        ///< psU32
00107     PS_DATA_U64  = PS_TYPE_U64,        ///< psU64
00108     PS_DATA_F32  = PS_TYPE_F32,        ///< psF32
00109     PS_DATA_F64  = PS_TYPE_F64,        ///< psF64
00110     PS_DATA_BOOL = PS_TYPE_BOOL,       ///< psBool
00111     PS_DATA_STRING = 0x10000,          ///< psString (char *)
00112     PS_DATA_ARRAY,                     ///< psArray
00113     PS_DATA_BITSET,                    ///< psBitSet
00114     PS_DATA_CUBE,                      ///< psCube
00115     PS_DATA_FITS,                      ///< psFits
00116     PS_DATA_HASH,                      ///< psHash
00117     PS_DATA_HISTOGRAM,                 ///< psHistogram
00118     PS_DATA_IMAGE,                     ///< psImage
00119     PS_DATA_KERNEL,                    ///< psKernel
00120     PS_DATA_LINE,                      ///< psLine
00121     PS_DATA_LIST,                      ///< psList
00122     PS_DATA_LOOKUPTABLE,               ///< psLookupTable
00123     PS_DATA_METADATA,                  ///< psMetadata
00124     PS_DATA_METADATAITEM,              ///< psMetadataItem
00125     PS_DATA_MINIMIZATION,              ///< psMinimization
00126     PS_DATA_PIXELS,                    ///< psPixels
00127     PS_DATA_PLANE,                     ///< psPlane
00128     PS_DATA_PLANEDISTORT,              ///< psPlaneDistort
00129     PS_DATA_PLANETRANSFORM,            ///< psPlaneTransform
00130     PS_DATA_POLYNOMIAL1D,              ///< psPolynomial1D
00131     PS_DATA_POLYNOMIAL2D,              ///< psPolynomial2D
00132     PS_DATA_POLYNOMIAL3D,              ///< psPolynomial3D
00133     PS_DATA_POLYNOMIAL4D,              ///< psPolynomial4D
00134     PS_DATA_PROJECTION,                ///< psProjection
00135     PS_DATA_REGION,                    ///< psRegion
00136     PS_DATA_SCALAR,                    ///< psScalar
00137     PS_DATA_SPHERE,                    ///< psSphere
00138     PS_DATA_SPHEREROT,                 ///< psSphereTransform
00139     PS_DATA_SPLINE1D,                  ///< psSpline1D
00140     PS_DATA_STATS,                     ///< psStats
00141     PS_DATA_TIME,                      ///< psTime
00142     PS_DATA_VECTOR,                    ///< psVector
00143     PS_DATA_UNKNOWN,                   ///< Other data of an unknown type
00144     PS_DATA_METADATA_MULTI             ///< Used internally for metadata; not a 'real' type
00145 } psDataType;
00146 
00147 #define PS_TYPE_MASK PS_TYPE_U8        /**< the psElemType to use for mask image */
00148 #define PS_TYPE_MASK_DATA U8           /**< the data member to use for mask image */
00149 #define PS_TYPE_MASK_NAME "psU8"       /**< the data type for mask as a string */
00150 
00151 typedef psU8 psMaskType;               ///< the C datatype for a mask image
00152 typedef psBool psBOOL;                 ///< allow psBOOL to be used instead of psBool (for macros)
00153 
00154 #define PS_MIN_S8        INT8_MIN      /**< minimum valid psS8 value */
00155 #define PS_MIN_S16       INT16_MIN     /**< minimum valid psS16 value */
00156 #define PS_MIN_S32       INT32_MIN     /**< minimum valid psS32 value */
00157 #define PS_MIN_S64       INT64_MIN     /**< minimum valid psS64 value */
00158 #define PS_MIN_U8        0             /**< minimum valid psU8 value */
00159 #define PS_MIN_U16       0             /**< minimum valid psU16 value */
00160 #define PS_MIN_U32       0             /**< minimum valid psU32 value */
00161 #define PS_MIN_U64       0             /**< minimum valid psU64 value */
00162 #define PS_MIN_F32       -FLT_MAX      /**< minimum valid psF32 value */
00163 #define PS_MIN_F64       -DBL_MAX      /**< minimum valid psF64 value */
00164 #define PS_MIN_C32       -FLT_MAX      /**< minimum valid real or imaginary psC32 value */
00165 #define PS_MIN_C64       -DBL_MAX      /**< minimum valid real or imaginary psC32 value */
00166 
00167 #define PS_MAX_S8        INT8_MAX      /**< maximum valid psS8 value */
00168 #define PS_MAX_S16       INT16_MAX     /**< maximum valid psS16 value */
00169 #define PS_MAX_S32       INT32_MAX     /**< maximum valid psS32 value */
00170 #define PS_MAX_S64       INT64_MAX     /**< maximum valid psS64 value */
00171 #define PS_MAX_U8        UINT8_MAX     /**< maximum valid psU8 value */
00172 #define PS_MAX_U16       UINT16_MAX    /**< maximum valid psU16 value */
00173 #define PS_MAX_U32       UINT32_MAX    /**< maximum valid psU32 value */
00174 #define PS_MAX_U64       UINT64_MAX    /**< maximum valid psU64 value */
00175 #define PS_MAX_F32       FLT_MAX       /**< maximum valid psF32 value */
00176 #define PS_MAX_F64       DBL_MAX       /**< maximum valid psF64 value */
00177 #define PS_MAX_C32       FLT_MAX       /**< maximum valid real or imaginary psC32 value */
00178 #define PS_MAX_C64       DBL_MAX       /**< maximum valid real or imaginary psC32 value */
00179 
00180 #define PS_TYPE_BOOL_NAME "psBool"
00181 #define PS_TYPE_S8_NAME   "psS8"
00182 #define PS_TYPE_S16_NAME  "psS16"
00183 #define PS_TYPE_S32_NAME  "psS32"
00184 #define PS_TYPE_S64_NAME  "psS64"
00185 #define PS_TYPE_U8_NAME   "psU8"
00186 #define PS_TYPE_U16_NAME  "psU16"
00187 #define PS_TYPE_U32_NAME  "psU32"
00188 #define PS_TYPE_U64_NAME  "psU64"
00189 #define PS_TYPE_F32_NAME  "psF32"
00190 #define PS_TYPE_F64_NAME  "psF64"
00191 #define PS_TYPE_C32_NAME  "psC32"
00192 #define PS_TYPE_C64_NAME  "psC64"
00193 
00194 #define PS_TYPE_NAME(value,type) \
00195 switch(type) { \
00196 case PS_TYPE_BOOL: \
00197     value = PS_TYPE_BOOL_NAME; \
00198     break; \
00199 case PS_TYPE_S8: \
00200     value = PS_TYPE_S8_NAME; \
00201     break; \
00202 case PS_TYPE_S16: \
00203     value = PS_TYPE_S16_NAME; \
00204     break; \
00205 case PS_TYPE_S32: \
00206     value = PS_TYPE_S32_NAME; \
00207     break; \
00208 case PS_TYPE_S64: \
00209     value = PS_TYPE_S64_NAME; \
00210     break; \
00211 case PS_TYPE_U8: \
00212     value = PS_TYPE_U8_NAME; \
00213     break; \
00214 case PS_TYPE_U16: \
00215     value = PS_TYPE_U16_NAME; \
00216     break; \
00217 case PS_TYPE_U32: \
00218     value = PS_TYPE_U32_NAME; \
00219     break; \
00220 case PS_TYPE_U64: \
00221     value = PS_TYPE_U64_NAME; \
00222     break; \
00223 case PS_TYPE_F32: \
00224     value = PS_TYPE_F32_NAME; \
00225     break; \
00226 case PS_TYPE_F64: \
00227     value = PS_TYPE_F64_NAME; \
00228     break; \
00229 case PS_TYPE_C32: \
00230     value = PS_TYPE_C32_NAME; \
00231     break; \
00232 case PS_TYPE_C64: \
00233     value = PS_TYPE_C64_NAME; \
00234     break; \
00235 default: \
00236     value = "unknown"; \
00237 };
00238 
00239 /// Macro to get the bad pixel reason code (stored as part of mask value)
00240 #define PS_BADPIXEL_BITMASK 0x0f
00241 #define PS_GET_BADPIXEL(maskValue) (maskValue & PS_BADPIXEL_BITMASK)
00242 
00243 #define PS_IS_BADPIXEL(maskValue) (PS_GET_BADPIXEL(maskValue) != 0)
00244 
00245 /// Macro to apply a bad pixel reason code to mask image
00246 #define PS_SET_BADPIXEL(maskValue, reasonCode) \
00247 { \
00248     maskValue = (psMaskType)((reasonCode & PS_BADPIXEL_BITMASK) | (maskValue & ~PS_BADPIXEL_BITMASK)); \
00249 }
00250 
00251 /// Macro to determine if the psElemType is an integer.
00252 #define PS_IS_PSELEMTYPE_INT(x) ((x & 0x100) == 0x100)
00253 /// Macro to determine if the psElemType is unsigned.
00254 #define PS_IS_PSELEMTYPE_UNSIGNED(x) ((x & 0x200) == 0x200)
00255 /// Macro to determine if the psElemType is a real (non-complex) floating-point type.
00256 #define PS_IS_PSELEMTYPE_REAL(x) ((x & 0x400) == 0x400)
00257 /// Macro to determine if the psElemType is complex number type.
00258 #define PS_IS_PSELEMTYPE_COMPLEX(x) ((x & 0x800) == 0x800)
00259 /// Macro to determine if the psElemType is boolean type.
00260 #define PS_IS_PSELEMTYPE_BOOL(x) ((x & 0x1000) == 0x1000)
00261 /// Macro to determine the storage size, in bytes, of the psElemType.
00262 #define PSELEMTYPE_SIZEOF(x) (x & 0xFF)
00263 
00264 /** Dimensions of a data type.
00265  *
00266  * The dimensions of containers used by psLib are defined within this enum. This enum is used by the psType
00267 struct. *
00268  */
00269 typedef enum {
00270     PS_DIMEN_SCALAR,            ///< Scalar.
00271     PS_DIMEN_VECTOR,            ///< Vector.
00272     PS_DIMEN_TRANSV,            ///< Transposed vector.
00273     PS_DIMEN_IMAGE,             ///< Image.
00274     PS_DIMEN_OTHER              ///< Something else that's not supported for arithmetic.
00275 } psDimen;
00276 
00277 /** The type of a data type.
00278  *
00279  * All psLib complex types consist of primitive components. This struct provides the description of those
00280  * primitives.
00281  *
00282  */
00283 typedef struct
00284 {
00285     psElemType type;                   ///< The type
00286     psDimen dimen;                     ///< The dimensionality.
00287 }
00288 psMathType;
00289 
00290 /** The type of a basic data type
00291  *
00292  *  All psLib complex types consist of primitive components.  This structure provides the ability to cast
00293  *  an unknown data structure to safely test the underlining data type.
00294  *
00295  */
00296 typedef struct
00297 {
00298     psMathType type;              ///< Data type information
00299 }
00300 psMath;
00301 
00302 /** Checks the deallocator to see if the pointer matches the desired datatype.
00303  *
00304  *  @return bool:       True if type matches, otherwise false.
00305  */
00306 bool psMemCheckType(
00307     psDataType type,                   ///< The desired psDataType to match
00308     psPtr ptr                          ///< The desired pointer to match
00309 );
00310 
00311 /// @}
00312 #endif // #ifndef PS_TYPE_H

Generated on Fri Feb 2 22:24:35 2007 for pslib by  doxygen 1.5.1