Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Useful Macros

Several useful macros defined by the OGDF. More...

Macros

#define OGDF_SIZEOF_POINTER   8
 The size of a pointer. More...
 

Assertions (only active in debug builds)

#define OGDF_ASSERT(expr)
 Assert condition expr. See doc/build.md for more information. More...
 
#define OGDF_ASSERT(expr)   assert(expr)
 Assert condition expr. See doc/build.md for more information. More...
 
#define OGDF_HEAVY_ASSERT(expr)
 Assert condition expr when using heavy debugging. See OGDF_ASSERT. More...
 
#define OGDF_IF_DBG(x)
 Single statement that will only be compiled if OGDF_DEBUG is defined. More...
 
#define OGDF_IF_DBG(x)   x
 Single statement that will only be compiled if OGDF_DEBUG is defined. More...
 

Throwing exceptions

#define OGDF_THROW_PARAM(CLASS, PARAM)   OGDF_FLUSH_OUTPUTS, throw CLASS(PARAM)
 Replacement for throw. More...
 
#define OGDF_THROW_PARAM(CLASS, PARAM)   OGDF_FLUSH_OUTPUTS, throw CLASS(PARAM, __FILE__, __LINE__)
 Replacement for throw. More...
 
#define OGDF_THROW(CLASS)   OGDF_FLUSH_OUTPUTS, throw CLASS()
 Replacement for throw. More...
 
#define OGDF_THROW(CLASS)   OGDF_FLUSH_OUTPUTS, throw CLASS(__FILE__, __LINE__)
 Replacement for throw. More...
 

Deprecation

#define OGDF_DEPRECATED(reason)
 Mark a class / member / function as deprecated. More...
 

Macros for locally disabling compiler warnings

#define OGDF_DISABLE_WARNING_PUSH
 Start a new warning configuration context (i.e. do pragma diagnostic/warning push) More...
 
#define OGDF_DISABLE_WARNING_POP
 End the current warning configuration context (i.e. do pragma diagnostic/warning pop) More...
 
#define OGDF_DISABLE_WARNING(warningNumber)
 Disable the warning with the given number of MSVC or name of g++/clang. More...
 
#define OGDF_DISABLE_WARNING_THROW_TERMINATE
 Disable the warning that calling throw will always terminate the program in a noexept block. More...
 
#define OGDF_DISABLE_WARNING_UNUSED
 Disable the warning that something is unused. More...
 
#define OGDF_DISABLE_WARNING_DEPRECATED
 Disable deprecation warnings. More...
 

Unused results

#define OGDF_NODISCARD
 Indicate that the result of a function call should not be discarded. More...
 

Optimization

#define OGDF_LIKELY(x)   (x)
 Specify the likely branch in a condition. More...
 
#define OGDF_UNLIKELY(x)   (x)
 Specify the unlikely branch in a condition. More...
 
#define OGDF_DECL_ALIGN(b)
 Specify the minimum alignment (in bytes) of a type to be b. This is used in type declarations. More...
 

Managing memory

#define OGDF_NEW_DELETE   OGDF_MM(OGDF_ALLOCATOR)
 Makes the class use OGDF's memory allocator. More...
 
#define OGDF_MALLOC_NEW_DELETE   OGDF_MM(ogdf::MallocMemoryAllocator)
 Makes the class use malloc for memory allocation. More...
 

Detailed Description

Several useful macros defined by the OGDF.

Macro Definition Documentation

◆ OGDF_ASSERT [1/2]

#define OGDF_ASSERT (   expr)

Assert condition expr. See doc/build.md for more information.

Definition at line 54 of file basic.h.

◆ OGDF_ASSERT [2/2]

#define OGDF_ASSERT (   expr)    assert(expr)

Assert condition expr. See doc/build.md for more information.

Definition at line 54 of file basic.h.

◆ OGDF_DECL_ALIGN

#define OGDF_DECL_ALIGN (   b)

Specify the minimum alignment (in bytes) of a type to be b. This is used in type declarations.

Definition at line 234 of file config.h.

◆ OGDF_DEPRECATED

#define OGDF_DEPRECATED (   reason)

Mark a class / member / function as deprecated.

Definition at line 120 of file config.h.

◆ OGDF_DISABLE_WARNING

#define OGDF_DISABLE_WARNING (   warningNumber)

Disable the warning with the given number of MSVC or name of g++/clang.

Definition at line 147 of file config.h.

◆ OGDF_DISABLE_WARNING_DEPRECATED

#define OGDF_DISABLE_WARNING_DEPRECATED

Disable deprecation warnings.

Definition at line 159 of file config.h.

◆ OGDF_DISABLE_WARNING_POP

#define OGDF_DISABLE_WARNING_POP

End the current warning configuration context (i.e. do pragma diagnostic/warning pop)

Definition at line 143 of file config.h.

◆ OGDF_DISABLE_WARNING_PUSH

#define OGDF_DISABLE_WARNING_PUSH

Start a new warning configuration context (i.e. do pragma diagnostic/warning push)

Definition at line 139 of file config.h.

◆ OGDF_DISABLE_WARNING_THROW_TERMINATE

#define OGDF_DISABLE_WARNING_THROW_TERMINATE

Disable the warning that calling throw will always terminate the program in a noexept block.

Definition at line 151 of file config.h.

◆ OGDF_DISABLE_WARNING_UNUSED

#define OGDF_DISABLE_WARNING_UNUSED

Disable the warning that something is unused.

Definition at line 155 of file config.h.

◆ OGDF_HEAVY_ASSERT

#define OGDF_HEAVY_ASSERT (   expr)

Assert condition expr when using heavy debugging. See OGDF_ASSERT.

Definition at line 44 of file basic.h.

◆ OGDF_IF_DBG [1/2]

#define OGDF_IF_DBG (   x)

Single statement that will only be compiled if OGDF_DEBUG is defined.

Definition at line 90 of file basic.h.

◆ OGDF_IF_DBG [2/2]

#define OGDF_IF_DBG (   x)    x

Single statement that will only be compiled if OGDF_DEBUG is defined.

Definition at line 90 of file basic.h.

◆ OGDF_LIKELY

#define OGDF_LIKELY (   x)    (x)

Specify the likely branch in a condition.

Usage:

if (OGDF_LIKELY(i >= 0)) { likely branch } else { unlikely branch }

Definition at line 223 of file config.h.

◆ OGDF_MALLOC_NEW_DELETE

#define OGDF_MALLOC_NEW_DELETE   OGDF_MM(ogdf::MallocMemoryAllocator)

Makes the class use malloc for memory allocation.

Creates new and delete operators in a class using the given memory allocator. In other words, adding this macro in a class declaration makes that class managed by the respective memory manager. Throws an ogdf::InsufficientMemoryException if no more memory is available.

Definition at line 91 of file memory.h.

◆ OGDF_NEW_DELETE

#define OGDF_NEW_DELETE   OGDF_MM(OGDF_ALLOCATOR)

Makes the class use OGDF's memory allocator.

Creates new and delete operators in a class using the given memory allocator. In other words, adding this macro in a class declaration makes that class managed by the respective memory manager. Throws an ogdf::InsufficientMemoryException if no more memory is available.

Definition at line 84 of file memory.h.

◆ OGDF_NODISCARD

#define OGDF_NODISCARD

Indicate that the result of a function call should not be discarded.

Definition at line 203 of file config.h.

◆ OGDF_SIZEOF_POINTER

#define OGDF_SIZEOF_POINTER   8

The size of a pointer.

Definition at line 25 of file config_autogen.h.

◆ OGDF_THROW [1/2]

#define OGDF_THROW (   CLASS)    OGDF_FLUSH_OUTPUTS, throw CLASS()

Replacement for throw.

This macro is used to throw an exception and pass the file name and line number of the location in the source file (in Debug mode only).

Parameters
CLASSis the name of the exception class.

Definition at line 70 of file exceptions.h.

◆ OGDF_THROW [2/2]

#define OGDF_THROW (   CLASS)    OGDF_FLUSH_OUTPUTS, throw CLASS(__FILE__, __LINE__)

Replacement for throw.

This macro is used to throw an exception and pass the file name and line number of the location in the source file (in Debug mode only).

Parameters
CLASSis the name of the exception class.

Definition at line 70 of file exceptions.h.

◆ OGDF_THROW_PARAM [1/2]

#define OGDF_THROW_PARAM (   CLASS,
  PARAM 
)    OGDF_FLUSH_OUTPUTS, throw CLASS(PARAM)

Replacement for throw.

This macro is used to throw an exception and pass the file name and line number of the location in the source file (in Debug mode only).

Parameters
CLASSis the name of the exception class.
PARAMis an additional parameter (like the error code) required by the exception calls.

Definition at line 67 of file exceptions.h.

◆ OGDF_THROW_PARAM [2/2]

#define OGDF_THROW_PARAM (   CLASS,
  PARAM 
)    OGDF_FLUSH_OUTPUTS, throw CLASS(PARAM, __FILE__, __LINE__)

Replacement for throw.

This macro is used to throw an exception and pass the file name and line number of the location in the source file (in Debug mode only).

Parameters
CLASSis the name of the exception class.
PARAMis an additional parameter (like the error code) required by the exception calls.

Definition at line 67 of file exceptions.h.

◆ OGDF_UNLIKELY

#define OGDF_UNLIKELY (   x)    (x)

Specify the unlikely branch in a condition.

Usage:

if (OGDF_UNLIKELY(set.empty())) { unlikely branch } else { likely branch }

Definition at line 230 of file config.h.

OGDF_LIKELY
#define OGDF_LIKELY(x)
Specify the likely branch in a condition.
Definition: config.h:223
OGDF_UNLIKELY
#define OGDF_UNLIKELY(x)
Specify the unlikely branch in a condition.
Definition: config.h:230