IceTypes.h
Go to the documentation of this file.
00001 
00002 
00008 
00009 
00011 // Include Guard
00012 #ifndef __ICETYPES_H__
00013 #define __ICETYPES_H__
00014 
00016 // Things to help us compile on non-windows platforms
00017 #if 0
00018 #if defined(__MACOSX__) || defined(__APPLE__)
00019 #undef bool
00020 #define bool char
00021 #undef true
00022 #define true ((bool)-1)
00023 #undef false
00024 #define false ((bool)0)
00025 #endif // mac stuff
00026 #endif
00027 
00028 
00029         #define USE_HANDLE_MANAGER
00030 
00031         // Constants
00032         #define PI                                      3.1415926535897932384626433832795028841971693993751f    //!< PI
00033         #define HALFPI                          1.57079632679489661923f                                                                 //!< 0.5 * PI
00034         #define TWOPI                           6.28318530717958647692f                                                                 //!< 2.0 * PI
00035         #define INVPI                           0.31830988618379067154f                                                                 //!< 1.0 / PI
00036 
00037         #define RADTODEG                        57.2957795130823208768f                                                                 //!< 180.0 / PI, convert radians to degrees
00038         #define DEGTORAD                        0.01745329251994329577f                                                                 //!< PI / 180.0, convert degrees to radians
00039 
00040         #define EXP                                     2.71828182845904523536f                                                                 //!< e
00041         #define INVLOG2                         3.32192809488736234787f                                                                 //!< 1.0 / log10(2)
00042         #define LN2                                     0.693147180559945f                                                                              //!< ln(2)
00043         #define INVLN2                          1.44269504089f                                                                                  //!< 1.0f / ln(2)
00044 
00045         #define INV3                            0.33333333333333333333f                                                                 //!< 1/3
00046         #define INV6                            0.16666666666666666666f                                                                 //!< 1/6
00047         #define INV7                            0.14285714285714285714f                                                                 //!< 1/7
00048         #define INV9                            0.11111111111111111111f                                                                 //!< 1/9
00049         #define INV255                          0.00392156862745098039f                                                                 //!< 1/255
00050 
00051         #define SQRT2                           1.41421356237f                                                                                  //!< sqrt(2)
00052         #define INVSQRT2                        0.707106781188f                                                                                 //!< 1 / sqrt(2)
00053 
00054         #define SQRT3                           1.73205080757f                                                                                  //!< sqrt(3)
00055         #define INVSQRT3                        0.577350269189f                                                                                 //!< 1 / sqrt(3)
00056 
00057         #define null                            0                                                                                                               //!< our own NULL pointer
00058 
00059         // Custom types used in ICE
00060         typedef signed char                     sbyte;          
00061         typedef unsigned char           ubyte;          
00062         typedef signed short            sword;          
00063         typedef unsigned short          uword;          
00064         typedef signed int                      sdword;         
00065         typedef unsigned int            udword;         
00066         typedef signed __int64          sqword;         
00067         typedef unsigned __int64        uqword;         
00068         typedef float                           float32;        
00069         typedef double                          float64;        
00070 
00071         ICE_COMPILE_TIME_ASSERT(sizeof(bool)==1);       // ...otherwise things might fail with VC++ 4.2 !
00072         ICE_COMPILE_TIME_ASSERT(sizeof(ubyte)==1);
00073         ICE_COMPILE_TIME_ASSERT(sizeof(sbyte)==1);
00074         ICE_COMPILE_TIME_ASSERT(sizeof(sword)==2);
00075         ICE_COMPILE_TIME_ASSERT(sizeof(uword)==2);
00076         ICE_COMPILE_TIME_ASSERT(sizeof(udword)==4);
00077         ICE_COMPILE_TIME_ASSERT(sizeof(sdword)==4);
00078         ICE_COMPILE_TIME_ASSERT(sizeof(uqword)==8);
00079         ICE_COMPILE_TIME_ASSERT(sizeof(sqword)==8);
00080 
00082         #define DECLARE_ICE_HANDLE(name)        struct name##__ { int unused; }; typedef struct name##__ *name
00083 
00084         typedef udword                          DynID;          
00085 #ifdef USE_HANDLE_MANAGER
00086         typedef udword                          KID;            
00087 //      DECLARE_ICE_HANDLE(KID);
00088 #else
00089         typedef uword                           KID;            
00090 #endif
00091         typedef udword                          RTYPE;          
00092         #define INVALID_ID                      0xffffffff      //!< Invalid dword ID (counterpart of null pointers)
00093 #ifdef USE_HANDLE_MANAGER
00094         #define INVALID_KID                     0xffffffff      //!< Invalid Kernel ID
00095 #else
00096         #define INVALID_KID                     0xffff          //!< Invalid Kernel ID
00097 #endif
00098         #define INVALID_NUMBER          0xDEADBEEF      //!< Standard junk value
00099 
00100         // Define BOOL if needed
00101         #ifndef BOOL
00102         typedef int     BOOL;                                           
00103         #endif
00104 
00106         typedef union {
00107                 float   f;                                                      
00108                 sdword  d;                                                      
00109         }scell;
00110 
00112         typedef union {
00113                 float   f;                                                      
00114                 udword  d;                                                      
00115         }ucell;
00116 
00117         // Type ranges
00118         #define MAX_SBYTE                               0x7f                                            //!< max possible sbyte value
00119         #define MIN_SBYTE                               0x80                                            //!< min possible sbyte value
00120         #define MAX_UBYTE                               0xff                                            //!< max possible ubyte value
00121         #define MIN_UBYTE                               0x00                                            //!< min possible ubyte value
00122         #define MAX_SWORD                               0x7fff                                          //!< max possible sword value
00123         #define MIN_SWORD                               0x8000                                          //!< min possible sword value
00124         #define MAX_UWORD                               0xffff                                          //!< max possible uword value
00125         #define MIN_UWORD                               0x0000                                          //!< min possible uword value
00126         #define MAX_SDWORD                              0x7fffffff                                      //!< max possible sdword value
00127         #define MIN_SDWORD                              0x80000000                                      //!< min possible sdword value
00128         #define MAX_UDWORD                              0xffffffff                                      //!< max possible udword value
00129         #define MIN_UDWORD                              0x00000000                                      //!< min possible udword value
00130         #define MAX_FLOAT                               FLT_MAX                                         //!< max possible float value
00131         #define MIN_FLOAT                               (-FLT_MAX)                                      //!< min possible loat value
00132         #define IEEE_1_0                                0x3f800000                                      //!< integer representation of 1.0
00133         #define IEEE_255_0                              0x437f0000                                      //!< integer representation of 255.0
00134         #define IEEE_MAX_FLOAT                  0x7f7fffff                                      //!< integer representation of MAX_FLOAT
00135         #define IEEE_MIN_FLOAT                  0xff7fffff                                      //!< integer representation of MIN_FLOAT
00136         #define IEEE_UNDERFLOW_LIMIT    0x1a000000
00137 
00138         #define ONE_OVER_RAND_MAX               (1.0f / float(RAND_MAX))        //!< Inverse of the max possible value returned by rand()
00139 
00140         typedef int                                     (__stdcall* PROC)();                    
00141         typedef bool                            (*ENUMERATION)(udword value, udword param, udword context);     
00142         typedef void**                          VTABLE;                                                 
00143 
00144         #undef          MIN
00145         #undef          MAX
00146         #define         MIN(a, b)       ((a) < (b) ? (a) : (b))                 //!< Returns the min value between a and b
00147         #define         MAX(a, b)       ((a) > (b) ? (a) : (b))                 //!< Returns the max value between a and b
00148         #define         MAXMAX(a,b,c)   ((a) > (b) ? MAX (a,c) : MAX (b,c))     //!<    Returns the max value between a, b and c
00149 
00150         template<class T>       inline_ const T&        TMin    (const T& a, const T& b)        { return b < a ? b : a; }
00151         template<class T>       inline_ const T&        TMax    (const T& a, const T& b)        { return a < b ? b : a; }
00152         template<class T>       inline_ void            TSetMin (T& a, const T& b)                      { if(a>b)       a = b;          }
00153         template<class T>       inline_ void            TSetMax (T& a, const T& b)                      { if(a<b)       a = b;          }
00154 
00155         #define         SQR(x)                  ((x)*(x))                                               //!< Returns x square
00156         #define         CUBE(x)                 ((x)*(x)*(x))                                   //!< Returns x cube
00157 
00158         #define         AND             &                                                                               //!< ...
00159         #define         OR              |                                                                               //!< ...
00160         #define         XOR             ^                                                                               //!< ...
00161 
00162         #define         QUADRAT(x)              ((x)*(x))                                               //!< Returns x square
00163 
00164 #ifdef _WIN32
00165 #   define srand48(x) srand((unsigned int) (x))
00166 #       define srandom(x) srand((unsigned int) (x))
00167 #       define random()   ((double) rand())
00168 #   define drand48()  ((double) (((double) rand()) / ((double) RAND_MAX)))
00169 #endif
00170 
00171 #endif // __ICETYPES_H__


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sun Apr 2 2017 03:43:54