Open
Graph Drawing
Framework

 v. 2022.02 (Dogwood)
 

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