Wavelet and Image class library  1.3.2
miscdefs.h
Go to the documentation of this file.
00001 /*
00002  * Miscellanous type definitions etc...
00003  *
00004  * $Date$
00005  * $Revision$
00006  *
00007  */
00008 
00009 #ifndef MISCDEFS_H__
00010 #define MISCDEFS_H__
00011 
00015 #include <cfloat>
00016 #include <stdexcept>
00017 #include <string>
00018 #ifndef _WIN32_WCE
00019 #include <iostream>
00020 #else
00021 /* we disable this warning because there is a macro DELETE in the Windows
00022  * CE toolkit which we just overwrite */
00023 #pragma warning (disable: 4005)
00024 #endif
00025 
00026 #ifndef NEW
00027 #define NEW(a)       new a
00028 #endif
00029 #ifndef DELETE
00030 #define DELETE(a)    delete (a), (a) = NULL
00031 #endif
00032 #ifndef DELETEAR
00033 #define DELETEAR(a)  delete [] (a), (a) = NULL
00034 #endif
00035 #ifndef DELETENOTNULL
00036 #define DELETENOTNULL(a) if (a) { DELETE (a); } else {}
00037 #endif
00038 #ifndef DELETENOTNULLAR
00039 #define DELETENOTNULLAR(a) if (a) { DELETEAR (a); } else {}
00040 #endif
00041 
00044 typedef unsigned char pixel;
00047 typedef double        coeff;
00048 
00051 #define COEFF_EPSILON ((coeff)DBL_EPSILON)
00052 
00054 #define COEFF_MAX ((coeff)DBL_MAX)
00055 
00057 #define COEFF_MIN ((coeff)DBL_MIN)
00058 
00060 #define MIN(x,y) ((x) < (y)? (x): (y))
00061 
00063 #define MAX(x,y) ((x) > (y)? (x): (y))
00064 
00066 #define DIV2(x) ((unsigned)(x)>>1u)
00067 
00069 #define MUL2(x) ((unsigned)(x)<<1u)
00070 
00072 #define TWOPOW(n) (1u<<(unsigned)(n))
00073 
00074 #define SQUARE(n) ((n)*(n))
00075 
00077 #if defined (__GNUG__) && __GNUG__ >= 3 || defined (__INTEL_COMPILER)
00078 #define FMT0 std::ios_base::fmtflags(0)
00079 #else
00080 #define FMT0 0
00081 #endif
00082 
00086 typedef enum { LL = 0, HL, LH, HH, areaINVALID } area;
00087 
00089 extern const area areas [areaINVALID]; /*= { LL, HL, LH, HH };*/
00090 
00092 typedef enum { cm_rgb, cm_yuv, cm_grey, cm_unknown } clrmodel;
00093 
00095 typedef enum { yuv_y = 0, yuv_u, yuv_v, yuv_unknown } yuv;
00096 
00098 typedef enum { rgb_r = 0, rgb_g, rgb_b, rgb_unknown } rgb;
00099 
00100 #if defined __WATCOMC__ || defined __GNUC__ && __GNUC__ < 3
00101 #define HAS_NO_IOS_BASE
00102 #endif
00103 
00104 #ifdef HAS_NO_IOS_BASE
00105 // Some wrapping for Watcom C++ (does not yet include a full STL)
00106 namespace ios_base {
00107   class failure : public std::logic_error {
00108   public:
00109     failure (std::string const& what_arg)
00110       : logic_error( what_arg ) {
00111                     }
00112   };
00113   //#define ios_base::app ios::append
00114 
00115   enum open_mode {                  // How to open a stream
00116     in        = std::ios::in,            // - open for input
00117     out       = std::ios::out,           // - open for output
00118     nocreate  = std::ios::nocreate,      // - open only an existing file
00119     noreplace = std::ios::noreplace,     // - open only a new file
00120     binary    = std::ios::binary,        // - open as binary file
00121 
00122     app       = std::ios::app,           // Historical purposes
00123     ate       = std::ios::ate,
00124     trunc     = std::ios::trunc
00125   };
00126 }
00127 #endif
00128 
00131 #endif /* MISCDEFS_H__ */
00132 
00133 /* We put this outside the recursion stopper to allow overriding
00134  * defines set by some microsoft environments */
00135 #if defined _MSC_VER || defined __WATCOMC__ || defined _WIN32_WCE
00136 
00140 # define for if(0);else for
00141 # ifdef DELETE
00142 #  undef DELETE
00143 # endif
00144 # define DELETE(a)    delete (a), (a) = NULL
00145 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines