00001 /* src/Inventor/Qt/SoQtBasic.h. Generated automatically by configure. */ 00002 /************************************************************************** 00003 * 00004 * This file is part of the Coin GUI binding libraries. 00005 * Copyright (C) 2000 by Systems in Motion. All rights reserved. 00006 * 00007 * The libraries this file is part of is free software; you can 00008 * redistribute them and/or modify them under the terms of the GNU 00009 * Lesser General Public License version 2.1 as published by the 00010 * Free Software Foundation. See the file LICENSE.LGPL at the root 00011 * directory of the distribution for all the details. 00012 * 00013 * If you want to use the Coin GUI binding libraries for applications 00014 * not compatible with the LGPL, contact SIM about acquiring a 00015 * Professional Edition License. 00016 * 00017 * Systems in Motion, Prof Brochs gate 6, N-7030 Trondheim, NORWAY 00018 * http://www.sim.no/ support@sim.no Voice: +47 22114160 Fax: +47 22207097 00019 * 00020 **************************************************************************/ 00021 00022 // Generated automatically from SoGuiBasic.h.in by configure. 00023 // $Id: SoGuiBasic.h.in,v 1.23 2002/01/26 19:11:24 larsa Exp $ 00024 00025 #ifndef SOQT_BASIC_H 00026 #define SOQT_BASIC_H 00027 00028 // ************************************************************************* 00029 00030 /* For the Doxygen tool. */ 00031 /* FIXME: these Doxygen "tags" should be moved to an internal 00032 headerfile. 20010810 mortene. */ 00033 00042 // ************************************************************************* 00043 00044 /* Some useful inline template functions (instead of macros): 00045 * SoQtMin(Val1, Val2) - returns minimum value 00046 * SoQtMax(Val1, Val2) - returns maximum value 00047 * SoQtClamp(Val, Min, Max) - returns clamped value 00048 * SoQtSwap(Val1, Val2) - swaps the two values (no return value) 00049 * 00050 * FIXME: write Doxygen doc for these methods. 20010810 mortene. 00051 */ 00052 00053 template <class Type> 00054 inline Type SoQtAbs(Type Val) { 00055 return (Val < 0) ? -Val : Val; 00056 } 00057 00058 template <class Type> 00059 inline Type SoQtMin(Type a, Type b) { 00060 return (b < a) ? b : a; 00061 } 00062 00063 template <class Type> 00064 inline Type SoQtMax(Type a, Type b) { 00065 return (b > a) ? b : a; 00066 } 00067 00068 template <class Type> 00069 inline Type SoQtClamp(Type val, Type min, Type max) { 00070 return SoQtMax(min, SoQtMin(max, val)); 00071 } 00072 00073 template <class Type> 00074 inline void SoQtSwap(Type & a, Type & b) { 00075 Type t = a; a = b; b = t; 00076 } 00077 00078 // ************************************************************************* 00079 00080 #define __COIN_SOQT__ 00081 00082 #if ! defined(SOQT_MAJOR_VERSION) 00083 #define SOQT_MAJOR_VERSION 0 00084 #endif /* ! SOQT_MAJOR_VERSION */ 00085 #if ! defined(SOQT_MINOR_VERSION) 00086 #define SOQT_MINOR_VERSION 10 00087 #endif /* ! SOQT_MINOR_VERSION */ 00088 #if ! defined(SOQT_MICRO_VERSION) 00089 #define SOQT_MICRO_VERSION 0 00090 #endif /* ! SOQT_MICRO_VERSION */ 00091 #if ! defined(SOQT_VERSION) 00092 #define SOQT_VERSION "0.10.0" 00093 #endif /* ! SOQT_VERSION */ 00094 00095 // ************************************************************************* 00096 00097 /* Precaution to avoid an error easily made by the application programmer. */ 00098 #ifdef SOQT_DLL_API 00099 # error Leave the internal SOQT_DLL_API define alone. 00100 #endif /* SOQT_DLL_API */ 00101 00102 /* 00103 On MSWindows platforms, one of these defines must always be set when 00104 building application programs: 00105 00106 - "SOQT_DLL", when the application programmer is using the 00107 library in the form of a dynamic link library (DLL) 00108 00109 - "SOQT_NOT_DLL", when the application programmer is using the 00110 library in the form of a static object library (LIB) 00111 00112 Note that either SOQT_DLL or SOQT_NOT_DLL _must_ be defined by 00113 the application programmer on MSWindows platforms, or else the 00114 #error statement will hit. Set up one or the other of these two 00115 defines in your compiler environment according to how the library 00116 was built -- as a DLL (use "SOQT_DLL") or as a LIB (use 00117 "SOQT_NOT_DLL"). 00118 00119 (Setting up defines for the compiler is typically done by either 00120 adding something like "/DSOQT_DLL" to the compiler's argument 00121 line (for command-line build processes), or by adding the define to 00122 the list of preprocessor symbols in your IDE GUI (in the MSVC IDE, 00123 this is done from the "Project"->"Settings" menu, choose the "C/C++" 00124 tab, then "Preprocessor" from the dropdown box and add the 00125 appropriate define)). 00126 00127 It is extremely important that the application programmer uses the 00128 correct define, as using "SOQT_NOT_DLL" when "SOQT_DLL" is 00129 correct is likely to cause mysterious crashes. 00130 */ 00131 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) 00132 # ifdef SOQT_INTERNAL 00133 # ifdef SOQT_MAKE_DLL 00134 # define SOQT_DLL_API __declspec(dllexport) 00135 # endif /* SOQT_MAKE_DLL */ 00136 # else /* !SOQT_INTERNAL */ 00137 # ifdef SOQT_DLL 00138 # define SOQT_DLL_API __declspec(dllimport) 00139 # else /* !SOQT_DLL */ 00140 # ifndef SOQT_NOT_DLL 00141 # error Define either SOQT_DLL or SOQT_NOT_DLL as appropriate for your linkage! See Inventor/Qt/SoQtBasic.h for further instructions. 00142 # endif /* SOQT_NOT_DLL */ 00143 # endif /* !SOQT_DLL */ 00144 # endif /* !SOQT_MAKE_DLL */ 00145 #endif /* Microsoft Windows */ 00146 00147 /* Empty define to avoid errors when _not_ compiling an MSWindows DLL. */ 00148 #ifndef SOQT_DLL_API 00149 # define SOQT_DLL_API 00150 #endif /* !SOQT_DLL_API */ 00151 00152 // ************************************************************************* 00153 // These sanity checks are designed to detect common pitfall errors for 00154 // Microsoft Windows linkage with SoQt and Coin. 00155 00156 enum SoQtABIType { 00157 SOQT_DLL_ABI, SOQT_LIB_ABI, SOQT_UNKNOWN_ABI }; 00158 00159 enum SoQtABIError { 00160 SOQT_LINKTIME_MISMATCH, SOQT_LINKSTYLE_MISMATCH, 00161 SOQT_RUNTIME_MISMATCH }; 00162 00163 // FIXME: use an "is-this-a-DLL-capable-platform" configure check 00164 // and remove the system "#if defined" tests below. 20011203 mortene. 00165 // FIXME: I disabled this because it wasn't inlined in the client app 00166 // but compiled into the library by MSVC++ and with SOWIN_DLL undefined, 00167 // the ABI test always tried the LIB_ABI path. 20020126 larsa 00168 #if 0 && (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)) 00169 #define SOQT_SANITY_CHECK(forward_call) \ 00170 if (SoQt::isDebugLibrary() && \ 00171 SoDB::isInitialized()) \ 00172 SoDebugError::postWarning("SoQt::init", \ 00173 "unable to verify application linkage sanity " \ 00174 "because Open Inventor has already been " \ 00175 "initialized before SoQt::init call"); \ 00176 SOQT_RUNTIME_SANITY_CHECK(); \ 00177 SOQT_LINKSTYLE_SANITY_CHECK(); \ 00178 forward_call; \ 00179 SOQT_LINKTIME_SANITY_CHECK() 00180 00181 #define SOQT_RUNTIME_SANITY_CHECK() \ 00182 do { \ 00183 if (!SoQt::isCompatible(SOQT_MAJOR_VERSION, \ 00184 SOQT_MINOR_VERSION)) \ 00185 SoQt::abort(SOQT_RUNTIME_MISMATCH); \ 00186 } while (FALSE) 00187 00188 #ifdef SOQT_DLL 00189 #define SOQT_LINKSTYLE_SANITY_CHECK() \ 00190 do { \ 00191 if (SoQt::getABIType() != SOQT_DLL_ABI) \ 00192 SoQt::abort(SOQT_LINKSTYLE_MISMATCH); \ 00193 } while (FALSE) 00194 #else 00195 #define SOQT_LINKSTYLE_SANITY_CHECK() \ 00196 do { \ 00197 if (SoQt::getABIType() != SOQT_LIB_ABI) \ 00198 SoQt::abort(SOQT_LINKSTYLE_MISMATCH); \ 00199 } while (FALSE) 00200 #endif 00201 00202 #define SOQT_LINKTIME_SANITY_CHECK() \ 00203 do { \ 00204 if (!SoDB::isInitialized()) \ 00205 SoQt::abort(SOQT_LINKTIME_MISMATCH); \ 00206 } while (FALSE) 00207 #else /* ! MS Windows */ 00208 #define SOQT_SANITY_CHECK(forward_call) \ 00209 forward_call 00210 #endif /* ! MS Windows */ 00211 00212 // ************************************************************************* 00213 00214 #endif // ! SOQT_BASIC_H