Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

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 
44 namespace ogdf {
45 
46 // generally used <string> members
47 using std::string;
48 using 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 
136 
139 #define OGDF_DISABLE_WARNING_PUSH
140 
143 #define OGDF_DISABLE_WARNING_POP
144 
147 #define OGDF_DISABLE_WARNING(warningNumber)
148 
151 #define OGDF_DISABLE_WARNING_THROW_TERMINATE
152 
155 #define OGDF_DISABLE_WARNING_UNUSED
156 
159 #define OGDF_DISABLE_WARNING_DEPRECATED
160 
161 #if defined(_MSC_VER)
162 # undef OGDF_DISABLE_WARNING_PUSH
163 # undef OGDF_DISABLE_WARNING_POP
164 # undef OGDF_DISABLE_WARNING
165 
166 # define OGDF_DISABLE_WARNING_PUSH __pragma(warning(push))
167 # define OGDF_DISABLE_WARNING_POP __pragma(warning(pop))
168 # define OGDF_DISABLE_WARNING(warningNumber) __pragma(warning(disable : warningNumber))
169 #elif defined(__GNUC__) || defined(__clang__)
170 # undef OGDF_DISABLE_WARNING_PUSH
171 # undef OGDF_DISABLE_WARNING_POP
172 # undef OGDF_DISABLE_WARNING
173 
174 # define OGDF_DO_PRAGMA(X) _Pragma(#X)
175 # define OGDF_DISABLE_WARNING_PUSH OGDF_DO_PRAGMA(GCC diagnostic push)
176 # define OGDF_DISABLE_WARNING_POP OGDF_DO_PRAGMA(GCC diagnostic pop)
177 # define OGDF_DISABLE_WARNING(warningName) OGDF_DO_PRAGMA(GCC diagnostic ignored warningName)
178 #endif
179 
180 #if defined(__GNUC__)
181 # if defined(__clang__)
182 # undef OGDF_DISABLE_WARNING_THROW_TERMINATE
183 # define OGDF_DISABLE_WARNING_THROW_TERMINATE OGDF_DISABLE_WARNING("-Wexceptions")
184 # else
185 # undef OGDF_DISABLE_WARNING_THROW_TERMINATE
186 # define OGDF_DISABLE_WARNING_THROW_TERMINATE OGDF_DISABLE_WARNING("-Wterminate")
187 # endif
188 # undef OGDF_DISABLE_WARNING_UNUSED
189 # define OGDF_DISABLE_WARNING_UNUSED OGDF_DISABLE_WARNING("-Wunused")
190 # undef OGDF_DISABLE_WARNING_DEPRECATED
191 # define OGDF_DISABLE_WARNING_DEPRECATED OGDF_DISABLE_WARNING("-Wdeprecated-declarations")
192 #elif defined(_MSC_VER)
193 # undef OGDF_DISABLE_WARNING_THROW_TERMINATE
194 # define OGDF_DISABLE_WARNING_THROW_TERMINATE OGDF_DISABLE_WARNING(4297)
195 #endif
196 
200 
203 #define OGDF_NODISCARD
204 
205 #if OGDF_HAS_CPP_ATTRIBUTE(nodiscard)
206 # undef OGDF_NODISCARD
207 # define OGDF_NODISCARD [[nodiscard]]
208 #elif defined(__GNUC__)
209 # undef OGDF_NODISCARD
210 # define OGDF_NODISCARD __attribute__((warn_unused_result))
211 #endif
212 
214 
217 
223 #define OGDF_LIKELY(x) (x)
224 
230 #define OGDF_UNLIKELY(x) (x)
231 
234 #define OGDF_DECL_ALIGN(b)
235 
236 #ifdef _MSC_VER // Visual C++ compiler
237 # undef OGDF_DECL_ALIGN
238 # define OGDF_DECL_ALIGN(b) __declspec(align(b))
239 #elif defined(__GNUC__) // GNU gcc compiler (also Intel compiler)
240 # undef OGDF_LIKELY
241 # define OGDF_LIKELY(x) __builtin_expect((x), 1)
242 # undef OGDF_UNLIKELY
243 # define OGDF_UNLIKELY(x) __builtin_expect((x), 0)
244 # undef OGDF_DECL_ALIGN
245 # define OGDF_DECL_ALIGN(b) __attribute__((aligned(b)))
246 #endif
247 
249 
251 #define OGDF_CASE_FALLTHROUGH
252 #if OGDF_HAS_CPP_ATTRIBUTE(fallthrough)
253 # undef OGDF_CASE_FALLTHROUGH
254 # define OGDF_CASE_FALLTHROUGH [[fallthrough]]
255 #elif defined(__GNUC__) && __GNUC__ >= 7
256 # undef OGDF_CASE_FALLTHROUGH
257 # define OGDF_CASE_FALLTHROUGH __attribute__((fallthrough))
258 #endif
259 
260 // compiler adaptions
261 
262 #ifdef _MSC_VER
263 
264 # ifdef OGDF_DLL
265 // disable useless warnings
266 // missing dll-interface
267 
268 // warning C4251: 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
270 // warning C4275: non-DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier'
272 # endif
273 
274 // warning C4355: 'this' : used in base member initializer list
276 
277 #endif
278 
280 
284 public:
286  enum class System {
287  Unknown,
288  Windows,
289  Unix,
290  OSX,
291  STOP
292  };
293 
295  enum class LPSolver {
296  None,
297  Clp,
298  Symphony,
299  CPLEX,
300  Gurobi,
301  STOP
302  };
303 
305  enum class MemoryManager {
306  PoolTS,
307  PoolNTS,
308  Malloc,
309  STOP
310  };
311 
313  static constexpr System whichSystem() {
314 #ifdef OGDF_SYSTEM_WINDOWS
315  return System::Windows;
316 #elif defined(OGDF_SYSTEM_OSX)
317  return System::OSX;
318 #elif defined(OGDF_SYSTEM_UNIX)
319  return System::Unix;
320 #else
321  return System::Unknown
322 #endif
323  }
324 
326 
330  OGDF_DEPRECATED("OGDF always has LP solver support since 2015.05")
331 
332  static constexpr bool haveLPSolver() { return true; }
333 
335  static constexpr LPSolver whichLPSolver() {
336 #if defined(COIN_OSI_CLP)
337  return LPSolver::Clp;
338 #elif defined(COIN_OSI_SYM)
339  return LPSolver::Symphony;
340 #elif defined(COIN_OSI_CPX)
341  return LPSolver::CPLEX;
342 #elif defined(COIN_OSI_GRB)
343  return LPSolver::Gurobi;
344 #else
345 # error "OGDF is compiled without LP solver. Check your build configuration."
346 #endif
347  }
348 
350 
356  OGDF_DEPRECATED("OGDF always has COIN-OR since 2015.05")
357 
358  static constexpr bool haveCoin() { return true; }
359 
361 
367  OGDF_DEPRECATED("OGDF always has ABACUS since 2015.05")
368 
369  static constexpr bool haveAbacus() { return true; }
370 
380  static constexpr MemoryManager whichMemoryManager() {
381 #if defined(OGDF_MEMORY_POOL_TS)
382  return MemoryManager::PoolTS;
383 #elif defined(OGDF_MEMORY_POOL_NTS)
384  return MemoryManager::PoolNTS;
385 #elif defined(OGDF_MEMORY_MALLOC_TS)
386  return MemoryManager::Malloc;
387 #else
388 # error "OGDF is compiled without memory manager. Check your build configuration."
389 #endif
390  }
391 
393  static const string& toString(System sys);
394 
396  static const string& toString(LPSolver lps);
397 
399  static const string& toString(MemoryManager mm);
400 };
401 
403 inline std::ostream& operator<<(std::ostream& os, Configuration::System sys) {
404  os << Configuration::toString(sys);
405  return os;
406 }
407 
409 inline std::ostream& operator<<(std::ostream& os, Configuration::LPSolver lps) {
410  os << Configuration::toString(lps);
411  return os;
412 }
413 
415 inline std::ostream& operator<<(std::ostream& os, Configuration::MemoryManager mm) {
416  os << Configuration::toString(mm);
417  return os;
418 }
419 
420 }
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::Configuration::LPSolver
LPSolver
Specifies the LP-solver used by OGDF.
Definition: config.h:295
ogdf::Configuration::toString
static const string & toString(System sys)
Converts sys to a (readable) string.
OGDF_DEPRECATED
#define OGDF_DEPRECATED(reason)
Mark a class / member / function as deprecated.
Definition: config.h:120
ogdf::Configuration::MemoryManager
MemoryManager
Specifies the memory-manager used by OGDF.
Definition: config.h:305
ogdf::Configuration::System
System
Specifies the operating system for which OGDF has been configured/built.
Definition: config.h:286
ogdf::Configuration::whichLPSolver
static constexpr LPSolver whichLPSolver()
Returns the LP-solver used by OGDF.
Definition: config.h:335
version.h
ogdf::AlgorithmFailureCode::Unknown
@ Unknown
ogdf::LPSolver
Definition: LPSolver.h:40
ogdf::Configuration
Provides information about how OGDF has been configured.
Definition: config.h:283
OGDF_DISABLE_WARNING
#define OGDF_DISABLE_WARNING(warningNumber)
Disable the warning with the given number of MSVC or name of g++/clang.
Definition: config.h:147
ogdf::operator<<
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
Definition: Array.h:978
config_autogen.h
ogdf::Configuration::whichMemoryManager
static constexpr MemoryManager whichMemoryManager()
Returns the memory manager used by OGDF.
Definition: config.h:380
ogdf::toString
string toString(FromClass key)
Definition: graphics.h:557
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::System
System specific functionality.
Definition: System.h:121
ogdf::AlgorithmFailureCode::STOP
@ STOP
ogdf::IntersectionType::None
@ None
Two geometric objects do not intersect.
ogdf::sync_plan::internal::to_string
std::string to_string(const std::function< std::ostream &(std::ostream &)> &func)
ogdf::Configuration::whichSystem
static constexpr System whichSystem()
Returns the operating system for which OGDF has been configured.
Definition: config.h:313