Orxonox  0.0.5 Codename: Arcturus
Macros
OrxAssert.h File Reference

Declaration of custom assertion facilities
More...

#include "UtilPrereqs.h"
#include <cassert>
#include "Output.h"

Go to the source code of this file.

Macros

#define OrxAssert(condition, errorMessage)
 Run time assertion like assert(), but with an embedded message. More...
 
#define OrxVerify(condition, errorMessage)
 Works like OrxAssert in debug mode, but also checks the condition in release mode (no abort() triggered then). More...
 

Detailed Description

Declaration of custom assertion facilities

Macro Definition Documentation

#define OrxAssert (   condition,
  errorMessage 
)
Value:
do \
{ \
if (!(condition)) \
{ \
orxout(user_error) << __FILE__ << "(" << __LINE__ << "): "; \
orxout(user_error) << "Assertion failed in " << __FUNCTIONNAME__ << endl; \
orxout(user_error) << "Expression: " << #condition << endl; \
orxout(user_error) << "Message : " << errorMessage << endl; \
/* Don't use the condition again to avoid double evaluation */ \
/* Instead, stringify the expression and negate it */ \
assert(!#condition); \
} \
} while (false)
Output level, used for error messages which are important for the user.
Definition: OutputDefinitions.h:91
OutputStream & orxout(OutputLevel level=level::debug_output, const OutputContextContainer &context=context::undefined())
This helper function returns a reference to a commonly used instance of OutputStream.
Definition: Output.h:81
#define __FUNCTIONNAME__
Definition: OrxonoxConfig.h:104

Run time assertion like assert(), but with an embedded message.

The message will be printed as error with orxout(user_error).
You can use the same magic here as you can with ThrowException

1 OrxAssert(condition, "Text: " << number << " more text");
#define OrxVerify (   condition,
  errorMessage 
)
Value:
do \
{ \
if (!(condition)) \
{ \
orxout(user_error) << __FILE__ << "(" << __LINE__ << "): "; \
orxout(user_error) << "Verification failed in " << __FUNCTIONNAME__ << endl; \
orxout(user_error) << "Expression: " << #condition << endl; \
orxout(user_error) << "Message : " << errorMessage << endl; \
/* Don't use the condition again to avoid double evaluation */ \
/* Instead, stringify the expression and negate it */ \
assert(!#condition); \
} \
} while (false)
Output level, used for error messages which are important for the user.
Definition: OutputDefinitions.h:91
OutputStream & orxout(OutputLevel level=level::debug_output, const OutputContextContainer &context=context::undefined())
This helper function returns a reference to a commonly used instance of OutputStream.
Definition: Output.h:81
#define __FUNCTIONNAME__
Definition: OrxonoxConfig.h:104

Works like OrxAssert in debug mode, but also checks the condition in release mode (no abort() triggered then).

The message will be printed as error with orxout(user_error).
You can use the same magic here as you can with ThrowException

1 OrxVerify(condition, "Text: " << number << " more text");