Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

config.h
Go to the documentation of this file.
1 
32 #pragma once
33 
35 #include <ogdf/basic/internal/config_autogen.h>
36 #include <iostream>
37 #include <string>
38 
39 namespace ogdf {
40 
41 // generally used <iostream> members
42 using std::ios;
43 using std::istream;
44 using std::ostream;
45 using std::cin;
46 using std::cout;
47 using std::cerr;
48 using std::endl;
49 using std::flush;
50 using std::swap;
51 
52 // generally used <string> members
53 using std::string;
54 
55 // detection of the system
56 
57 #if defined(unix) || defined(__unix__) || defined(__unix) || defined(_AIX) || defined(__APPLE__)
58 #define OGDF_SYSTEM_UNIX
59 #endif
60 
61 #if defined(__WIN32__) || defined(_WIN32) || defined(__NT__)
62 #define OGDF_SYSTEM_WINDOWS
63 #endif
64 
65 // Note: Apple OS X machines will be both OGDF_SYSTEM_UNIX and OGDF_SYSTEM_OSX
66 #if defined(__APPLE__)
67 #define OGDF_SYSTEM_OSX
68 #endif
69 
70 // C++11 standard
71 
72 #if __cplusplus < 201103
73 
74 #if defined(_MSC_VER)
75 #if _MSC_VER < 1700
76 #error "Compiling OGDF requires Visual C++ 11 (Visual Studio 2012) or higher!"
77 #endif
78 
79 #elif defined(__GNUC__)
80 #ifndef __GXX_EXPERIMENTAL_CXX0X__
81 #error "No C++11 support activated for g++ (compile with -std=c++0x or -std=c++11)!"
82 #endif
83 
84 #else
85 #error "Compiling OGDF requires a C++11 compliant compiler!"
86 #endif
87 
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 __cplusplus >= 201402L
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 
168 // compiler adaptions
169 
170 #ifdef _MSC_VER
171 
172 #ifdef OGDF_DLL
173 // disable useless warnings
174 // missing dll-interface
175 
176 // warning C4251: 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
177 #pragma warning(disable : 4251)
178 // warning C4275: non-DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier'
179 #pragma warning(disable : 4275)
180 #endif
181 
182 // warning C4355: 'this' : used in base member initializer list
183 #pragma warning (disable : 4355)
184 
185 #endif
186 
188 
192 public:
194  enum class System {
195  Unknown,
196  Windows,
197  Unix,
198  OSX,
199  STOP
200  };
201 
203  enum class LPSolver {
204  None,
205  Clp,
206  Symphony,
207  CPLEX,
208  Gurobi,
209  STOP
210  };
211 
213  enum class MemoryManager {
214  PoolTS,
215  PoolNTS,
216  Malloc,
217  STOP
218  };
219 
221  static constexpr System whichSystem() {
222 #ifdef OGDF_SYSTEM_WINDOWS
223  return System::Windows;
224 #elif defined(OGDF_SYSTEM_OSX)
225  return System::OSX;
226 #elif defined(OGDF_SYSTEM_UNIX)
227  return System::Unix;
228 #else
229  return System::Unknown
230 #endif
231  }
232 
234 
238  OGDF_DEPRECATED("OGDF always has LP solver support since 2015.05")
239  static constexpr bool haveLPSolver() {
240  return true;
241  }
242 
244  static constexpr LPSolver whichLPSolver() {
245 #if defined(COIN_OSI_CLP)
246  return LPSolver::Clp;
247 #elif defined(COIN_OSI_SYM)
248  return LPSolver::Symphony;
249 #elif defined(COIN_OSI_CPX)
250  return LPSolver::CPLEX;
251 #elif defined(COIN_OSI_GRB)
252  return LPSolver::Gurobi;
253 #else
254 # error "OGDF is compiled without LP solver. Check your build configuration."
255 #endif
256  }
257 
259 
265  OGDF_DEPRECATED("OGDF always has COIN-OR since 2015.05")
266  static constexpr bool haveCoin() {
267  return true;
268  }
269 
271 
277  OGDF_DEPRECATED("OGDF always has ABACUS since 2015.05")
278  static constexpr bool haveAbacus() {
279  return true;
280  }
281 
291  static constexpr MemoryManager whichMemoryManager() {
292 #if defined(OGDF_MEMORY_POOL_TS)
293  return MemoryManager::PoolTS;
294 #elif defined(OGDF_MEMORY_POOL_NTS)
295  return MemoryManager::PoolNTS;
296 #elif defined(OGDF_MEMORY_MALLOC_TS)
297  return MemoryManager::Malloc;
298 #else
299 # error "OGDF is compiled without memory manager. Check your build configuration."
300 #endif
301  }
302 
304  static const string &toString(System sys);
305 
307  static const string &toString(LPSolver lps);
308 
310  static const string &toString(MemoryManager mm);
311 };
312 
313 
315 inline ostream &operator<<(ostream &os, Configuration::System sys)
316 {
317  os << Configuration::toString(sys);
318  return os;
319 }
320 
322 inline ostream &operator<<(ostream &os, Configuration::LPSolver lps)
323 {
324  os << Configuration::toString(lps);
325  return os;
326 }
327 
329 inline ostream &operator<<(ostream &os, Configuration::MemoryManager mm)
330 {
331  os << Configuration::toString(mm);
332  return os;
333 }
334 
335 }
static constexpr MemoryManager whichMemoryManager()
Returns the memory manager used by OGDF.
Definition: config.h:291
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
Provides information about how OGDF has been configured.
Definition: config.h:191
static constexpr System whichSystem()
Returns the operating system for which OGDF has been configured.
Definition: config.h:221
ostream & operator<<(ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
Definition: Array.h:764
std::string toString(const Attribute &attr)
static const string & toString(System sys)
Converts sys to a (readable) string.
LPSolver
Specifies the LP-solver used by OGDF.
Definition: config.h:203
MemoryManager
Specifies the memory-manager used by OGDF.
Definition: config.h:213
static constexpr LPSolver whichLPSolver()
Returns the LP-solver used by OGDF.
Definition: config.h:244
#define OGDF_DEPRECATED(reason)
Mark a class / member / function as deprecated.
Definition: config.h:118
System
Specifies the operating system for which OGDF has been configured/built.
Definition: config.h:194
The namespace for all OGDF objects.