Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

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.1.1.1 $ $Name:  $
00013 *  @date $Date: 2005/06/15 21:08:12 $
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 #include <complex.h>
00022 #include <stdint.h>
00023 #include <float.h>
00024 #include <stdbool.h>
00025 
00026 /// @addtogroup DataContainer
00027 /// @{
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 typedef struct
00055 {
00056     float re, im;
00057 }
00058 psC32;
00059 typedef struct
00060 {
00061     double re,im;
00062 }
00063 psC64;
00064 #else // SWIG
00065 typedef float _Complex psC32;          ///< complex with 32-bit floating point Real and Imagary numbers
00066 typedef double _Complex psC64;         ///< complex with 64-bit floating point Real and Imagary numbers
00067 #endif // !SWIG
00068 
00069 typedef void* psPtr;                   ///< void pointer
00070 typedef bool psBool;                   ///< boolean value
00071 
00072 typedef enum {
00073     PS_TYPE_S8   = 0x0101,             ///< Character.
00074     PS_TYPE_S16  = 0x0102,             ///< Short integer.
00075     PS_TYPE_S32  = 0x0104,             ///< Integer.
00076     PS_TYPE_S64  = 0x0108,             ///< Long integer.
00077     PS_TYPE_U8   = 0x0301,             ///< Unsigned character.
00078     PS_TYPE_U16  = 0x0302,             ///< Unsigned psS16 integer.
00079     PS_TYPE_U32  = 0x0304,             ///< Unsigned integer.
00080     PS_TYPE_U64  = 0x0308,             ///< Unsigned psS64 integer.
00081     PS_TYPE_F32  = 0x0404,             ///< Single-precision Floating point.
00082     PS_TYPE_F64  = 0x0408,             ///< Double-precision floating point.
00083     PS_TYPE_C32  = 0x0808,             ///< Complex numbers consisting of single-precision floating point.
00084     PS_TYPE_C64  = 0x0810,             ///< Complex numbers consisting of double-precision floating point.
00085     PS_TYPE_BOOL = 0x1301              ///< Boolean.
00086 } psElemType;
00087 
00088 #define PS_TYPE_MASK PS_TYPE_U8        /**< the psElemType to use for mask image */
00089 #define PS_TYPE_MASK_DATA U8           /**< the data member to use for mask image */
00090 #define PS_TYPE_MASK_NAME "psU8"       /**< the data type for mask as a string */
00091 
00092 typedef psU8 psMaskType;               ///< the C datatype for a mask image
00093 typedef psBool psBOOL;                 ///< allow psBOOL to be used instead of psBool (for macros)
00094 
00095 #define PS_MIN_S8        INT8_MIN      /**< minimum valid psS8 value */
00096 #define PS_MIN_S16       INT16_MIN     /**< minimum valid psS16 value */
00097 #define PS_MIN_S32       INT32_MIN     /**< minimum valid psS32 value */
00098 #define PS_MIN_S64       INT64_MIN     /**< minimum valid psS64 value */
00099 #define PS_MIN_U8        0             /**< minimum valid psU8 value */
00100 #define PS_MIN_U16       0             /**< minimum valid psU16 value */
00101 #define PS_MIN_U32       0             /**< minimum valid psU32 value */
00102 #define PS_MIN_U64       0             /**< minimum valid psU64 value */
00103 #define PS_MIN_F32       -FLT_MAX      /**< minimum valid psF32 value */
00104 #define PS_MIN_F64       -DBL_MAX      /**< minimum valid psF64 value */
00105 #define PS_MIN_C32       -FLT_MAX      /**< minimum valid real or imaginary psC32 value */
00106 #define PS_MIN_C64       -DBL_MAX      /**< minimum valid real or imaginary psC32 value */
00107 
00108 #define PS_MAX_S8        INT8_MAX      /**< maximum valid psS8 value */
00109 #define PS_MAX_S16       INT16_MAX     /**< maximum valid psS16 value */
00110 #define PS_MAX_S32       INT32_MAX     /**< maximum valid psS32 value */
00111 #define PS_MAX_S64       INT64_MAX     /**< maximum valid psS64 value */
00112 #define PS_MAX_U8        UINT8_MAX     /**< maximum valid psU8 value */
00113 #define PS_MAX_U16       UINT16_MAX    /**< maximum valid psU16 value */
00114 #define PS_MAX_U32       UINT32_MAX    /**< maximum valid psU32 value */
00115 #define PS_MAX_U64       UINT64_MAX    /**< maximum valid psU64 value */
00116 #define PS_MAX_F32       FLT_MAX       /**< maximum valid psF32 value */
00117 #define PS_MAX_F64       DBL_MAX       /**< maximum valid psF64 value */
00118 #define PS_MAX_C32       FLT_MAX       /**< maximum valid real or imaginary psC32 value */
00119 #define PS_MAX_C64       DBL_MAX       /**< maximum valid real or imaginary psC32 value */
00120 
00121 #define PS_TYPE_BOOL_NAME "psBool"
00122 #define PS_TYPE_S8_NAME   "psS8"
00123 #define PS_TYPE_S16_NAME  "psS16"
00124 #define PS_TYPE_S32_NAME  "psS32"
00125 #define PS_TYPE_S64_NAME  "psS64"
00126 #define PS_TYPE_U8_NAME   "psU8"
00127 #define PS_TYPE_U16_NAME  "psU16"
00128 #define PS_TYPE_U32_NAME  "psU32"
00129 #define PS_TYPE_U64_NAME  "psU64"
00130 #define PS_TYPE_F32_NAME  "psF32"
00131 #define PS_TYPE_F64_NAME  "psF64"
00132 #define PS_TYPE_C32_NAME  "psC32"
00133 #define PS_TYPE_C64_NAME  "psC64"
00134 
00135 #define PS_TYPE_NAME(value,type) \
00136 switch(type) { \
00137 case PS_TYPE_BOOL: \
00138     value = PS_TYPE_BOOL_NAME; \
00139     break; \
00140 case PS_TYPE_S8: \
00141     value = PS_TYPE_S8_NAME; \
00142     break; \
00143 case PS_TYPE_S16: \
00144     value = PS_TYPE_S16_NAME; \
00145     break; \
00146 case PS_TYPE_S32: \
00147     value = PS_TYPE_S32_NAME; \
00148     break; \
00149 case PS_TYPE_S64: \
00150     value = PS_TYPE_S64_NAME; \
00151     break; \
00152 case PS_TYPE_U8: \
00153     value = PS_TYPE_U8_NAME; \
00154     break; \
00155 case PS_TYPE_U16: \
00156     value = PS_TYPE_U16_NAME; \
00157     break; \
00158 case PS_TYPE_U32: \
00159     value = PS_TYPE_U32_NAME; \
00160     break; \
00161 case PS_TYPE_U64: \
00162     value = PS_TYPE_U64_NAME; \
00163     break; \
00164 case PS_TYPE_F32: \
00165     value = PS_TYPE_F32_NAME; \
00166     break; \
00167 case PS_TYPE_F64: \
00168     value = PS_TYPE_F64_NAME; \
00169     break; \
00170 case PS_TYPE_C32: \
00171     value = PS_TYPE_C32_NAME; \
00172     break; \
00173 case PS_TYPE_C64: \
00174     value = PS_TYPE_C64_NAME; \
00175     break; \
00176 default: \
00177     value = "unknown"; \
00178 };
00179 
00180 /// Macro to get the bad pixel reason code (stored as part of mask value)
00181 #define PS_BADPIXEL_BITMASK 0x0f
00182 #define PS_GET_BADPIXEL(maskValue) (maskValue & PS_BADPIXEL_BITMASK)
00183 
00184 #define PS_IS_BADPIXEL(maskValue) (PS_GET_BADPIXEL(maskValue) != 0)
00185 
00186 /// Macro to apply a bad pixel reason code to mask image
00187 #define PS_SET_BADPIXEL(maskValue, reasonCode) \
00188 { \
00189     maskValue = (psMaskType)((reasonCode & PS_BADPIXEL_BITMASK) | (maskValue & ~PS_BADPIXEL_BITMASK)); \
00190 }
00191 
00192 /// Macro to determine if the psElemType is an integer.
00193 #define PS_IS_PSELEMTYPE_INT(x) ((x & 0x100) == 0x100)
00194 /// Macro to determine if the psElemType is unsigned.
00195 #define PS_IS_PSELEMTYPE_UNSIGNED(x) ((x & 0x200) == 0x200)
00196 /// Macro to determine if the psElemType is a real (non-complex) floating-point type.
00197 #define PS_IS_PSELEMTYPE_REAL(x) ((x & 0x400) == 0x400)
00198 /// Macro to determine if the psElemType is complex number type.
00199 #define PS_IS_PSELEMTYPE_COMPLEX(x) ((x & 0x800) == 0x800)
00200 /// Macro to determine if the psElemType is boolean type.
00201 #define PS_IS_PSELEMTYPE_BOOL(x) ((x & 0x1000) == 0x1000)
00202 /// Macro to determine the storage size, in bytes, of the psElemType.
00203 #define PSELEMTYPE_SIZEOF(x) (x & 0xFF)
00204 
00205 /** Dimensions of a data type.
00206  *
00207  * The dimensions of containers used by psLib are defined within this enum. This enum is used by the psType
00208 struct. *
00209  */
00210 typedef enum {
00211     PS_DIMEN_SCALAR,            ///< Scalar.
00212     PS_DIMEN_VECTOR,            ///< Vector.
00213     PS_DIMEN_TRANSV,            ///< Transposed vector.
00214     PS_DIMEN_IMAGE,             ///< Image.
00215     PS_DIMEN_OTHER              ///< Something else that's not supported for arithmetic.
00216 } psDimen;
00217 
00218 /** The type of a data type.
00219  *
00220  * All psLib complex types consist of primitive components. This struct provides the description of those
00221  * primitives.
00222  *
00223  */
00224 typedef struct
00225 {
00226     psElemType type;            ///< Primitive type.
00227     psDimen dimen;              ///< Dimensionality.
00228 }
00229 psType;
00230 
00231 /** The type of a basic data type
00232  *
00233  *  All psLib complex types consist of primitive components.  This structure provides the ability to cast
00234  *  an unknown data structure to safely test the underlining data type.
00235  *
00236  */
00237 typedef struct
00238 {
00239     psType  type;              ///< Data type information
00240 }
00241 psMath;
00242 
00243 /// @}
00244 
00245 #endif // #ifndef PS_TYPE_H

Generated on Wed Jun 15 11:00:57 2005 for Pan-STARRS Foundation Library by  doxygen 1.4.1