Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
config.h
Go to the documentation of this file.
1
32#pragma once
33
36
37#include <iostream>
38#include <string>
39
40#if defined(OGDF_DEBUG) && defined(NDEBUG)
41# error "Contradicting configuration: Macros OGDF_DEBUG and NDEBUG are defined."
42#endif
43
44namespace ogdf {
45
46// generally used <string> members
47using std::string;
48using std::to_string;
49
50// detection of the system
51
52#if defined(unix) || defined(__unix__) || defined(__unix) || defined(_AIX) || defined(__APPLE__)
53# define OGDF_SYSTEM_UNIX
54#endif
55
56#if defined(__WIN32__) || defined(_WIN32) || defined(__NT__)
57# define OGDF_SYSTEM_WINDOWS
58#endif
59
60// Note: Apple OS X machines will be both OGDF_SYSTEM_UNIX and OGDF_SYSTEM_OSX
61#if defined(__APPLE__)
62# define OGDF_SYSTEM_OSX
63#endif
64
65// C++11 standard
66
67#if __cplusplus < 201103
68
69# if defined(_MSC_VER)
70# if _MSC_VER < 1700
71# error "Compiling OGDF requires Visual C++ 11 (Visual Studio 2012) or higher!"
72# endif
73
74# elif defined(__GNUC__)
75# ifndef __GXX_EXPERIMENTAL_CXX0X__
76# error "No C++11 support activated for g++ (compile with -std=c++0x or -std=c++11)!"
77# endif
78
79# else
80# error "Compiling OGDF requires a C++11 compliant compiler!"
81# endif
82
83#endif
84
85#ifdef __has_cpp_attribute
86# define OGDF_HAS_CPP_ATTRIBUTE(x) \
87 (__has_cpp_attribute(x) && __cplusplus >= __has_cpp_attribute(x))
88#else
89# define OGDF_HAS_CPP_ATTRIBUTE(x) 0
90#endif
91
95
101#define OGDF_EXPORT
102
103#ifdef OGDF_SYSTEM_WINDOWS
104# ifdef OGDF_DLL
105# undef OGDF_EXPORT
106# ifdef OGDF_INSTALL
107# define OGDF_EXPORT __declspec(dllexport)
108# else
109# define OGDF_EXPORT __declspec(dllimport)
110# endif
111# endif
112#endif
113
117
120#define OGDF_DEPRECATED(reason)
121
122#if OGDF_HAS_CPP_ATTRIBUTE(deprecated)
123# undef OGDF_DEPRECATED
124# define OGDF_DEPRECATED(reason) [[deprecated(reason)]]
125#elif defined(_MSC_VER)
126# undef OGDF_DEPRECATED
127# define OGDF_DEPRECATED(reason) __declspec(deprecated(reason))
128#elif defined(__GNUC__)
129# undef OGDF_DEPRECATED
130# define OGDF_DEPRECATED(reason) __attribute__((deprecated(reason)))
131#endif
132
134
137
143#define OGDF_LIKELY(x) (x)
144
150#define OGDF_UNLIKELY(x) (x)
151
154#define OGDF_DECL_ALIGN(b)
155
156#ifdef _MSC_VER // Visual C++ compiler
157# undef OGDF_DECL_ALIGN
158# define OGDF_DECL_ALIGN(b) __declspec(align(b))
159#elif defined(__GNUC__) // GNU gcc compiler (also Intel compiler)
160# undef OGDF_LIKELY
161# define OGDF_LIKELY(x) __builtin_expect((x), 1)
162# undef OGDF_UNLIKELY
163# define OGDF_UNLIKELY(x) __builtin_expect((x), 0)
164# undef OGDF_DECL_ALIGN
165# define OGDF_DECL_ALIGN(b) __attribute__((aligned(b)))
166#endif
167
169
171#define OGDF_CASE_FALLTHROUGH
172#if OGDF_HAS_CPP_ATTRIBUTE(fallthrough)
173# undef OGDF_CASE_FALLTHROUGH
174# define OGDF_CASE_FALLTHROUGH [[fallthrough]]
175#elif defined(__GNUC__) && __GNUC__ >= 7
176# undef OGDF_CASE_FALLTHROUGH
177# define OGDF_CASE_FALLTHROUGH __attribute__((fallthrough))
178#endif
179
180// compiler adaptions
181
182#ifdef _MSC_VER
183
184# ifdef OGDF_DLL
185// disable useless warnings
186// missing dll-interface
187
188// warning C4251: 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
189# pragma warning(disable : 4251)
190// warning C4275: non-DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier'
191# pragma warning(disable : 4275)
192# endif
193
194// warning C4355: 'this' : used in base member initializer list
195# pragma warning(disable : 4355)
196
197#endif
198
200
204public:
206 enum class System {
207 Unknown,
208 Windows,
209 Unix,
210 OSX,
211 STOP
212 };
213
215 enum class LPSolver {
216 None,
217 Clp,
218 Symphony,
219 CPLEX,
220 Gurobi,
221 STOP
222 };
223
225 enum class MemoryManager {
226 PoolTS,
227 PoolNTS,
228 Malloc,
229 STOP
230 };
231
233 static constexpr System whichSystem() {
234#ifdef OGDF_SYSTEM_WINDOWS
235 return System::Windows;
236#elif defined(OGDF_SYSTEM_OSX)
237 return System::OSX;
238#elif defined(OGDF_SYSTEM_UNIX)
239 return System::Unix;
240#else
241 return System::Unknown
242#endif
243 }
244
246
250 OGDF_DEPRECATED("OGDF always has LP solver support since 2015.05")
251
252 static constexpr bool haveLPSolver() { return true; }
253
255 static constexpr LPSolver whichLPSolver() {
256#if defined(COIN_OSI_CLP)
257 return LPSolver::Clp;
258#elif defined(COIN_OSI_SYM)
259 return LPSolver::Symphony;
260#elif defined(COIN_OSI_CPX)
261 return LPSolver::CPLEX;
262#elif defined(COIN_OSI_GRB)
263 return LPSolver::Gurobi;
264#else
265# error "OGDF is compiled without LP solver. Check your build configuration."
266#endif
267 }
268
270
276 OGDF_DEPRECATED("OGDF always has COIN-OR since 2015.05")
277
278 static constexpr bool haveCoin() { return true; }
279
281
287 OGDF_DEPRECATED("OGDF always has ABACUS since 2015.05")
288
289 static constexpr bool haveAbacus() { return true; }
290
301#if defined(OGDF_MEMORY_POOL_TS)
302 return MemoryManager::PoolTS;
303#elif defined(OGDF_MEMORY_POOL_NTS)
304 return MemoryManager::PoolNTS;
305#elif defined(OGDF_MEMORY_MALLOC_TS)
306 return MemoryManager::Malloc;
307#else
308# error "OGDF is compiled without memory manager. Check your build configuration."
309#endif
310 }
311
313 static const string& toString(System sys);
314
316 static const string& toString(LPSolver lps);
317
319 static const string& toString(MemoryManager mm);
320};
321
323inline std::ostream& operator<<(std::ostream& os, Configuration::System sys) {
325 return os;
326}
327
329inline std::ostream& operator<<(std::ostream& os, Configuration::LPSolver lps) {
331 return os;
332}
333
335inline std::ostream& operator<<(std::ostream& os, Configuration::MemoryManager mm) {
337 return os;
338}
339
340}
Provides information about how OGDF has been configured.
Definition config.h:203
static constexpr System whichSystem()
Returns the operating system for which OGDF has been configured.
Definition config.h:233
static const string & toString(System sys)
Converts sys to a (readable) string.
static constexpr LPSolver whichLPSolver()
Returns the LP-solver used by OGDF.
Definition config.h:255
LPSolver
Specifies the LP-solver used by OGDF.
Definition config.h:215
static const string & toString(LPSolver lps)
Converts lps to a (readable) string.
System
Specifies the operating system for which OGDF has been configured/built.
Definition config.h:206
MemoryManager
Specifies the memory-manager used by OGDF.
Definition config.h:225
static const string & toString(MemoryManager mm)
Converts mm to a (readable) string.
static constexpr MemoryManager whichMemoryManager()
Returns the memory manager used by OGDF.
Definition config.h:300
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition config.h:101
#define OGDF_DEPRECATED(reason)
Mark a class / member / function as deprecated.
Definition config.h:120
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.
@ None
Two geometric objects do not intersect.
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
Definition Array.h:978