1#ifndef SO@GUI@_BASIC_H 2#define SO@GUI@_BASIC_H 3 4// NB: this is not a pure configure-input file, it's also a config header... 5 6/**************************************************************************\ 7 * Copyright (c) Kongsberg Oil & Gas Technologies AS 8 * All rights reserved. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions are 12 * met: 13 * 14 * Redistributions of source code must retain the above copyright notice, 15 * this list of conditions and the following disclaimer. 16 * 17 * Redistributions in binary form must reproduce the above copyright 18 * notice, this list of conditions and the following disclaimer in the 19 * documentation and/or other materials provided with the distribution. 20 * 21 * Neither the name of the copyright holder nor the names of its 22 * contributors may be used to endorse or promote products derived from 23 * this software without specific prior written permission. 24 * 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 29 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36\**************************************************************************/ 37 38// ************************************************************************* 39 40/* Some useful inline template functions: 41 * So@Gui@Min(Val1, Val2) - returns minimum value 42 * So@Gui@Max(Val1, Val2) - returns maximum value 43 * So@Gui@Clamp(Val, Min, Max) - returns clamped value 44 * So@Gui@Swap(Val1, Val2) - swaps the two values (no return value) 45 */ 46 47template <class Type> 48inline Type So@Gui@Abs(Type Val) { 49 return (Val < 0) ? -Val : Val; 50} 51 52template <class Type> 53inline Type So@Gui@Min(Type a, Type b) { 54 return (b < a) ? b : a; 55} 56 57template <class Type> 58inline Type So@Gui@Max(Type a, Type b) { 59 return (b > a) ? b : a; 60} 61 62template <class Type> 63inline Type So@Gui@Clamp(Type val, Type min, Type max) { 64 return So@Gui@Max(min, So@Gui@Min(max, val)); 65} 66 67template <class Type> 68inline void So@Gui@Swap(Type & a, Type & b) { 69 Type t = a; a = b; b = t; 70} 71 72// ************************************************************************* 73 74#define __COIN_SO@GUI@__ 75 76#if ! defined(SO@GUI@_MAJOR_VERSION) 77#define SO@GUI@_MAJOR_VERSION ${SO@GUI@_MAJOR_VERSION} 78#endif /* ! SO@GUI@_MAJOR_VERSION */ 79#if ! defined(SO@GUI@_MINOR_VERSION) 80#define SO@GUI@_MINOR_VERSION ${SO@GUI@_MINOR_VERSION} 81#endif /* ! SO@GUI@_MINOR_VERSION */ 82#if ! defined(SO@GUI@_MICRO_VERSION) 83#define SO@GUI@_MICRO_VERSION ${SO@GUI@_MICRO_VERSION} 84#endif /* ! SO@GUI@_MICRO_VERSION */ 85#if ! defined(SO@GUI@_BETA_VERSION) 86#define SO@GUI@_BETA_VERSION ${SO@GUI@_BETA_VERSION} 87#endif /* ! SO@GUI@_BETA_VERSION */ 88#if ! defined(SO@GUI@_VERSION) 89#define SO@GUI@_VERSION "${SO@GUI@_VERSION}" 90#endif /* ! SO@GUI@_VERSION */ 91 92// ************************************************************************* 93 94/* Precaution to avoid an error easily made by the application programmer. */ 95#ifdef SO@GUI@_DLL_API 96# error Leave the internal SO@GUI@_DLL_API define alone. 97#endif /* SO@GUI@_DLL_API */ 98 99/* 100 On MSWindows platforms, one of these defines must always be set when 101 building application programs: 102 103 - "SO@GUI@_DLL", when the application programmer is using the 104 library in the form of a dynamic link library (DLL) 105 106 - "SO@GUI@_NOT_DLL", when the application programmer is using the 107 library in the form of a static object library (LIB) 108 109 Note that either SO@GUI@_DLL or SO@GUI@_NOT_DLL _must_ be defined by 110 the application programmer on MSWindows platforms, or else the 111 #error statement will hit. Set up one or the other of these two 112 defines in your compiler environment according to how the library 113 was built -- as a DLL (use "SO@GUI@_DLL") or as a LIB (use 114 "SO@GUI@_NOT_DLL"). 115 116 (Setting up defines for the compiler is typically done by either 117 adding something like "/DSO@GUI@_DLL" to the compiler's argument 118 line (for command-line build processes), or by adding the define to 119 the list of preprocessor symbols in your IDE GUI (in the MSVC IDE, 120 this is done from the "Project"->"Settings" menu, choose the "C/C++" 121 tab, then "Preprocessor" from the dropdown box and add the 122 appropriate define)). 123 124 It is extremely important that the application programmer uses the 125 correct define, as using "SO@GUI@_NOT_DLL" when "SO@GUI@_DLL" is 126 correct is likely to cause mysterious crashes. 127 */ 128#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) 129# ifdef SO@GUI@_INTERNAL 130# ifdef SO@GUI@_MAKE_DLL 131# define SO@GUI@_DLL_API __declspec(dllexport) 132# endif /* SO@GUI@_MAKE_DLL */ 133# else /* !SO@GUI@_INTERNAL */ 134# ifdef SO@GUI@_DLL 135# define SO@GUI@_DLL_API __declspec(dllimport) 136# else /* !SO@GUI@_DLL */ 137# ifndef SO@GUI@_NOT_DLL 138# error Define either SO@GUI@_DLL or SO@GUI@_NOT_DLL as appropriate for your linkage! See Inventor/@Gui@/So@Gui@Basic.h for further instructions. 139# endif /* SO@GUI@_NOT_DLL */ 140# endif /* !SO@GUI@_DLL */ 141# endif /* !SO@GUI@_MAKE_DLL */ 142#endif /* Microsoft Windows */ 143 144/* Empty define to avoid errors when _not_ compiling an MSWindows DLL. */ 145#ifndef SO@GUI@_DLL_API 146# define SO@GUI@_DLL_API 147#endif /* !SO@GUI@_DLL_API */ 148 149#ifndef GUI_TOOLKIT_VERSION 150#define GUI_TOOLKIT_VERSION "@GUI_TOOLKIT_VERSION@" 151#endif /* GUI_TOOLKIT_VERSION */ 152 153#endif // ! SO@GUI@_BASIC_H 154