IMP
2.2.1
The Integrative Modeling Platform
|
Exception definitions and assertions. More...
#include <IMP/base/base_config.h>
#include "exception.h"
#include "compiler_macros.h"
#include <iostream>
#include <cmath>
Go to the source code of this file.
Macros | |
#define | IMP_ALWAYS_CHECK(condition, message, exception_name) |
Throw an exception if a check fails. More... | |
#define | IMP_CATCH_AND_TERMINATE(expr) |
#define | IMP_CHECK_CODE(expr) |
Only compile the code if checks are enabled. More... | |
#define | IMP_CHECK_OBJECT(obj) IMP_UNUSED(obj) |
Perform some basic validity checks on the object for memory debugging. | |
#define | IMP_CHECK_OBJECT_IF_NOT_nullptr(obj) IMP_UNUSED(obj) |
#define | IMP_FAILURE(message) |
A runtime failure for IMP. More... | |
#define | IMP_IF_CHECK(level) |
Execute the code block if a certain level checks are on. More... | |
#define | IMP_INTERNAL_CHECK(expr, message) |
An assertion to check for internal errors in IMP . An IMP::ErrorException will be thrown. More... | |
#define | IMP_INTERNAL_CHECK_FLOAT_EQUAL(expra, exprb, message) |
#define | IMP_INTERNAL_CHECK_VARIABLE(variable) |
#define | IMP_NOT_IMPLEMENTED |
Use this to make that the method is not implemented yet. | |
#define | IMP_THROW(message, exception_name) |
Throw an exception with a message. More... | |
#define | IMP_USAGE_CHECK(expr, message) |
A runtime test for incorrect usage of a class or method. More... | |
#define | IMP_USAGE_CHECK_FLOAT_EQUAL(expra, exprb, message) |
#define | IMP_USAGE_CHECK_VARIABLE(variable) |
Copyright 2007-2014 IMP Inventors. All rights reserved.
Definition in file base/check_macros.h.
#define IMP_ALWAYS_CHECK | ( | condition, | |
message, | |||
exception_name | |||
) |
Do IMP_THROW() if the check as the first argument fails. Unlike IMP_USAGE_CHECK() and IMP_INTERNAL_CHECK() these checks are always present.
Definition at line 63 of file base/check_macros.h.
#define IMP_CATCH_AND_TERMINATE | ( | expr | ) |
Catch any IMP exception thrown by expr and terminate with an error message. Use this for basic error handling in main functions in C++. Do not use within the IMP
library.
Definition at line 30 of file base/check_macros.h.
#define IMP_CHECK_CODE | ( | expr | ) |
For example
Definition at line 121 of file base/check_macros.h.
#define IMP_FAILURE | ( | message | ) |
[in] | message | Failure message to write. This macro is used to provide nice error messages when there is an internal error in IMP . It causes an IMP::InternalException to be thrown. |
Definition at line 74 of file base/check_macros.h.
#define IMP_IF_CHECK | ( | level | ) |
The next code block (delimited by { }) is executed if get_check_level() <= level.
For example:
Definition at line 108 of file base/check_macros.h.
#define IMP_INTERNAL_CHECK | ( | expr, | |
message | |||
) |
Since it is a debug-only check and no attempt should be made to recover from it, the exception type cannot be specified.
For example:
[in] | expr | The assertion expression. |
[in] | message | Write this message if the assertion fails. |
Definition at line 143 of file base/check_macros.h.
#define IMP_INTERNAL_CHECK_FLOAT_EQUAL | ( | expra, | |
exprb, | |||
message | |||
) |
This is like IMP_INTERNAL_CHECK, however designed to check if two floating point numbers are almost equal. The check looks something like
Using this makes such tests a bit easier to spot and not mess up.
Definition at line 153 of file base/check_macros.h.
#define IMP_INTERNAL_CHECK_VARIABLE | ( | variable | ) |
Mark a variable as one that is only used in checks. This disables unused variable warnings on it in fast mode.
Definition at line 199 of file base/check_macros.h.
#define IMP_THROW | ( | message, | |
exception_name | |||
) |
The exception thrown must inherit from Exception and not be UsageException or InternalException as those are reserved for disableable checks (the IMP_INTERNAL_CHECK() and IMP_USAGE_CHECK() macros).
Definition at line 50 of file base/check_macros.h.
#define IMP_USAGE_CHECK | ( | expr, | |
message | |||
) |
[in] | expr | The assertion expression. |
[in] | message | Write this message if the assertion fails. |
It should be used to check arguments to function. For example
Definition at line 172 of file base/check_macros.h.
#define IMP_USAGE_CHECK_FLOAT_EQUAL | ( | expra, | |
exprb, | |||
message | |||
) |
This is like IMP_USAGE_CHECK, however designed to check if two floating point numbers are almost equal. The check looks something like
Using this makes such tests a bit easier to spot and not mess up.
Definition at line 182 of file base/check_macros.h.
#define IMP_USAGE_CHECK_VARIABLE | ( | variable | ) |
Mark a variable as one that is only used in checks. This disables unused variable warnings on it in fast mode.
Definition at line 194 of file base/check_macros.h.