RobWorkProject  23.9.11-
Macros
core/macros.hpp File Reference
#include <rw/core/Exception.hpp>
#include <rw/core/IOUtil.hpp>
#include <rw/core/Log.hpp>
#include <rw/core/Message.hpp>
#include <iostream>
#include <sstream>

Macros

#define RW_THROW(ostreamExpression)
 Throw an exception with message ostreamExpression. More...
 
#define RW_THROW2(id, ostreamExpression)
 Throw an exception with the specified id and message ostreamExpression. More...
 
#define RW_WARN(ostreamExpression)
 Emit a warning. More...
 
#define RW_DEBUG(ostreamExpression)
 Emit debug message. More...
 
#define RW_ASSERT_IMPL(e, ostreamExpression, file, line)
 For internal use only. More...
 
#define RW_ASSERT(e)   RW_ASSERT_IMPL(e, std::string(#e), __FILE__, __LINE__)
 RobWork assertions. More...
 
#define RW_ASSERT_MSG(e, msg)   RW_ASSERT_IMPL(e, msg, __FILE__, __LINE__)
 RobWork assertions with user-friendly messages. More...
 
#define RW_LOG(id, ostreamExpression)    do { rw::core::Log::log().get(id) << ostreamExpression << std::endl; } while(0)
 Writes ostreamExpression to log with LogIndex id. More...
 
#define RW_LOG_ERROR(ostreamExpression)   RW_LOG(rw::core::Log::Error, ostreamExpression)
 Writes ostreamExpression to error log. More...
 
#define RW_LOG_WARNING(ostreamExpression)   RW_LOG(rw::core::Log::Warning, ostreamExpression)
 Writes ostreamExpression to warning log. More...
 
#define RW_LOG_DEBUG(ostreamExpression)   RW_LOG(rw::core::Log::Debug, ostreamExpression)
 Writes ostreamExpression to debug log. More...
 
#define RW_LOG_INFO(ostreamExpression)   RW_LOG(rw::core::Log::Info, ostreamExpression)
 Writes ostreamExpression to info log. More...
 
#define RW_MSG(ostreamExpression)   (Message(__FILE__, __LINE__) << ostreamExpression)
 Convenient convertion of a string expression into a Message. More...
 
#define PRINT_HERE   std::cout << __FILE__ << ":" << __LINE__ << std::endl << std::flush;
 
#define FALLTHROUGH
 Used to indicate that the fall through of a switch cas to another is intentional and not because you forgot to add break.
 
#define DEPRECATED(text)
 a way to mark code for deprecation More...
 
#define USE_ROBWORK_NAMESPACE
 enables the use of a robwork namespace
 

Macro Definition Documentation

◆ DEPRECATED

#define DEPRECATED (   text)

a way to mark code for deprecation

Parameters
textthe message to print

◆ RW_ASSERT

#define RW_ASSERT (   e)    RW_ASSERT_IMPL(e, std::string(#e), __FILE__, __LINE__)

RobWork assertions.

RW_ASSERT() is an assertion macro in the style of assert(). RW_ASSERT() can be enabled by compiling with RW_ENABLE_ASSERT defined. Otherwise RW_ASSERT() is enabled if NDBUG is not defined.

You should prefer RW_ASSERT() to assert() everywhere with a possible exception being (unsafe) access of arrays and a few other places where you are sure that a run time sanity check will be a performance issue.

◆ RW_ASSERT_IMPL

#define RW_ASSERT_IMPL (   e,
  ostreamExpression,
  file,
  line 
)
Value:
do { \
std::stringstream RW__stream; \
RW__stream << ostreamExpression; \
((e) ? (void) 0 : rw::core::IOUtil::rwAssert(RW__stream.str().c_str(), file, line)); \
} while(0)
static void rwAssert(const char *expression, const char *file, int line)
Emit an assertion message and kill the program.

For internal use only.

◆ RW_ASSERT_MSG

#define RW_ASSERT_MSG (   e,
  msg 
)    RW_ASSERT_IMPL(e, msg, __FILE__, __LINE__)

RobWork assertions with user-friendly messages.

RW_ASSERT_MSG() is an assertion macro similar to RW_ASSERT(). RW_ASSERT_MSG() can be enabled by compiling with RW_ENABLE_ASSERT defined. Otherwise RW_ASSERT_MSG() is enabled if NDBUG is not defined.

RW_ASSERT_MSG() takes one additional argument, allowing printing user-friendly error message if assertion fails.

◆ RW_DEBUG

#define RW_DEBUG (   ostreamExpression)

Emit debug message.

ostreamExpression is an expression that is fed to an output stream. Example:

RW_DEBUG("The value of x is " << x << ". x should be less than zero.");
#define RW_DEBUG(ostreamExpression)
Emit debug message.
Definition: core/macros.hpp:123

Debug messages can be intercepted via debugLog().

◆ RW_LOG

#define RW_LOG (   id,
  ostreamExpression 
)     do { rw::core::Log::log().get(id) << ostreamExpression << std::endl; } while(0)

Writes ostreamExpression to log with LogIndex id.

id be the log level of type rw::core::Log::LogIndex.

ostreamExpression is an expression that is fed to an output stream.

Example:

int x = 1;
RW_LOG(rw::core::Log::Debug, "Warning: The value of x " << x << " is too small");
#define RW_LOG(id, ostreamExpression)
Writes ostreamExpression to log with LogIndex id.
Definition: core/macros.hpp:193
Parameters
id[in] log level to write to.
ostreamExpression[in] Stream expression which should be written to the log

◆ RW_LOG_DEBUG

#define RW_LOG_DEBUG (   ostreamExpression)    RW_LOG(rw::core::Log::Debug, ostreamExpression)

Writes ostreamExpression to debug log.

Parameters
ostreamExpression[in] Stream expression which should be written to the log

◆ RW_LOG_ERROR

#define RW_LOG_ERROR (   ostreamExpression)    RW_LOG(rw::core::Log::Error, ostreamExpression)

Writes ostreamExpression to error log.

Parameters
ostreamExpression[in] Stream expression which should be written to the log

◆ RW_LOG_INFO

#define RW_LOG_INFO (   ostreamExpression)    RW_LOG(rw::core::Log::Info, ostreamExpression)

Writes ostreamExpression to info log.

Parameters
ostreamExpression[in] Stream expression which should be written to the log

◆ RW_LOG_WARNING

#define RW_LOG_WARNING (   ostreamExpression)    RW_LOG(rw::core::Log::Warning, ostreamExpression)

Writes ostreamExpression to warning log.

Parameters
ostreamExpression[in] Stream expression which should be written to the log

◆ RW_MSG

#define RW_MSG (   ostreamExpression)    (Message(__FILE__, __LINE__) << ostreamExpression)

Convenient convertion of a string expression into a Message.

Parameters
ostreamExpression[in] stream expression which should be converted to a Message.

◆ RW_THROW

#define RW_THROW (   ostreamExpression)
Value:
do { \
int RW__line = __LINE__; \
std::stringstream RW__stream; \
RW__stream << ostreamExpression; \
rw::core::Message RW__message(__FILE__, RW__line, RW__stream.str()); \
if(rw::core::Log::log().isEnabled(rw::core::Log::Debug)) \
throw rw::core::Exception(RW__message); \
} while(0)
Standard exception type of RobWork.
Definition: core/Exception.hpp:47
void write(const std::string &str)
Writes str to the log.
static rw::core::LogWriter & debugLog()
convenience function for getting the LogWriter that is associated with the debug loglevel
Definition: core/Log.hpp:176
static Log & log()
convenience function of getInstance

Throw an exception with message ostreamExpression.

ostreamExpression is an expression that is fed to an output stream. Example:

RW_THROW("The value of x is " << x);
#define RW_THROW(ostreamExpression)
Throw an exception with message ostreamExpression.
Definition: core/macros.hpp:47

Exception messages can be intercepted via exceptionLog().

◆ RW_THROW2

#define RW_THROW2 (   id,
  ostreamExpression 
)
Value:
do { \
int RW__line = __LINE__; \
std::stringstream RW__stream; \
RW__stream << ostreamExpression; \
rw::core::Message RW__message(__FILE__, RW__line, RW__stream.str()); \
rw::core::Exception exp(id, RW__message); \
if(rw::core::Log::log().isEnabled(rw::core::Log::Error)) \
throw exp; \
} while(0)
static rw::core::LogWriter & errorLog()
convenience function for getting the LogWriter that is associated with the error loglevel
Definition: core/Log.hpp:169
Quaternion< T > exp(const Quaternion< T > &q)
this will return the exponential of this quaternion
Definition: Quaternion.hpp:585

Throw an exception with the specified id and message ostreamExpression.

id is the id of the exception and * ostreamExpression is an expression that is fed to an output stream. Example:

RW_THROW("The value of x is " << x);

Exception data can be intercepted via exceptionLog().

◆ RW_WARN

#define RW_WARN (   ostreamExpression)
Value:
do { \
int RW__line = __LINE__; \
std::stringstream RW__stream; \
RW__stream << ostreamExpression; \
rw::core::Message RW__message(__FILE__, RW__line, RW__stream.str()); \
if(rw::core::Log::log().isEnabled(rw::core::Log::Warning)) \
rw::core::Log::warningLog() << RW__message << std::endl; \
} while(0)
static rw::core::LogWriter & warningLog()
convenience function for getting the LogWriter that is associated with the warning loglevel
Definition: core/Log.hpp:162

Emit a warning.

ostreamExpression is an expression that is fed to an output stream. Example:

RW_WARN("The value of x is " << x << ". x should be less than zero.");
#define RW_WARN(ostreamExpression)
Emit a warning.
Definition: core/macros.hpp:93

Warning messages can be intercepted via warningLog().