Tulip  5.1.0
Large graphs analysis and drawing
tulipconf.h
1 /*
2  *
3  * This file is part of Tulip (http://tulip.labri.fr)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux
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 TLP_TYPEOF decltype
36 # else
37 # define TLP_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 
58 //MSVC 2010 has a different keyword for typeof, and deprecated
59 # if _MSC_VER >= 1600
60 # define _DEPRECATED __declspec(deprecated)
61 # define _DEPRECATED_TYPEDEF(type, deprecated_type) typedef _DEPRECATED type deprecated_type
62 # define TLP_TYPEOF decltype
63 # else
64 //MSVC 2008 must use Boost's typeof
65 # include "boost/typeof/typeof.hpp"
66 # define TLP_TYPEOF BOOST_TYPEOF
67 # endif
68 
69 # define __PRETTY_FUNCTION__ __FUNCTION__ //MSVC has a different name for pretty_function
70 # define strcasecmp stricmp //strcasecmp does not exists for VC, workaround
71 
72 #include <cmath>
73 
74 inline double fabs(int i) {
75  return std::fabs(static_cast<double>(i));
76 }
77 
78 # if _MSC_VER < 1800 // Visual Studio 2013 improved C99 support, no need to redefine some cmath functions
79 
80 // MSVC needs explicit casting of ints ot double, float or long double. Let's just pretend he does not.
81 #include <cstdlib>
82 
83 inline double sqrt(int i) {
84  return std::sqrt(static_cast<double>(i));
85 }
86 
87 inline double sqrt(unsigned int i) {
88  return std::sqrt(static_cast<double>(i));
89 }
90 
91 inline double log(int i) {
92  return std::log(static_cast<double>(i));
93 }
94 
95 inline double log(unsigned int i) {
96  return std::log(static_cast<double>(i));
97 }
98 
99 inline double floor(int i) {
100  return std::floor(static_cast<double>(i));
101 }
102 
103 inline double floor(unsigned int i) {
104  return std::floor(static_cast<double>(i));
105 }
106 
107 inline double round(double d) {
108  return std::floor(d + 0.5);
109 }
110 
111 inline float strtof(const char* cptr, char** endptr) {
112  return std::strtod(cptr, endptr);
113 }
114 
115 #define isnan(x) ((x) != (x)) //you guessed it, this is a C99 feature, and VC++ does not support C99. workaroud this.
116 #define rint(arg) arg > 0 ? static_cast<int>(std::floor(static_cast<double>(arg))) : static_cast<int>(std::ceil(static_cast<double>(arg))) //Hey, nother C99 feature !
117 
118 #if _MSC_VER <= 1600
119 inline double log1p(double x) {
120  return log(x + 1);
121 }
122 #endif
123 
124 # else // _MSC_VER < 1800
125 
126 // for std::min and std::max
127 #include <algorithm>
128 
129 # endif // _MSC_VER < 1800
130 
131 //clang does not define __GNUC_MINOR__, thus having a separate clang #elif seems cleaner than adding defined() in the #else
132 #elif __clang__
133 # define _DEPRECATED __attribute__ ((deprecated))
134 # define _DEPRECATED_TYPEDEF(type, deprecated_type) typedef type deprecated_type _DEPRECATED
135 # define stdext __gnu_cxx
136 
137 // disable some specific C++11 warnings with clang
138 #if __clang_major__ >= 3 && __clang_minor__ >= 4
139 #pragma clang diagnostic ignored "-Wdeprecated-register"
140 #endif
141 
142 //for GCC 4.X
143 #else
144 # define _DEPRECATED __attribute__ ((deprecated))
145 # define _DEPRECATED_TYPEDEF(type, deprecated_type) typedef type deprecated_type _DEPRECATED
146 # define stdext __gnu_cxx
147 # if (__GNUC_MINOR__ < 4 && __GNUC__ < 4)
148 # include <ext/stl_hash_fun.h>
149 # elif (__GNUC_MINOR__ < 3 && __GNUC__ <= 4)
150 # include <ext/hash_fun.h>
151 # elif (__GNUC_MINOR__ > 3 && __GNUC__ >= 4)
152 # include <backward/hash_fun.h>
153 # endif
154 #endif
155 
156 #ifdef _OPENMP
157 #include <omp.h>
158 // _OPENMP is supposed to be defined as an integer
159 // representing the year/month of the supported version
160 #if _OPENMP < 200805
161 // only signed integer types are supported
162 // for OpenMP < 3.0
163 #define OMP_ITER_TYPE long long
164 #else
165 #define OMP_ITER_TYPE size_t
166 #endif
167 #else
168 #define OMP_ITER_TYPE size_t
169 #endif
170 
171 //WIN32 specific defines: dllimport and dllexport stuff
172 #ifdef _WIN32
173 # ifdef DLL_TULIP
174 # define TLP_SCOPE __declspec(dllexport)
175 # else
176 # define TLP_SCOPE __declspec(dllimport)
177 # endif
178 #endif
179 #ifndef TLP_SCOPE
180 # define TLP_SCOPE
181 #endif
182 
183 #ifdef _WIN32
184 # ifdef DLL_TULIP_GL
185 # define TLP_GL_SCOPE __declspec(dllexport)
186 # else
187 # define TLP_GL_SCOPE __declspec(dllimport)
188 # endif
189 #endif
190 #ifndef TLP_GL_SCOPE
191 # define TLP_GL_SCOPE
192 #endif
193 
194 #ifdef _WIN32
195 # ifdef DLL_TULIP_QT
196 # define TLP_QT_SCOPE __declspec(dllexport)
197 # else
198 # define TLP_QT_SCOPE __declspec(dllimport)
199 # endif
200 #endif
201 #ifndef TLP_QT_SCOPE
202 # define TLP_QT_SCOPE
203 #endif
204 
205 #ifdef _WIN32
206 # ifdef DLL_TULIP_PYTHON
207 # define TLP_PYTHON_SCOPE __declspec(dllexport)
208 # else
209 # define TLP_PYTHON_SCOPE __declspec(dllimport)
210 # endif
211 #endif
212 #ifndef TLP_PYTHON_SCOPE
213 # define TLP_PYTHON_SCOPE
214 #endif
215 
216 #ifdef _WIN32
217 # ifdef DLL_TULIP_OGDF
218 # define TLP_OGDF_SCOPE __declspec(dllexport)
219 # else
220 # define TLP_OGDF_SCOPE __declspec(dllimport)
221 # endif
222 #endif
223 #ifndef TLP_OGDF_SCOPE
224 # define TLP_OGDF_SCOPE
225 #endif
226 
227 #include <ostream>
228 
229 namespace tlp {
230 /**
231  *
232  * @brief return the ostream used for the output of debug messages
233  */
234 extern TLP_SCOPE std::ostream& debug();
235 /**
236  *
237  * @brief set the ostream used for the output debug messages
238  */
239 extern TLP_SCOPE void setDebugOutput(std::ostream& os);
240 /**
241  *
242  * @brief return the ostream used for the output of warning messages
243  */
244 extern TLP_SCOPE std::ostream& warning();
245 /**
246  *
247  * @brief set the ostream used for the output of warning messages
248  */
249 extern TLP_SCOPE void setWarningOutput(std::ostream& os);
250 /**
251  *
252  * @brief return the ostream used for the output of error messages
253  */
254 extern TLP_SCOPE std::ostream& error();
255 /**
256  *
257  * @brief set the ostream used for the output of error messages
258  */
259 extern TLP_SCOPE void setErrorOutput(std::ostream& os);
260 
261 /**
262  *
263  * @brief return the TULIP_VERSION value
264  */
265 extern TLP_SCOPE std::string getTulipVersion();
266 
267 }
268 
269 #endif //TULIPCONF_H
270 ///@endcond