Tulip  4.2.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__)
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: 4275) //base class is not dllexport
45 #pragma warning(disable: 4244) //conversion to (or from) smaller integer type
46 #pragma warning(disable: 4355) //'this' pointer used in initializer list
47 #pragma warning(disable: 4800) //non-bool value coerced into bool (e.g. bool a = 5;)
48 #pragma warning(disable: 4503) //decorated name too long, truncated
49 #pragma warning(disable: 4344) //template specialisation results in different function being called (getProperty<>)
50 // disable deprecated warnings when compiling the tulip dlls, as MSVC is overly verbose with deprecation
51 // (even if a deprecated function is not used, warnings are issued)
52 #if defined(DLL_TULIP) || defined(DLL_TULIP_GL) || defined(DLL_TULIP_QT) || defined(DLL_TULIP_QT2)
53 #pragma warning(disable: 4996) //deprecated functions
54 #endif
55 //MSVC 2010 has a different keyword for typeof, and deprecated
56 # if _MSC_VER >= 1600
57 # define _DEPRECATED __declspec(deprecated)
58 # define _DEPRECATED_TYPEDEF(type, deprecated_type) typedef _DEPRECATED type deprecated_type
59 # define TYPEOF decltype
60 # else
61 //MSVC 2008 must use Boost's typeof
62 # include "boost/typeof/typeof.hpp"
63 # define TYPEOF BOOST_TYPEOF
64 # endif
65 
66 //MSVC needs explicit casting of ints ot double, float or long double. Let's just pretend he does not.
67 #include <cmath>
68 #include <cstdlib>
69 static double sqrt(int i) {
70  return sqrt((double)i);
71 }
72 static double sqrt(unsigned int i) {
73  return sqrt((double)i);
74 }
75 
76 static double log(int i) {
77  return log((double)i);
78 }
79 static double log(unsigned int i) {
80  return log((double)i);
81 }
82 
83 static double floor(int i) {
84  return floor((double)i);
85 }
86 static double floor(unsigned int i) {
87  return floor((double)i);
88 }
89 
90 static double round(double d) {
91  return floor(d + 0.5);
92 }
93 
94 static double fabs(int i) {
95  return fabs((double)i);
96 }
97 
98 static float strtof(const char* cptr, char** endptr) {
99  return strtod(cptr, endptr);
100 }
101 
102 # define __PRETTY_FUNCTION__ __FUNCTION__ //MSVC has a different name for pretty_function
103 # define strcasecmp stricmp //strcasecmp does not exists for VC, workaround
104 # define isnan(x) ((x) != (x)) //you guessed it, this is a C99 feature, and VC++ does not support C99. workaroud this.
105 # define rint(arg) arg > 0 ? (int)std::floor((double)arg) : (int)std::ceil((double)arg) //Hey, nother C99 feature !
106 
107 //clang does not define __GNUC_MINOR__, thus having a separate clang #elif seems cleaner than adding defined() in the #else
108 #elif __clang__
109 # define _DEPRECATED __attribute__ ((deprecated))
110 # define _DEPRECATED_TYPEDEF(type, deprecated_type) typedef type deprecated_type _DEPRECATED
111 # define stdext __gnu_cxx
112 
113 //for GCC 4.X
114 #else
115 # define _DEPRECATED __attribute__ ((deprecated))
116 # define _DEPRECATED_TYPEDEF(type, deprecated_type) typedef type deprecated_type _DEPRECATED
117 # define stdext __gnu_cxx
118 # if (__GNUC_MINOR__ < 4 && __GNUC__ < 4)
119 # include <ext/stl_hash_fun.h>
120 # elif (__GNUC_MINOR__ < 3)
121 # include <ext/hash_fun.h>
122 # endif
123 #endif
124 
125 //WIN32 specific defines: dllimport and dllexport stuff
126 #ifdef _WIN32
127 # ifdef DLL_TULIP
128 # define TLP_SCOPE __declspec(dllexport)
129 # else
130 # define TLP_SCOPE __declspec(dllimport)
131 # endif
132 #endif
133 #ifndef TLP_SCOPE
134 # define TLP_SCOPE
135 #endif
136 
137 #ifdef _WIN32
138 # ifdef DLL_TULIP_GL
139 # define TLP_GL_SCOPE __declspec(dllexport)
140 # else
141 # define TLP_GL_SCOPE __declspec(dllimport)
142 # endif
143 #endif
144 #ifndef TLP_GL_SCOPE
145 # define TLP_GL_SCOPE
146 #endif
147 
148 #ifdef _WIN32
149 # ifdef DLL_TULIP_QT
150 # define TLP_QT_SCOPE __declspec(dllexport)
151 # else
152 # define TLP_QT_SCOPE __declspec(dllimport)
153 # endif
154 #endif
155 #ifndef TLP_QT_SCOPE
156 # define TLP_QT_SCOPE
157 #endif
158 
159 #ifdef _WIN32
160 # ifdef DLL_TULIP_PYTHON
161 # define TLP_PYTHON_SCOPE __declspec(dllexport)
162 # else
163 # define TLP_PYTHON_SCOPE __declspec(dllimport)
164 # endif
165 #endif
166 #ifndef TLP_PYTHON_SCOPE
167 # define TLP_PYTHON_SCOPE
168 #endif
169 
170 #ifdef _WIN32
171 # ifdef DLL_TULIP_OGDF
172 # define TLP_OGDF_SCOPE __declspec(dllexport)
173 # else
174 # define TLP_OGDF_SCOPE __declspec(dllimport)
175 # endif
176 #endif
177 #ifndef TLP_OGDF_SCOPE
178 # define TLP_OGDF_SCOPE
179 #endif
180 
181 #include <ostream>
182 
183 namespace tlp {
184 /**
185  *
186  * @brief return the ostream used for the output of debug messages
187  */
188 extern TLP_SCOPE std::ostream& debug();
189 /**
190  *
191  * @brief set the ostream used for the output debug messages
192  */
193 extern TLP_SCOPE void setDebugOutput(std::ostream& os);
194 /**
195  *
196  * @brief return the ostream used for the output of warning messages
197  */
198 extern TLP_SCOPE std::ostream& warning();
199 /**
200  *
201  * @brief set the ostream used for the output of warning messages
202  */
203 extern TLP_SCOPE void setWarningOutput(std::ostream& os);
204 /**
205  *
206  * @brief return the ostream used for the output of error messages
207  */
208 extern TLP_SCOPE std::ostream& error();
209 /**
210  *
211  * @brief set the ostream used for the output of error messages
212  */
213 extern TLP_SCOPE void setErrorOutput(std::ostream& os);
214 }
215 
216 #endif //TULIPCONF_H
217 ///@endcond