Main Page | Class Hierarchy | Class List | File List | Class Members

Basic.h

00001 /**************************************************************************\ 00002 * 00003 * FILE: Basic.h 00004 * 00005 * This source file is part of DIME. 00006 * Copyright (C) 1998-1999 by Systems In Motion. All rights reserved. 00007 * 00008 * This library is free software; you can redistribute it and/or modify it 00009 * under the terms of the GNU General Public License, version 2, as 00010 * published by the Free Software Foundation. 00011 * 00012 * This library is distributed in the hope that it will be useful, but 00013 * WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * General Public License (the accompanying file named COPYING) for more 00016 * details. 00017 * 00018 ************************************************************************** 00019 * 00020 * If you need DIME for a non-GPL project, contact Systems In Motion 00021 * to acquire a Professional Edition License: 00022 * 00023 * Systems In Motion http://www.sim.no/ 00024 * Prof. Brochs gate 6 sales@sim.no 00025 * N-7030 Trondheim Voice: +47 22114160 00026 * NORWAY Fax: +47 67172912 00027 * 00028 \**************************************************************************/ 00029 00030 #ifndef DIME_BASIC_H 00031 #define DIME_BASIC_H 00032 00033 #include <stdlib.h> 00034 #include <stdio.h> 00035 #include <stdarg.h> 00036 #include <string.h> 00037 #include <assert.h> 00038 #include <math.h> 00039 00040 // we prefer to use floats to save mem. Applications needing 00041 // scientific calculations should typedef this to double 00042 typedef float dxfdouble; 00043 00044 #ifdef _WIN32 00045 #include "float.h" 00046 #define M_PI 3.14159265357989 00047 #endif 00048 00049 #define DXFABS(x) ((x)<0?-(x):(x)) 00050 #define DXFMAX(x,y) ((x)>(y)?(x):(y)) 00051 #define DXFMIN(x,y) ((x)<(y)?(x):(y)) 00052 #define DXFDEG2RAD(x) (M_PI*(x)/180.0) 00053 #define DXFRAD2DEG(x) (180.0*(x)/M_PI) 00054 00055 00056 #ifdef __sgi 00057 #define bool int 00058 #define true 1 00059 #define false 0 00060 #endif // __sgi 00061 00062 00063 template <class T> inline 00064 T DXFSQR(const T x) 00065 { 00066 return x*x; 00067 } 00068 00069 #if defined(__BEOS__) 00070 #include <support/SupportDefs.h> 00071 #else // ! defined(__BEOS__) 00072 typedef signed char int8; 00073 typedef unsigned char uint8; 00074 typedef signed short int16; 00075 typedef unsigned short uint16; 00076 #ifdef _WIN32 00077 typedef long int32; 00078 #else // ! defined(_WIN32) 00079 typedef signed int int32; 00080 #endif // ! defined(_WIN32) 00081 typedef unsigned int uint32; 00082 #endif // ! defined(__BEOS__) 00083 00084 #ifdef macintosh 00085 char* strdup( const char* ); 00086 #endif 00087 00088 #define ARRAY_NEW(memh, type, num) \ 00089 memh ? (type*) memh->allocMem((num)*sizeof(type)) : new type[num] 00090 00091 #define DXF_STRCPY(mh, d, s) \ 00092 mh ? d = mh->stringAlloc(s) : d = new char[strlen(s)+1]; if (d) strcpy(d,s) 00093 00094 typedef bool dimeCallbackFunc(const class dimeState * const, class dimeEntity *, void *); 00095 typedef dimeCallbackFunc * dimeCallback; 00096 00097 typedef union { 00098 int8 int8_data; 00099 int16 int16_data; 00100 int32 int32_data; 00101 float float_data; 00102 dxfdouble double_data; 00103 const char *string_data; 00104 const char *hex_data; 00105 } dimeParam; 00106 00107 /* ********************************************************************** */ 00108 /* Precaution to avoid an some errors easily made by the application 00109 programmer. */ 00110 00111 #ifdef DIME_DLL_API 00112 # error Leave the internal DIME_DLL_API define alone. 00113 #endif /* DIME_DLL_API */ 00114 #ifdef DIME_INTERNAL 00115 # ifdef DIME_NOT_DLL 00116 # error The DIME_NOT_DLL define is not supposed to be used when building the library, only when building Win32 applications. 00117 # endif /* DIME_INTERNAL && DIME_NOT_DLL */ 00118 # ifdef DIME_DLL 00119 # error The DIME_DLL define is not supposed to be used when building the library, only when building Win32 applications. 00120 # endif /* DIME_INTERNAL && DIME_DLL */ 00121 #endif /* DIME_INTERNAL */ 00122 00123 /* 00124 On MSWindows platforms, one of these defines must always be set when 00125 building application programs: 00126 00127 - "DIME_DLL", when the application programmer is using the library 00128 in the form of a dynamic link library (DLL) 00129 00130 - "DIME_NOT_DLL", when the application programmer is using the 00131 library in the form of a static object library (LIB) 00132 00133 Note that either DIME_DLL or DIME_NOT_DLL _must_ be defined by the 00134 application programmer on MSWindows platforms, or else the #error 00135 statement will hit. Set up one or the other of these two defines in 00136 your compiler environment according to how the library was built -- 00137 as a DLL (use "DIME_DLL") or as a LIB (use "DIME_NOT_DLL"). 00138 00139 (Setting up defines for the compiler is typically done by either 00140 adding something like "/DDIME_DLL" to the compiler's argument line 00141 (for command-line build processes), or by adding the define to the 00142 list of preprocessor symbols in your IDE GUI (in the MSVC IDE, this 00143 is done from the "Project"->"Settings" menu, choose the "C/C++" tab, 00144 then "Preprocessor" from the dropdown box and add the appropriate 00145 define)). 00146 00147 It is extremely important that the application programmer uses the 00148 correct define, as using "DIME_NOT_DLL" when "DIME_DLL" is correct 00149 will cause mysterious crashes. 00150 */ 00151 /* FIXME: use a feature check to see if this is a platform which can 00152 recognize the __declspec keyword instead of the crap #if below. 00153 20011201 mortene. */ 00154 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) 00155 # ifdef DIME_INTERNAL 00156 # ifdef DIME_MAKE_DLL 00157 # define DIME_DLL_API __declspec(dllexport) 00158 # endif /* DIME_MAKE_DLL */ 00159 # else /* !DIME_INTERNAL */ 00160 # ifdef DIME_DLL 00161 # ifdef DIME_NOT_DLL 00162 # error Do not define both DIME_DLL and DIME_NOT_DLL at the same time 00163 # endif 00164 # define DIME_DLL_API __declspec(dllimport) 00165 # else /* !DIME_DLL */ 00166 # ifndef DIME_NOT_DLL 00167 # error Define either DIME_DLL or DIME_NOT_DLL as appropriate for your linkage! See dime/Basic.h for further instructions. 00168 # endif /* DIME_NOT_DLL */ 00169 # endif /* !DIME_DLL */ 00170 # endif /* !DIME_INTERNAL */ 00171 #endif /* Microsoft Windows */ 00172 00173 /* Empty define to avoid errors when _not_ compiling an MSWindows DLL. */ 00174 #ifndef DIME_DLL_API 00175 # define DIME_DLL_API 00176 #endif /* !DIME_DLL_API */ 00177 00178 /* ********************************************************************** */ 00179 00180 #endif // !DIME_BASIC_H

Copyright © 1998-1999, Systems In Motion <sales@sim.no>. All rights reserved.
System documentation was generated using doxygen.