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// C++17 standard
66#if __cplusplus < 201703
67
68# if defined(_MSC_VER)
69# if _MSC_VER < 1915
70# error "Compiling OGDF requires C++17 (Visual Studio 2017 15.8) or higher!"
71# endif
72
73# elif defined(__GNUC__)
74# error "Compiling OGDF requires C++17 (compile with -std=c++17)!"
75
76# else
77# error "Compiling OGDF requires a C++17 compliant compiler!"
78# endif
79
80#endif
81
82#ifdef __has_cpp_attribute
83# define OGDF_HAS_CPP_ATTRIBUTE(x) \
84 (__has_cpp_attribute(x) && __cplusplus >= __has_cpp_attribute(x))
85#else
86# define OGDF_HAS_CPP_ATTRIBUTE(x) 0
87#endif
88
92
114#define OGDF_EXPORT
115
158#define OGDF_EXPORT_TEMPL_DECL OGDF_EXPORT
159
166#define OGDF_EXPORT_TEMPL_INST
167
175#define OGDF_LOCAL
176
177#ifdef OGDF_SYSTEM_WINDOWS
178# ifdef OGDF_DLL
179# undef OGDF_EXPORT
180# ifdef OGDF_INSTALL
181# define OGDF_EXPORT __declspec(dllexport)
182# undef OGDF_EXPORT_TEMPL_DECL
183# undef OGDF_EXPORT_TEMPL_INST
184# define OGDF_EXPORT_TEMPL_DECL
185# define OGDF_EXPORT_TEMPL_INST OGDF_EXPORT
186# else
187# define OGDF_EXPORT __declspec(dllimport)
188# endif
189# endif
190#else
191# undef OGDF_EXPORT
192# undef OGDF_LOCAL
193# define OGDF_EXPORT __attribute__((visibility("default")))
194# define OGDF_LOCAL __attribute__((visibility("hidden")))
195#endif
196
200
203#define OGDF_DEPRECATED(reason)
204
205#if OGDF_HAS_CPP_ATTRIBUTE(deprecated)
206# undef OGDF_DEPRECATED
207# define OGDF_DEPRECATED(reason) [[deprecated(reason)]]
208#elif defined(_MSC_VER)
209# undef OGDF_DEPRECATED
210# define OGDF_DEPRECATED(reason) __declspec(deprecated(reason))
211#elif defined(__GNUC__)
212# undef OGDF_DEPRECATED
213# define OGDF_DEPRECATED(reason) __attribute__((deprecated(reason)))
214#endif
215
219
222#define OGDF_DISABLE_WARNING_PUSH
223
226#define OGDF_DISABLE_WARNING_POP
227
230#define OGDF_DISABLE_WARNING(warningNumber)
231
234#define OGDF_DISABLE_WARNING_THROW_TERMINATE
235
238#define OGDF_DISABLE_WARNING_UNUSED
239
242#define OGDF_DISABLE_WARNING_DEPRECATED
243
244#if defined(_MSC_VER)
245# undef OGDF_DISABLE_WARNING_PUSH
246# undef OGDF_DISABLE_WARNING_POP
247# undef OGDF_DISABLE_WARNING
248
249# define OGDF_DISABLE_WARNING_PUSH __pragma(warning(push))
250# define OGDF_DISABLE_WARNING_POP __pragma(warning(pop))
251# define OGDF_DISABLE_WARNING(warningNumber) __pragma(warning(disable : warningNumber))
252#elif defined(__GNUC__) || defined(__clang__)
253# undef OGDF_DISABLE_WARNING_PUSH
254# undef OGDF_DISABLE_WARNING_POP
255# undef OGDF_DISABLE_WARNING
256
257# define OGDF_DO_PRAGMA(X) _Pragma(#X)
258# define OGDF_DISABLE_WARNING_PUSH OGDF_DO_PRAGMA(GCC diagnostic push)
259# define OGDF_DISABLE_WARNING_POP OGDF_DO_PRAGMA(GCC diagnostic pop)
260# define OGDF_DISABLE_WARNING(warningName) OGDF_DO_PRAGMA(GCC diagnostic ignored warningName)
261#endif
262
263#if defined(__GNUC__)
264# if defined(__clang__)
265# undef OGDF_DISABLE_WARNING_THROW_TERMINATE
266# define OGDF_DISABLE_WARNING_THROW_TERMINATE OGDF_DISABLE_WARNING("-Wexceptions")
267# else
268# undef OGDF_DISABLE_WARNING_THROW_TERMINATE
269# define OGDF_DISABLE_WARNING_THROW_TERMINATE OGDF_DISABLE_WARNING("-Wterminate")
270# endif
271# undef OGDF_DISABLE_WARNING_UNUSED
272# define OGDF_DISABLE_WARNING_UNUSED OGDF_DISABLE_WARNING("-Wunused")
273# undef OGDF_DISABLE_WARNING_DEPRECATED
274# define OGDF_DISABLE_WARNING_DEPRECATED OGDF_DISABLE_WARNING("-Wdeprecated-declarations")
275#elif defined(_MSC_VER)
276# undef OGDF_DISABLE_WARNING_THROW_TERMINATE
277# define OGDF_DISABLE_WARNING_THROW_TERMINATE OGDF_DISABLE_WARNING(4297)
278#endif
279
283
286#define OGDF_NODISCARD
287
288#if OGDF_HAS_CPP_ATTRIBUTE(nodiscard)
289# undef OGDF_NODISCARD
290# define OGDF_NODISCARD [[nodiscard]]
291#elif defined(__GNUC__)
292# undef OGDF_NODISCARD
293# define OGDF_NODISCARD __attribute__((warn_unused_result))
294#endif
295
297
300
306#define OGDF_LIKELY(x) (x)
307
313#define OGDF_UNLIKELY(x) (x)
314
317#define OGDF_DECL_ALIGN(b)
318
319#ifdef _MSC_VER // Visual C++ compiler
320# undef OGDF_DECL_ALIGN
321# define OGDF_DECL_ALIGN(b) __declspec(align(b))
322#elif defined(__GNUC__) // GNU gcc compiler (also Intel compiler)
323# undef OGDF_LIKELY
324# define OGDF_LIKELY(x) __builtin_expect((x), 1)
325# undef OGDF_UNLIKELY
326# define OGDF_UNLIKELY(x) __builtin_expect((x), 0)
327# undef OGDF_DECL_ALIGN
328# define OGDF_DECL_ALIGN(b) __attribute__((aligned(b)))
329#endif
330
332
334#define OGDF_CASE_FALLTHROUGH
335#if OGDF_HAS_CPP_ATTRIBUTE(fallthrough)
336# undef OGDF_CASE_FALLTHROUGH
337# define OGDF_CASE_FALLTHROUGH [[fallthrough]]
338#elif defined(__GNUC__) && __GNUC__ >= 7
339# undef OGDF_CASE_FALLTHROUGH
340# define OGDF_CASE_FALLTHROUGH __attribute__((fallthrough))
341#endif
342
343// compiler adaptions
344
345#ifdef _MSC_VER
346
347# ifdef OGDF_DLL
348// disable useless warnings
349// missing dll-interface
350
351// warning C4251: 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
353// warning C4275: non-DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier'
355# endif
356
357// warning C4355: 'this' : used in base member initializer list
359
360#endif
361
363
367public:
369 enum class System {
370 Unknown,
371 Windows,
372 Unix,
373 OSX,
374 STOP
375 };
376
378 enum class LPSolver {
379 None,
380 Clp,
381 Symphony,
382 CPLEX,
383 Gurobi,
384 STOP
385 };
386
388 enum class MemoryManager {
389 PoolTS,
390 PoolNTS,
391 Malloc,
392 STOP
393 };
394
396 static constexpr System whichSystem() {
397#ifdef OGDF_SYSTEM_WINDOWS
398 return System::Windows;
399#elif defined(OGDF_SYSTEM_OSX)
400 return System::OSX;
401#elif defined(OGDF_SYSTEM_UNIX)
402 return System::Unix;
403#else
404 return System::Unknown
405#endif
406 }
407
409
413 OGDF_DEPRECATED("OGDF always has LP solver support since 2015.05")
414
415 static constexpr bool haveLPSolver() { return true; }
416
418 static constexpr LPSolver whichLPSolver() {
419#if defined(COIN_OSI_CLP)
420 return LPSolver::Clp;
421#elif defined(COIN_OSI_SYM)
422 return LPSolver::Symphony;
423#elif defined(COIN_OSI_CPX)
424 return LPSolver::CPLEX;
425#elif defined(COIN_OSI_GRB)
426 return LPSolver::Gurobi;
427#else
428# error "OGDF is compiled without LP solver. Check your build configuration."
429#endif
430 }
431
433
439 OGDF_DEPRECATED("OGDF always has COIN-OR since 2015.05")
440
441 static constexpr bool haveCoin() { return true; }
442
444
450 OGDF_DEPRECATED("OGDF always has ABACUS since 2015.05")
451
452 static constexpr bool haveAbacus() { return true; }
453
464#if defined(OGDF_MEMORY_POOL_TS)
465 return MemoryManager::PoolTS;
466#elif defined(OGDF_MEMORY_POOL_NTS)
467 return MemoryManager::PoolNTS;
468#elif defined(OGDF_MEMORY_MALLOC_TS)
469 return MemoryManager::Malloc;
470#else
471# error "OGDF is compiled without memory manager. Check your build configuration."
472#endif
473 }
474
476 static const string& toString(System sys);
477
479 static const string& toString(LPSolver lps);
480
482 static const string& toString(MemoryManager mm);
483};
484
486inline std::ostream& operator<<(std::ostream& os, Configuration::System sys) {
487 os << Configuration::toString(sys);
488 return os;
489}
490
492inline std::ostream& operator<<(std::ostream& os, Configuration::LPSolver lps) {
493 os << Configuration::toString(lps);
494 return os;
495}
496
498inline std::ostream& operator<<(std::ostream& os, Configuration::MemoryManager mm) {
499 os << Configuration::toString(mm);
500 return os;
501}
502
503}
Provides information about how OGDF has been configured.
Definition config.h:366
static constexpr System whichSystem()
Returns the operating system for which OGDF has been configured.
Definition config.h:396
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:418
LPSolver
Specifies the LP-solver used by OGDF.
Definition config.h:378
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:369
MemoryManager
Specifies the memory-manager used by OGDF.
Definition config.h:388
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:463
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:114
#define OGDF_DEPRECATED(reason)
Mark a class / member / function as deprecated.
Definition config.h:203
#define OGDF_DISABLE_WARNING(warningNumber)
Disable the warning with the given number of MSVC or name of g++/clang.
Definition config.h:230
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