Tulip  4.4.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
tulipconf.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 ///@cond DOXYGEN_HIDDEN
20 
21 #ifndef TULIPCONF_H
22 #define TULIPCONF_H
23 
24 /**
25  * @brief this file contains various helper macros and functions to have a true cross-platform compilation.
26  *
27  */
28 
29 #define STRINGIFY(PARAM) STRINGIFY_INTERNAL(PARAM)
30 #define STRINGIFY_INTERNAL(PARAM) #PARAM
31 
32 //MSVC and GCC in c++11 mode use decltype instead of typeof
33 #if !defined(_MSC_VER)
34 # if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
35 # define TYPEOF decltype
36 # else
37 # define TYPEOF typeof
38 # endif
39 #endif
40 
41 #if defined(_MSC_VER)
42 // disable some annoying Visual Studio warnings
43 #pragma warning(disable: 4251) //member is not dllexport
44 #pragma warning(disable: 4267) //conversion from 'size_t' to 'type', possible loss of data
45 #pragma warning(disable: 4275) //base class is not dllexport
46 #pragma warning(disable: 4244) //conversion to (or from) smaller integer type
47 #pragma warning(disable: 4355) //'this' pointer used in initializer list
48 #pragma warning(disable: 4800) //non-bool value coerced into bool (e.g. bool a = 5;)
49 #pragma warning(disable: 4503) //decorated name too long, truncated
50 #pragma warning(disable: 4344) //template specialisation results in different function being called (getProperty<>)
51 
52 // disable deprecated warnings when compiling the tulip dlls, as MSVC is overly verbose with deprecation
53 // (even if a deprecated function is not used, warnings are issued)
54 #if defined(DLL_TULIP) || defined(DLL_TULIP_GL) || defined(DLL_TULIP_QT) || defined(DLL_TULIP_QT2)
55 #pragma warning(disable: 4996) //deprecated functions
56 #endif
57 //MSVC 2010 has a different keyword for typeof, and deprecated
58 # if _MSC_VER >= 1600
59 # define _DEPRECATED __declspec(deprecated)
60 # define _DEPRECATED_TYPEDEF(type, deprecated_type) typedef _DEPRECATED type deprecated_type
61 # define TYPEOF decltype
62 # else
63 //MSVC 2008 must use Boost's typeof
64 # include "boost/typeof/typeof.hpp"
65 # define TYPEOF BOOST_TYPEOF
66 # endif
67 
68 //MSVC needs explicit casting of ints ot double, float or long double. Let's just pretend he does not.
69 #include <cmath>
70 #include <cstdlib>
71 static double sqrt(int i) {
72  return sqrt((double)i);
73 }
74 static double sqrt(unsigned int i) {
75  return sqrt((double)i);
76 }
77 
78 static double log(int i) {
79  return log((double)i);
80 }
81 static double log(unsigned int i) {
82  return log((double)i);
83 }
84 
85 static double floor(int i) {
86  return floor((double)i);
87 }
88 static double floor(unsigned int i) {
89  return floor((double)i);
90 }
91 
92 static double round(double d) {
93  return floor(d + 0.5);
94 }
95 
96 static double fabs(int i) {
97  return fabs((double)i);
98 }
99 
100 static float strtof(const char* cptr, char** endptr) {
101  return strtod(cptr, endptr);
102 }
103 
104 # define __PRETTY_FUNCTION__ __FUNCTION__ //MSVC has a different name for pretty_function
105 # define strcasecmp stricmp //strcasecmp does not exists for VC, workaround
106 # define isnan(x) ((x) != (x)) //you guessed it, this is a C99 feature, and VC++ does not support C99. workaroud this.
107 # define rint(arg) arg > 0 ? (int)std::floor((double)arg) : (int)std::ceil((double)arg) //Hey, nother C99 feature !
108 
109 //clang does not define __GNUC_MINOR__, thus having a separate clang #elif seems cleaner than adding defined() in the #else
110 #elif __clang__
111 # define _DEPRECATED __attribute__ ((deprecated))
112 # define _DEPRECATED_TYPEDEF(type, deprecated_type) typedef type deprecated_type _DEPRECATED
113 # define stdext __gnu_cxx
114 
115 //for GCC 4.X
116 #else
117 # define _DEPRECATED __attribute__ ((deprecated))
118 # define _DEPRECATED_TYPEDEF(type, deprecated_type) typedef type deprecated_type _DEPRECATED
119 # define stdext __gnu_cxx
120 # if (__GNUC_MINOR__ < 4 && __GNUC__ < 4)
121 # include <ext/stl_hash_fun.h>
122 # elif (__GNUC_MINOR__ < 3)
123 # include <ext/hash_fun.h>
124 # endif
125 #endif
126 
127 //WIN32 specific defines: dllimport and dllexport stuff
128 #ifdef _WIN32
129 # ifdef DLL_TULIP
130 # define TLP_SCOPE __declspec(dllexport)
131 # else
132 # define TLP_SCOPE __declspec(dllimport)
133 # endif
134 #endif
135 #ifndef TLP_SCOPE
136 # define TLP_SCOPE
137 #endif
138 
139 #ifdef _WIN32
140 # ifdef DLL_TULIP_GL
141 # define TLP_GL_SCOPE __declspec(dllexport)
142 # else
143 # define TLP_GL_SCOPE __declspec(dllimport)
144 # endif
145 #endif
146 #ifndef TLP_GL_SCOPE
147 # define TLP_GL_SCOPE
148 #endif
149 
150 #ifdef _WIN32
151 # ifdef DLL_TULIP_QT
152 # define TLP_QT_SCOPE __declspec(dllexport)
153 # else
154 # define TLP_QT_SCOPE __declspec(dllimport)
155 # endif
156 #endif
157 #ifndef TLP_QT_SCOPE
158 # define TLP_QT_SCOPE
159 #endif
160 
161 #ifdef _WIN32
162 # ifdef DLL_TULIP_PYTHON
163 # define TLP_PYTHON_SCOPE __declspec(dllexport)
164 # else
165 # define TLP_PYTHON_SCOPE __declspec(dllimport)
166 # endif
167 #endif
168 #ifndef TLP_PYTHON_SCOPE
169 # define TLP_PYTHON_SCOPE
170 #endif
171 
172 #ifdef _WIN32
173 # ifdef DLL_TULIP_OGDF
174 # define TLP_OGDF_SCOPE __declspec(dllexport)
175 # else
176 # define TLP_OGDF_SCOPE __declspec(dllimport)
177 # endif
178 #endif
179 #ifndef TLP_OGDF_SCOPE
180 # define TLP_OGDF_SCOPE
181 #endif
182 
183 #include <ostream>
184 
185 namespace tlp {
186 /**
187  *
188  * @brief return the ostream used for the output of debug messages
189  */
190 extern TLP_SCOPE std::ostream& debug();
191 /**
192  *
193  * @brief set the ostream used for the output debug messages
194  */
195 extern TLP_SCOPE void setDebugOutput(std::ostream& os);
196 /**
197  *
198  * @brief return the ostream used for the output of warning messages
199  */
200 extern TLP_SCOPE std::ostream& warning();
201 /**
202  *
203  * @brief set the ostream used for the output of warning messages
204  */
205 extern TLP_SCOPE void setWarningOutput(std::ostream& os);
206 /**
207  *
208  * @brief return the ostream used for the output of error messages
209  */
210 extern TLP_SCOPE std::ostream& error();
211 /**
212  *
213  * @brief set the ostream used for the output of error messages
214  */
215 extern TLP_SCOPE void setErrorOutput(std::ostream& os);
216 }
217 
218 #endif //TULIPCONF_H
219 ///@endcond