UNDER CONSTRUCTION
Reference
Home
Overview
Hardware
News
Download
License
Documentation
Reference
Help
FAQs
Contributing
Contact
Links

Types.hpp

Go to the documentation of this file.
00001 //---CREDITS
00002 // Name: Types.h
00003 // Desc: Common types and macros
00004 // Tabs: tabbed at 3
00005 //-------------------------->
00006 #ifndef ___RSLIB_TYPES___
00007 #define ___RSLIB_TYPES___
00008 
00009 
00010 //---TYPES & DEFINES
00011 // Note: Some of these types are defined exactly the same in windows
00012 //------------------------------------------------------------------>
00013 typedef char                  CHAR8,*PCHAR8;
00014 typedef signed char           INT8,*PINT8;
00015 typedef unsigned char         UINT8,*PUINT8,BYTE,*PBYTE;
00016 #ifdef _NATIVE_WCHAR_T_DEFINED
00017 typedef wchar_t               CHAR16,*PCHAR16;
00018 #else
00019    #ifdef __wchar_t
00020       typedef __wchar_t             CHAR16,*PCHAR16;
00021    #else
00022       typedef unsigned short        CHAR16,*PCHAR16;
00023    #endif   
00024 #endif
00025 typedef signed short          INT16,*PINT16;
00026 typedef unsigned short        UINT16,*PUINT16,WORD,*PWORD;
00027 typedef signed int            INT32,*PINT32;
00028 typedef unsigned int          UINT32,*PUINT32,FLAGS32,*PFLAGS32;
00029 typedef unsigned long         BOOL32,*PBOOL32;
00030 typedef unsigned long         DWORD,*PDWORD;
00031 typedef signed __int64        INT64, *PINT64;
00032 typedef unsigned __int64      UINT64, *PUINT64,QWORD,*PQWORD;
00033 typedef float                 FLT32,*PFLT32;
00034 typedef double                FLT64,*PFLT64;
00035 typedef void                  *PVOID;
00036 typedef unsigned long int     PTR32,*PPTR32;
00037 
00038 #define VIRTUAL virtual
00039 
00040 
00041 //---WINDOWS DUPLICATES
00042 // Note: do not change. they are defined exactly in this way inside windows headers
00043 //--------------------------------------------------------------------------------->
00044 #define PURE = 0
00045 #define NULL 0
00046 
00047 #define FALSE   0
00048 #define TRUE    1
00049 
00050 //windows.h contains this whole block...
00051 //so defining VOID alone would leave undefined CHAR,SHORT and LONG
00052 //creating a deadly tragedy if this header is thrown in before windows.h
00053 #ifndef VOID
00054    #define VOID void
00055    typedef char CHAR;
00056    typedef short SHORT;
00057    typedef long LONG;
00058 #endif
00059 
00060 #ifndef _WINERROR_
00061    typedef LONG HRESULT;
00062    #define SUCCEEDED(Status) ((HRESULT)(Status) >= 0)
00063    #define FAILED(Status) ((HRESULT)(Status)<0)
00064 #endif
00065  
00066  
00067 //---MACROS & TEMPLATES
00068 //-------------------------------------------------------------------->
00069 #define ARRAY_ITEMS(array)             (sizeof(array)/sizeof(array[0]))
00070 #define ARRAY_BYTES(array)             (sizeof(array))
00071 #define CAST(type,expression)          ((type)(expression))
00072 #define SEEAS(type,object)             (*(type*)(void*)&(object))
00073 #define REFERABLE_AS(type)             (RSLib::ReferableTempObject<type>)
00074 #define UNREFERENCED_PARAM(x)          x
00075 #define BRES_TO_URES(bRes)             ((bRes) ? 0x0000000 : 0x80000000)
00076  
00077  
00078  
00079 namespace RSLib {
00080 
00081 template<class T,class O> T& SeeAs(O& o){return *(T*)&o;}
00082 template <typename T> class ReferableTempObject
00083 {
00084    public:
00085    T x;
00086    
00087    public:
00088    ReferableTempObject(T t){x = t;}
00089    
00090    public:
00091    operator T&(){return x;}
00092 };
00093 
00094 
00095 }//namespace RSLib
00096 
00097  
00098  
00099 //---PARAMETERS TYPE
00100 //------------------->
00101 #define IN
00102 #define OUT
00103 
00104 
00105 //---EXCEPTION HANDLING
00106 //--------------------->
00107 #define BEGINTRYBLOCK try{
00108 #define BEGINCATCHBLOCK(x) }catch(x){
00109 #define ENDCATCHBLOCK }
00110  
00111 
00112 #define ABS(a) ( (a)> 0  ? (a) : (-(a)) )
00113 #define MIN(a,b) ( (a)<(b) ? (a) : (b) )
00114 #define MAX(a,b) ( (a)>(b) ? (a) : (b) )
00115 #define MAX3(a,b,c) (MAX(MAX(a,b),c))
00116 #define MIN3(a,b,c) (MIN(MIN(a,b),c))
00117 #define CLAMP(x,a,b) ((x) < (a)? (a) : ( (x) > (b) ? (b) : (x) ) )
00118  
00119  
00120  
00121 //---INPLACE CONSTRUCTOR & DESTRUCTOR
00122 // Samp: CONSTRUCT(Vector3,normal);
00123 //       CONSTRUCT(Vector3,normal)(1,1,1);
00124 //       DESTRUCT(Vector3,normal);
00125 //------------------------------------------------->
00126 #define CONSTRUCT(class,object) new (&object) class
00127 #define DESTRUCT(class,object) object.~class()
00128  
00129  
00130  
00131 //---ASSEMBLY CODING
00132 //----------------------------->
00133 #define BEGIN_ASSEMBLY __asm {
00134 #define ASSEMBLY __asm
00135 #define END_ASSEMBLY }
00136  
00137  
00138 #endif//___RSLIB_TYPES___
Last Updated on 2006/02/01 09:53:39 UTC info@haptiklibrary.org