Open
Graph Drawing
Framework

 v. 2025.10-dev (Foxglove)
 

Loading...
Searching...
No Matches
config.h
Go to the documentation of this file.
1
32#pragma once
33
34#include <ogdf/basic/internal/config_autogen.h>
36
37#include <sstream> // IWYU pragma: keep
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#ifdef _MSVC_LANG
66# define OGDF_CPLUSPLUS _MSVC_LANG
67#else
68# define OGDF_CPLUSPLUS __cplusplus
69#endif
70
71// C++17 standard
72#if OGDF_CPLUSPLUS < 201703L
73
74# if defined(_MSC_VER)
75# error "Compiling OGDF requires C++17 (Visual Studio 2017 15.8) or higher!"
76
77# elif defined(__GNUC__)
78# error "Compiling OGDF requires C++17 (compile with -std=c++17)!"
79
80# else
81# error "Compiling OGDF requires a C++17 compliant compiler!"
82# endif
83
84#endif
85
86#ifdef __has_cpp_attribute
87# define OGDF_HAS_CPP_ATTRIBUTE(x) \
88 (__has_cpp_attribute(x) && OGDF_CPLUSPLUS >= __has_cpp_attribute(x))
89#else
90# define OGDF_HAS_CPP_ATTRIBUTE(x) 0
91#endif
92
96
118#define OGDF_EXPORT
119
162#define OGDF_EXPORT_TEMPL_DECL OGDF_EXPORT
163
170#define OGDF_EXPORT_TEMPL_INST
171
179#define OGDF_LOCAL
180
181#ifdef OGDF_SYSTEM_WINDOWS
182# ifdef OGDF_DLL
183# undef OGDF_EXPORT
184# ifdef OGDF_INSTALL
185# define OGDF_EXPORT __declspec(dllexport)
186# undef OGDF_EXPORT_TEMPL_DECL
187# undef OGDF_EXPORT_TEMPL_INST
188# define OGDF_EXPORT_TEMPL_DECL
189# define OGDF_EXPORT_TEMPL_INST OGDF_EXPORT
190# else
191# define OGDF_EXPORT __declspec(dllimport)
192# endif
193# endif
194#else
195# undef OGDF_EXPORT
196# undef OGDF_LOCAL
197# define OGDF_EXPORT __attribute__((visibility("default")))
198# define OGDF_LOCAL __attribute__((visibility("hidden")))
199#endif
200
204
207#define OGDF_DEPRECATED(reason)
208
209#if OGDF_HAS_CPP_ATTRIBUTE(deprecated)
210# undef OGDF_DEPRECATED
211# define OGDF_DEPRECATED(reason) [[deprecated(reason)]]
212#elif defined(_MSC_VER)
213# undef OGDF_DEPRECATED
214# define OGDF_DEPRECATED(reason) __declspec(deprecated(reason))
215#elif defined(__GNUC__)
216# undef OGDF_DEPRECATED
217# define OGDF_DEPRECATED(reason) __attribute__((deprecated(reason)))
218#endif
219
223
226#define OGDF_DISABLE_WARNING_PUSH
227
230#define OGDF_DISABLE_WARNING_POP
231
234#define OGDF_DISABLE_WARNING(warningNumber)
235
238#define OGDF_DISABLE_WARNING_THROW_TERMINATE
239
242#define OGDF_DISABLE_WARNING_UNUSED
243
246#define OGDF_DISABLE_WARNING_DEPRECATED
247
248#if defined(_MSC_VER)
249# undef OGDF_DISABLE_WARNING_PUSH
250# undef OGDF_DISABLE_WARNING_POP
251# undef OGDF_DISABLE_WARNING
252
253# define OGDF_DISABLE_WARNING_PUSH __pragma(warning(push))
254# define OGDF_DISABLE_WARNING_POP __pragma(warning(pop))
255# define OGDF_DISABLE_WARNING(warningNumber) __pragma(warning(disable : warningNumber))
256#elif defined(__GNUC__) || defined(__clang__)
257# undef OGDF_DISABLE_WARNING_PUSH
258# undef OGDF_DISABLE_WARNING_POP
259# undef OGDF_DISABLE_WARNING
260
261# define OGDF_DO_PRAGMA(X) _Pragma(#X)
262# define OGDF_DISABLE_WARNING_PUSH OGDF_DO_PRAGMA(GCC diagnostic push)
263# define OGDF_DISABLE_WARNING_POP OGDF_DO_PRAGMA(GCC diagnostic pop)
264# define OGDF_DISABLE_WARNING(warningName) OGDF_DO_PRAGMA(GCC diagnostic ignored warningName)
265#endif
266
267#if defined(__GNUC__)
268# if defined(__clang__)
269# undef OGDF_DISABLE_WARNING_THROW_TERMINATE
270# define OGDF_DISABLE_WARNING_THROW_TERMINATE OGDF_DISABLE_WARNING("-Wexceptions")
271# else
272# undef OGDF_DISABLE_WARNING_THROW_TERMINATE
273# define OGDF_DISABLE_WARNING_THROW_TERMINATE OGDF_DISABLE_WARNING("-Wterminate")
274# endif
275# undef OGDF_DISABLE_WARNING_UNUSED
276# define OGDF_DISABLE_WARNING_UNUSED OGDF_DISABLE_WARNING("-Wunused")
277# undef OGDF_DISABLE_WARNING_DEPRECATED
278# define OGDF_DISABLE_WARNING_DEPRECATED OGDF_DISABLE_WARNING("-Wdeprecated-declarations")
279#elif defined(_MSC_VER)
280# undef OGDF_DISABLE_WARNING_THROW_TERMINATE
281# define OGDF_DISABLE_WARNING_THROW_TERMINATE OGDF_DISABLE_WARNING(4297)
282#endif
283
287
290#define OGDF_NODISCARD
291
292#if OGDF_HAS_CPP_ATTRIBUTE(nodiscard)
293# undef OGDF_NODISCARD
294# define OGDF_NODISCARD [[nodiscard]]
295#elif defined(__GNUC__)
296# undef OGDF_NODISCARD
297# define OGDF_NODISCARD __attribute__((warn_unused_result))
298#endif
299
301
304
310#define OGDF_LIKELY(x) (x)
311
317#define OGDF_UNLIKELY(x) (x)
318
321#define OGDF_DECL_ALIGN(b)
322
323#ifdef _MSC_VER // Visual C++ compiler
324# undef OGDF_DECL_ALIGN
325# define OGDF_DECL_ALIGN(b) __declspec(align(b))
326#elif defined(__GNUC__) // GNU gcc compiler (also Intel compiler)
327# undef OGDF_LIKELY
328# define OGDF_LIKELY(x) __builtin_expect((x), 1)
329# undef OGDF_UNLIKELY
330# define OGDF_UNLIKELY(x) __builtin_expect((x), 0)
331# undef OGDF_DECL_ALIGN
332# define OGDF_DECL_ALIGN(b) __attribute__((aligned(b)))
333#endif
334
336
338#define OGDF_CASE_FALLTHROUGH
339#if OGDF_HAS_CPP_ATTRIBUTE(fallthrough)
340# undef OGDF_CASE_FALLTHROUGH
341# define OGDF_CASE_FALLTHROUGH [[fallthrough]]
342#elif defined(__GNUC__) && __GNUC__ >= 7
343# undef OGDF_CASE_FALLTHROUGH
344# define OGDF_CASE_FALLTHROUGH __attribute__((fallthrough))
345#endif
346
347// compiler adaptions
348
349#ifdef _MSC_VER
350
351# ifdef OGDF_DLL
352// disable useless warnings
353// missing dll-interface
354
355// warning C4251: 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
357// warning C4275: non-DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier'
359# endif
360
361// warning C4355: 'this' : used in base member initializer list
363
364#endif
365
367
371public:
373 enum class System {
374 Unknown,
375 Windows,
376 Unix,
377 OSX,
378 STOP
379 };
380
382 enum class LPSolver {
383 None,
384 Clp,
385 Symphony,
386 CPLEX,
387 Gurobi,
388 STOP
389 };
390
392 enum class MemoryManager {
393 PoolTS,
394 PoolNTS,
395 Malloc,
396 STOP
397 };
398
400 static constexpr System whichSystem() {
401#ifdef OGDF_SYSTEM_WINDOWS
402 return System::Windows;
403#elif defined(OGDF_SYSTEM_OSX)
404 return System::OSX;
405#elif defined(OGDF_SYSTEM_UNIX)
406 return System::Unix;
407#else
408 return System::Unknown
409#endif
410 }
411
413
417 OGDF_DEPRECATED("OGDF always has LP solver support since 2015.05")
418
419 static constexpr bool haveLPSolver() { return true; }
420
422 static constexpr LPSolver whichLPSolver() {
423#if defined(COIN_OSI_CLP)
424 return LPSolver::Clp;
425#elif defined(COIN_OSI_SYM)
426 return LPSolver::Symphony;
427#elif defined(COIN_OSI_CPX)
428 return LPSolver::CPLEX;
429#elif defined(COIN_OSI_GRB)
430 return LPSolver::Gurobi;
431#else
432# error "OGDF is compiled without LP solver. Check your build configuration."
433#endif
434 }
435
437
443 OGDF_DEPRECATED("OGDF always has COIN-OR since 2015.05")
444
445 static constexpr bool haveCoin() { return true; }
446
448
454 OGDF_DEPRECATED("OGDF always has ABACUS since 2015.05")
455
456 static constexpr bool haveAbacus() { return true; }
457
468#if defined(OGDF_MEMORY_POOL_TS)
469 return MemoryManager::PoolTS;
470#elif defined(OGDF_MEMORY_POOL_NTS)
471 return MemoryManager::PoolNTS;
472#elif defined(OGDF_MEMORY_MALLOC_TS)
473 return MemoryManager::Malloc;
474#else
475# error "OGDF is compiled without memory manager. Check your build configuration."
476#endif
477 }
478
480 static const string& toString(System sys);
481
483 static const string& toString(LPSolver lps);
484
486 static const string& toString(MemoryManager mm);
487};
488
490inline std::ostream& operator<<(std::ostream& os, Configuration::System sys) {
491 os << Configuration::toString(sys);
492 return os;
493}
494
496inline std::ostream& operator<<(std::ostream& os, Configuration::LPSolver lps) {
497 os << Configuration::toString(lps);
498 return os;
499}
500
502inline std::ostream& operator<<(std::ostream& os, Configuration::MemoryManager mm) {
503 os << Configuration::toString(mm);
504 return os;
505}
506
507}
Provides information about how OGDF has been configured.
Definition config.h:370
static constexpr System whichSystem()
Returns the operating system for which OGDF has been configured.
Definition config.h:400
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:422
LPSolver
Specifies the LP-solver used by OGDF.
Definition config.h:382
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:373
MemoryManager
Specifies the memory-manager used by OGDF.
Definition config.h:392
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:467
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:118
#define OGDF_DEPRECATED(reason)
Mark a class / member / function as deprecated.
Definition config.h:207
#define OGDF_DISABLE_WARNING(warningNumber)
Disable the warning with the given number of MSVC or name of g++/clang.
Definition config.h:234
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:983