Main Page   Modules   Compound List   File List   Compound Members  

SoXtBasic.h

00001 /* src/Inventor/Xt/SoXtBasic.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 SOXT_BASIC_H
00026 #define SOXT_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  *   SoXtMin(Val1, Val2)       - returns minimum value
00046  *   SoXtMax(Val1, Val2)       - returns maximum value
00047  *   SoXtClamp(Val, Min, Max)  - returns clamped value
00048  *   SoXtSwap(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 SoXtAbs(Type Val) {
00055   return (Val < 0) ? -Val : Val;
00056 }
00057 
00058 template <class Type>
00059 inline Type SoXtMin(Type a, Type b) {
00060   return (b < a) ? b : a;
00061 }
00062 
00063 template <class Type>
00064 inline Type SoXtMax(Type a, Type b) {
00065   return (b > a) ? b : a;
00066 }
00067 
00068 template <class Type>
00069 inline Type SoXtClamp(Type val, Type min, Type max) {
00070   return SoXtMax(min, SoXtMin(max, val));
00071 }
00072 
00073 template <class Type>
00074 inline void SoXtSwap(Type & a, Type & b) {
00075   Type t = a; a = b; b = t;
00076 }
00077 
00078 // *************************************************************************
00079 
00080 #define __COIN_SOXT__
00081 
00082 #if ! defined(SOXT_MAJOR_VERSION)
00083 #define SOXT_MAJOR_VERSION 0
00084 #endif /* ! SOXT_MAJOR_VERSION */
00085 #if ! defined(SOXT_MINOR_VERSION)
00086 #define SOXT_MINOR_VERSION 5
00087 #endif /* ! SOXT_MINOR_VERSION */
00088 #if ! defined(SOXT_MICRO_VERSION)
00089 #define SOXT_MICRO_VERSION 0
00090 #endif /* ! SOXT_MICRO_VERSION */
00091 #if ! defined(SOXT_VERSION)
00092 #define SOXT_VERSION "0.5.0"
00093 #endif /* ! SOXT_VERSION */
00094 
00095 // *************************************************************************
00096 
00097 /* Precaution to avoid an error easily made by the application programmer. */
00098 #ifdef SOXT_DLL_API
00099 # error Leave the internal SOXT_DLL_API define alone.
00100 #endif /* SOXT_DLL_API */
00101 
00102 /*
00103   On MSWindows platforms, one of these defines must always be set when
00104   building application programs:
00105 
00106    - "SOXT_DLL", when the application programmer is using the
00107      library in the form of a dynamic link library (DLL)
00108 
00109    - "SOXT_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 SOXT_DLL or SOXT_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 "SOXT_DLL") or as a LIB (use
00117   "SOXT_NOT_DLL").
00118 
00119   (Setting up defines for the compiler is typically done by either
00120   adding something like "/DSOXT_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 "SOXT_NOT_DLL" when "SOXT_DLL" is
00129   correct is likely to cause mysterious crashes.
00130  */
00131 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
00132 # ifdef SOXT_INTERNAL
00133 #  ifdef SOXT_MAKE_DLL
00134 #   define SOXT_DLL_API __declspec(dllexport)
00135 #  endif /* SOXT_MAKE_DLL */
00136 # else /* !SOXT_INTERNAL */
00137 #  ifdef SOXT_DLL
00138 #   define SOXT_DLL_API __declspec(dllimport)
00139 #  else /* !SOXT_DLL */
00140 #   ifndef SOXT_NOT_DLL
00141 #    error Define either SOXT_DLL or SOXT_NOT_DLL as appropriate for your linkage! See Inventor/Xt/SoXtBasic.h for further instructions.
00142 #   endif /* SOXT_NOT_DLL */
00143 #  endif /* !SOXT_DLL */
00144 # endif /* !SOXT_MAKE_DLL */
00145 #endif /* Microsoft Windows */
00146 
00147 /* Empty define to avoid errors when _not_ compiling an MSWindows DLL. */
00148 #ifndef SOXT_DLL_API
00149 # define SOXT_DLL_API
00150 #endif /* !SOXT_DLL_API */
00151 
00152 // *************************************************************************
00153 // These sanity checks are designed to detect common pitfall errors for
00154 // Microsoft Windows linkage with SoXt and Coin.
00155 
00156 enum SoXtABIType {
00157   SOXT_DLL_ABI, SOXT_LIB_ABI, SOXT_UNKNOWN_ABI };
00158 
00159 enum SoXtABIError {
00160   SOXT_LINKTIME_MISMATCH, SOXT_LINKSTYLE_MISMATCH,
00161   SOXT_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 SOXT_SANITY_CHECK(forward_call)                  \
00170   if (SoXt::isDebugLibrary() &&                       \
00171        SoDB::isInitialized())                          \
00172     SoDebugError::postWarning("SoXt::init",            \
00173       "unable to verify application linkage sanity "    \
00174       "because Open Inventor has already been "         \
00175       "initialized before SoXt::init call");           \
00176   SOXT_RUNTIME_SANITY_CHECK();                         \
00177   SOXT_LINKSTYLE_SANITY_CHECK();                       \
00178   forward_call;                                         \
00179   SOXT_LINKTIME_SANITY_CHECK()
00180 
00181 #define SOXT_RUNTIME_SANITY_CHECK()                    \
00182   do {                                                  \
00183     if (!SoXt::isCompatible(SOXT_MAJOR_VERSION,      \
00184                             SOXT_MINOR_VERSION))      \
00185       SoXt::abort(SOXT_RUNTIME_MISMATCH);             \
00186   } while (FALSE)
00187 
00188 #ifdef SOXT_DLL
00189 #define SOXT_LINKSTYLE_SANITY_CHECK()                  \
00190   do {                                                  \
00191     if (SoXt::getABIType() != SOXT_DLL_ABI)         \
00192       SoXt::abort(SOXT_LINKSTYLE_MISMATCH);           \
00193   } while (FALSE)
00194 #else
00195 #define SOXT_LINKSTYLE_SANITY_CHECK()                  \
00196   do {                                                  \
00197     if (SoXt::getABIType() != SOXT_LIB_ABI)         \
00198       SoXt::abort(SOXT_LINKSTYLE_MISMATCH);           \
00199   } while (FALSE)
00200 #endif
00201 
00202 #define SOXT_LINKTIME_SANITY_CHECK()                   \
00203   do {                                                  \
00204     if (!SoDB::isInitialized())                       \
00205       SoXt::abort(SOXT_LINKTIME_MISMATCH);            \
00206   } while (FALSE)
00207 #else /* ! MS Windows */
00208 #define SOXT_SANITY_CHECK(forward_call)                \
00209   forward_call
00210 #endif /* ! MS Windows */
00211 
00212 // *************************************************************************
00213 
00214 #endif // ! SOXT_BASIC_H

Generated at Tue Mar 5 03:33:04 2002 for SoXt by doxygen1.2.9 written by Dimitri van Heesch, © 1997-2001