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
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++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
117#define OGDF_EXPORT
118
161#define OGDF_EXPORT_TEMPL_DECL OGDF_EXPORT
162
169#define OGDF_EXPORT_TEMPL_INST
170
178#define OGDF_LOCAL
179
180#ifdef OGDF_SYSTEM_WINDOWS
181# ifdef OGDF_DLL
182# undef OGDF_EXPORT
183# ifdef OGDF_INSTALL
184# define OGDF_EXPORT __declspec(dllexport)
185# undef OGDF_EXPORT_TEMPL_DECL
186# undef OGDF_EXPORT_TEMPL_INST
187# define OGDF_EXPORT_TEMPL_DECL
188# define OGDF_EXPORT_TEMPL_INST OGDF_EXPORT
189# else
190# define OGDF_EXPORT __declspec(dllimport)
191# endif
192# endif
193#else
194# undef OGDF_EXPORT
195# undef OGDF_LOCAL
196# define OGDF_EXPORT __attribute__((visibility("default")))
197# define OGDF_LOCAL __attribute__((visibility("hidden")))
198#endif
199
203
206#define OGDF_DEPRECATED(reason)
207
208#if OGDF_HAS_CPP_ATTRIBUTE(deprecated)
209# undef OGDF_DEPRECATED
210# define OGDF_DEPRECATED(reason) [[deprecated(reason)]]
211#elif defined(_MSC_VER)
212# undef OGDF_DEPRECATED
213# define OGDF_DEPRECATED(reason) __declspec(deprecated(reason))
214#elif defined(__GNUC__)
215# undef OGDF_DEPRECATED
216# define OGDF_DEPRECATED(reason) __attribute__((deprecated(reason)))
217#endif
218
222
225#define OGDF_DISABLE_WARNING_PUSH
226
229#define OGDF_DISABLE_WARNING_POP
230
233#define OGDF_DISABLE_WARNING(warningNumber)
234
237#define OGDF_DISABLE_WARNING_THROW_TERMINATE
238
241#define OGDF_DISABLE_WARNING_UNUSED
242
245#define OGDF_DISABLE_WARNING_DEPRECATED
246
247#if defined(_MSC_VER)
248# undef OGDF_DISABLE_WARNING_PUSH
249# undef OGDF_DISABLE_WARNING_POP
250# undef OGDF_DISABLE_WARNING
251
252# define OGDF_DISABLE_WARNING_PUSH __pragma(warning(push))
253# define OGDF_DISABLE_WARNING_POP __pragma(warning(pop))
254# define OGDF_DISABLE_WARNING(warningNumber) __pragma(warning(disable : warningNumber))
255#elif defined(__GNUC__) || defined(__clang__)
256# undef OGDF_DISABLE_WARNING_PUSH
257# undef OGDF_DISABLE_WARNING_POP
258# undef OGDF_DISABLE_WARNING
259
260# define OGDF_DO_PRAGMA(X) _Pragma(#X)
261# define OGDF_DISABLE_WARNING_PUSH OGDF_DO_PRAGMA(GCC diagnostic push)
262# define OGDF_DISABLE_WARNING_POP OGDF_DO_PRAGMA(GCC diagnostic pop)
263# define OGDF_DISABLE_WARNING(warningName) OGDF_DO_PRAGMA(GCC diagnostic ignored warningName)
264#endif
265
266#if defined(__GNUC__)
267# if defined(__clang__)
268# undef OGDF_DISABLE_WARNING_THROW_TERMINATE
269# define OGDF_DISABLE_WARNING_THROW_TERMINATE OGDF_DISABLE_WARNING("-Wexceptions")
270# else
271# undef OGDF_DISABLE_WARNING_THROW_TERMINATE
272# define OGDF_DISABLE_WARNING_THROW_TERMINATE OGDF_DISABLE_WARNING("-Wterminate")
273# endif
274# undef OGDF_DISABLE_WARNING_UNUSED
275# define OGDF_DISABLE_WARNING_UNUSED OGDF_DISABLE_WARNING("-Wunused")
276# undef OGDF_DISABLE_WARNING_DEPRECATED
277# define OGDF_DISABLE_WARNING_DEPRECATED OGDF_DISABLE_WARNING("-Wdeprecated-declarations")
278#elif defined(_MSC_VER)
279# undef OGDF_DISABLE_WARNING_THROW_TERMINATE
280# define OGDF_DISABLE_WARNING_THROW_TERMINATE OGDF_DISABLE_WARNING(4297)
281#endif
282
286
289#define OGDF_NODISCARD
290
291#if OGDF_HAS_CPP_ATTRIBUTE(nodiscard)
292# undef OGDF_NODISCARD
293# define OGDF_NODISCARD [[nodiscard]]
294#elif defined(__GNUC__)
295# undef OGDF_NODISCARD
296# define OGDF_NODISCARD __attribute__((warn_unused_result))
297#endif
298
300
303
309#define OGDF_LIKELY(x) (x)
310
316#define OGDF_UNLIKELY(x) (x)
317
320#define OGDF_DECL_ALIGN(b)
321
322#ifdef _MSC_VER // Visual C++ compiler
323# undef OGDF_DECL_ALIGN
324# define OGDF_DECL_ALIGN(b) __declspec(align(b))
325#elif defined(__GNUC__) // GNU gcc compiler (also Intel compiler)
326# undef OGDF_LIKELY
327# define OGDF_LIKELY(x) __builtin_expect((x), 1)
328# undef OGDF_UNLIKELY
329# define OGDF_UNLIKELY(x) __builtin_expect((x), 0)
330# undef OGDF_DECL_ALIGN
331# define OGDF_DECL_ALIGN(b) __attribute__((aligned(b)))
332#endif
333
335
337#define OGDF_CASE_FALLTHROUGH
338#if OGDF_HAS_CPP_ATTRIBUTE(fallthrough)
339# undef OGDF_CASE_FALLTHROUGH
340# define OGDF_CASE_FALLTHROUGH [[fallthrough]]
341#elif defined(__GNUC__) && __GNUC__ >= 7
342# undef OGDF_CASE_FALLTHROUGH
343# define OGDF_CASE_FALLTHROUGH __attribute__((fallthrough))
344#endif
345
346// compiler adaptions
347
348#ifdef _MSC_VER
349
350# ifdef OGDF_DLL
351// disable useless warnings
352// missing dll-interface
353
354// warning C4251: 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
356// warning C4275: non-DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier'
358# endif
359
360// warning C4355: 'this' : used in base member initializer list
362
363#endif
364
366
370public:
372 enum class System {
373 Unknown,
374 Windows,
375 Unix,
376 OSX,
377 STOP
378 };
379
381 enum class LPSolver {
382 None,
383 Clp,
384 Symphony,
385 CPLEX,
386 Gurobi,
387 STOP
388 };
389
391 enum class MemoryManager {
392 PoolTS,
393 PoolNTS,
394 Malloc,
395 STOP
396 };
397
399 static constexpr System whichSystem() {
400#ifdef OGDF_SYSTEM_WINDOWS
401 return System::Windows;
402#elif defined(OGDF_SYSTEM_OSX)
403 return System::OSX;
404#elif defined(OGDF_SYSTEM_UNIX)
405 return System::Unix;
406#else
407 return System::Unknown
408#endif
409 }
410
412
416 OGDF_DEPRECATED("OGDF always has LP solver support since 2015.05")
417
418 static constexpr bool haveLPSolver() { return true; }
419
421 static constexpr LPSolver whichLPSolver() {
422#if defined(COIN_OSI_CLP)
423 return LPSolver::Clp;
424#elif defined(COIN_OSI_SYM)
425 return LPSolver::Symphony;
426#elif defined(COIN_OSI_CPX)
427 return LPSolver::CPLEX;
428#elif defined(COIN_OSI_GRB)
429 return LPSolver::Gurobi;
430#else
431# error "OGDF is compiled without LP solver. Check your build configuration."
432#endif
433 }
434
436
442 OGDF_DEPRECATED("OGDF always has COIN-OR since 2015.05")
443
444 static constexpr bool haveCoin() { return true; }
445
447
453 OGDF_DEPRECATED("OGDF always has ABACUS since 2015.05")
454
455 static constexpr bool haveAbacus() { return true; }
456
467#if defined(OGDF_MEMORY_POOL_TS)
468 return MemoryManager::PoolTS;
469#elif defined(OGDF_MEMORY_POOL_NTS)
470 return MemoryManager::PoolNTS;
471#elif defined(OGDF_MEMORY_MALLOC_TS)
472 return MemoryManager::Malloc;
473#else
474# error "OGDF is compiled without memory manager. Check your build configuration."
475#endif
476 }
477
479 static const string& toString(System sys);
480
482 static const string& toString(LPSolver lps);
483
485 static const string& toString(MemoryManager mm);
486};
487
489inline std::ostream& operator<<(std::ostream& os, Configuration::System sys) {
490 os << Configuration::toString(sys);
491 return os;
492}
493
495inline std::ostream& operator<<(std::ostream& os, Configuration::LPSolver lps) {
496 os << Configuration::toString(lps);
497 return os;
498}
499
501inline std::ostream& operator<<(std::ostream& os, Configuration::MemoryManager mm) {
502 os << Configuration::toString(mm);
503 return os;
504}
505
506}
Provides information about how OGDF has been configured.
Definition config.h:369
static constexpr System whichSystem()
Returns the operating system for which OGDF has been configured.
Definition config.h:399
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:421
LPSolver
Specifies the LP-solver used by OGDF.
Definition config.h:381
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:372
MemoryManager
Specifies the memory-manager used by OGDF.
Definition config.h:391
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:466
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:117
#define OGDF_DEPRECATED(reason)
Mark a class / member / function as deprecated.
Definition config.h:206
#define OGDF_DISABLE_WARNING(warningNumber)
Disable the warning with the given number of MSVC or name of g++/clang.
Definition config.h:233
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