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/09/14 20:42: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 #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 /** 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_S32  = PS_TYPE_S32,        ///< psS32
00101     PS_DATA_F32  = PS_TYPE_F32,        ///< psF32
00102     PS_DATA_F64  = PS_TYPE_F64,        ///< psF64
00103     PS_DATA_BOOL = PS_TYPE_BOOL,       ///< psBool
00104     PS_DATA_STRING = 0x10000,          ///< psString (char *)
00105     PS_DATA_ARRAY,                     ///< psArray
00106     PS_DATA_BITSET,                    ///< psBitSet
00107     PS_DATA_CELL,                      ///< psCell
00108     PS_DATA_CHIP,                      ///< psChip
00109     PS_DATA_CUBE,                      ///< psCube
00110     PS_DATA_FITS,                      ///< psFits
00111     PS_DATA_HASH,                      ///< psHash
00112     PS_DATA_HISTOGRAM,                 ///< psHistogram
00113     PS_DATA_IMAGE,                     ///< psImage
00114     PS_DATA_KERNEL,                    ///< psKernel
00115     PS_DATA_LIST,                      ///< psList
00116     PS_DATA_LOOKUPTABLE,               ///< psLookupTable
00117     PS_DATA_METADATA,                  ///< psMetadata
00118     PS_DATA_METADATAITEM,              ///< psMetadataItem
00119     PS_DATA_MINIMIZATION,              ///< psMinimization
00120     PS_DATA_PIXELS,                    ///< psPixels
00121     PS_DATA_PLANE,                     ///< psPlane
00122     PS_DATA_PLANEDISTORT,              ///< psPlaneDistort
00123     PS_DATA_PLANETRANSFORM,            ///< psPlaneTransform
00124     PS_DATA_POLYNOMIAL1D,              ///< psPolynomial1D
00125     PS_DATA_POLYNOMIAL2D,              ///< psPolynomial2D
00126     PS_DATA_POLYNOMIAL3D,              ///< psPolynomial3D
00127     PS_DATA_POLYNOMIAL4D,              ///< psPolynomial4D
00128     PS_DATA_PROJECTION,                ///< psProjection
00129     PS_DATA_READOUT,                   ///< psReadout
00130     PS_DATA_REGION,                    ///< psRegion
00131     PS_DATA_SCALAR,                    ///< psScalar
00132     PS_DATA_SPHERE,                    ///< psSphere
00133     PS_DATA_SPHEREROT,                 ///< psSphereTransform
00134     PS_DATA_SPLINE1D,                  ///< psSpline1D
00135     PS_DATA_STATS,                     ///< psStats
00136     PS_DATA_TIME,                      ///< psTime
00137     PS_DATA_VECTOR,                    ///< psVector
00138     PS_DATA_UNKNOWN,                   ///< Other data of an unknown type
00139     PS_DATA_METADATA_MULTI             ///< Used internally for metadata; not a 'real' type
00140 } psDataType;
00141 
00142 #define PS_TYPE_MASK PS_TYPE_U8        /**< the psElemType to use for mask image */
00143 #define PS_TYPE_MASK_DATA U8           /**< the data member to use for mask image */
00144 #define PS_TYPE_MASK_NAME "psU8"       /**< the data type for mask as a string */
00145 
00146 typedef psU8 psMaskType;               ///< the C datatype for a mask image
00147 typedef psBool psBOOL;                 ///< allow psBOOL to be used instead of psBool (for macros)
00148 
00149 #define PS_MIN_S8        INT8_MIN      /**< minimum valid psS8 value */
00150 #define PS_MIN_S16       INT16_MIN     /**< minimum valid psS16 value */
00151 #define PS_MIN_S32       INT32_MIN     /**< minimum valid psS32 value */
00152 #define PS_MIN_S64       INT64_MIN     /**< minimum valid psS64 value */
00153 #define PS_MIN_U8        0             /**< minimum valid psU8 value */
00154 #define PS_MIN_U16       0             /**< minimum valid psU16 value */
00155 #define PS_MIN_U32       0             /**< minimum valid psU32 value */
00156 #define PS_MIN_U64       0             /**< minimum valid psU64 value */
00157 #define PS_MIN_F32       -FLT_MAX      /**< minimum valid psF32 value */
00158 #define PS_MIN_F64       -DBL_MAX      /**< minimum valid psF64 value */
00159 #define PS_MIN_C32       -FLT_MAX      /**< minimum valid real or imaginary psC32 value */
00160 #define PS_MIN_C64       -DBL_MAX      /**< minimum valid real or imaginary psC32 value */
00161 
00162 #define PS_MAX_S8        INT8_MAX      /**< maximum valid psS8 value */
00163 #define PS_MAX_S16       INT16_MAX     /**< maximum valid psS16 value */
00164 #define PS_MAX_S32       INT32_MAX     /**< maximum valid psS32 value */
00165 #define PS_MAX_S64       INT64_MAX     /**< maximum valid psS64 value */
00166 #define PS_MAX_U8        UINT8_MAX     /**< maximum valid psU8 value */
00167 #define PS_MAX_U16       UINT16_MAX    /**< maximum valid psU16 value */
00168 #define PS_MAX_U32       UINT32_MAX    /**< maximum valid psU32 value */
00169 #define PS_MAX_U64       UINT64_MAX    /**< maximum valid psU64 value */
00170 #define PS_MAX_F32       FLT_MAX       /**< maximum valid psF32 value */
00171 #define PS_MAX_F64       DBL_MAX       /**< maximum valid psF64 value */
00172 #define PS_MAX_C32       FLT_MAX       /**< maximum valid real or imaginary psC32 value */
00173 #define PS_MAX_C64       DBL_MAX       /**< maximum valid real or imaginary psC32 value */
00174 
00175 #define PS_TYPE_BOOL_NAME "psBool"
00176 #define PS_TYPE_S8_NAME   "psS8"
00177 #define PS_TYPE_S16_NAME  "psS16"
00178 #define PS_TYPE_S32_NAME  "psS32"
00179 #define PS_TYPE_S64_NAME  "psS64"
00180 #define PS_TYPE_U8_NAME   "psU8"
00181 #define PS_TYPE_U16_NAME  "psU16"
00182 #define PS_TYPE_U32_NAME  "psU32"
00183 #define PS_TYPE_U64_NAME  "psU64"
00184 #define PS_TYPE_F32_NAME  "psF32"
00185 #define PS_TYPE_F64_NAME  "psF64"
00186 #define PS_TYPE_C32_NAME  "psC32"
00187 #define PS_TYPE_C64_NAME  "psC64"
00188 
00189 #define PS_TYPE_NAME(value,type) \
00190 switch(type) { \
00191 case PS_TYPE_BOOL: \
00192     value = PS_TYPE_BOOL_NAME; \
00193     break; \
00194 case PS_TYPE_S8: \
00195     value = PS_TYPE_S8_NAME; \
00196     break; \
00197 case PS_TYPE_S16: \
00198     value = PS_TYPE_S16_NAME; \
00199     break; \
00200 case PS_TYPE_S32: \
00201     value = PS_TYPE_S32_NAME; \
00202     break; \
00203 case PS_TYPE_S64: \
00204     value = PS_TYPE_S64_NAME; \
00205     break; \
00206 case PS_TYPE_U8: \
00207     value = PS_TYPE_U8_NAME; \
00208     break; \
00209 case PS_TYPE_U16: \
00210     value = PS_TYPE_U16_NAME; \
00211     break; \
00212 case PS_TYPE_U32: \
00213     value = PS_TYPE_U32_NAME; \
00214     break; \
00215 case PS_TYPE_U64: \
00216     value = PS_TYPE_U64_NAME; \
00217     break; \
00218 case PS_TYPE_F32: \
00219     value = PS_TYPE_F32_NAME; \
00220     break; \
00221 case PS_TYPE_F64: \
00222     value = PS_TYPE_F64_NAME; \
00223     break; \
00224 case PS_TYPE_C32: \
00225     value = PS_TYPE_C32_NAME; \
00226     break; \
00227 case PS_TYPE_C64: \
00228     value = PS_TYPE_C64_NAME; \
00229     break; \
00230 default: \
00231     value = "unknown"; \
00232 };
00233 
00234 /// Macro to get the bad pixel reason code (stored as part of mask value)
00235 #define PS_BADPIXEL_BITMASK 0x0f
00236 #define PS_GET_BADPIXEL(maskValue) (maskValue & PS_BADPIXEL_BITMASK)
00237 
00238 #define PS_IS_BADPIXEL(maskValue) (PS_GET_BADPIXEL(maskValue) != 0)
00239 
00240 /// Macro to apply a bad pixel reason code to mask image
00241 #define PS_SET_BADPIXEL(maskValue, reasonCode) \
00242 { \
00243     maskValue = (psMaskType)((reasonCode & PS_BADPIXEL_BITMASK) | (maskValue & ~PS_BADPIXEL_BITMASK)); \
00244 }
00245 
00246 /// Macro to determine if the psElemType is an integer.
00247 #define PS_IS_PSELEMTYPE_INT(x) ((x & 0x100) == 0x100)
00248 /// Macro to determine if the psElemType is unsigned.
00249 #define PS_IS_PSELEMTYPE_UNSIGNED(x) ((x & 0x200) == 0x200)
00250 /// Macro to determine if the psElemType is a real (non-complex) floating-point type.
00251 #define PS_IS_PSELEMTYPE_REAL(x) ((x & 0x400) == 0x400)
00252 /// Macro to determine if the psElemType is complex number type.
00253 #define PS_IS_PSELEMTYPE_COMPLEX(x) ((x & 0x800) == 0x800)
00254 /// Macro to determine if the psElemType is boolean type.
00255 #define PS_IS_PSELEMTYPE_BOOL(x) ((x & 0x1000) == 0x1000)
00256 /// Macro to determine the storage size, in bytes, of the psElemType.
00257 #define PSELEMTYPE_SIZEOF(x) (x & 0xFF)
00258 
00259 /** Dimensions of a data type.
00260  *
00261  * The dimensions of containers used by psLib are defined within this enum. This enum is used by the psType
00262 struct. *
00263  */
00264 typedef enum {
00265     PS_DIMEN_SCALAR,            ///< Scalar.
00266     PS_DIMEN_VECTOR,            ///< Vector.
00267     PS_DIMEN_TRANSV,            ///< Transposed vector.
00268     PS_DIMEN_IMAGE,             ///< Image.
00269     PS_DIMEN_OTHER              ///< Something else that's not supported for arithmetic.
00270 } psDimen;
00271 
00272 /** The type of a data type.
00273  *
00274  * All psLib complex types consist of primitive components. This struct provides the description of those
00275  * primitives.
00276  *
00277  */
00278 typedef struct
00279 {
00280     psElemType type;                   ///< Primitive type.
00281     psDimen dimen;                     ///< Dimensionality.
00282 }
00283 psType;
00284 
00285 typedef struct
00286 {
00287     psElemType type;                   ///< The type
00288     psDimen dimen;                     ///< The dimensionality.
00289 }
00290 psMathType;
00291 
00292 /** The type of a basic data type
00293  *
00294  *  All psLib complex types consist of primitive components.  This structure provides the ability to cast
00295  *  an unknown data structure to safely test the underlining data type.
00296  *
00297  */
00298 typedef struct
00299 {
00300     psMathType type;              ///< Data type information
00301 }
00302 psMath;
00303 
00304 /// @}
00305 
00306 #endif // #ifndef PS_TYPE_H

Generated on Wed Sep 14 10:42:48 2005 for Pan-STARRS Foundation Library by  doxygen 1.4.2