RobWorkProject  22.2.21-
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)
 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 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)

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.");

Debug messages can be intercepted via debugLog().

◆ RW_LOG

#define RW_LOG (   id,
  ostreamExpression 
)
Value:
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");
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)) \
rw::core::Log::debugLog ().write (RW__message); \
throw rw::core::Exception (RW__message); \
} while (0)

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);

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)

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)

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.");

Warning messages can be intercepted via warningLog().

RW_WARN
#define RW_WARN(ostreamExpression)
Emit a warning.
Definition: core/macros.hpp:93
RW_THROW
#define RW_THROW(ostreamExpression)
Throw an exception with message ostreamExpression.
Definition: core/macros.hpp:47
rw::core::LogWriter::write
void write(const std::string &str)
Writes str to the log.
rw::core::Log::get
rw::core::LogWriter & get(LogIndex id)
Returns the LogWriter that is associated with LogIndex id.
rw::core::Exception
Standard exception type of RobWork.
Definition: core/Exception.hpp:46
rw::math::exp
Quaternion< T > exp(const Quaternion< T > &q)
this will return the exponential of this quaternion
Definition: Quaternion.hpp:593
RW_LOG
#define RW_LOG(id, ostreamExpression)
Writes ostreamExpression to log with LogIndex id.
Definition: core/macros.hpp:193
rw::core::Log::errorLog
static rw::core::LogWriter & errorLog()
convenience function for getting the LogWriter that is associated with the error loglevel
Definition: core/Log.hpp:173
rw::core::Log::debugLog
static rw::core::LogWriter & debugLog()
convenience function for getting the LogWriter that is associated with the debug loglevel
Definition: core/Log.hpp:180
rw::core::IOUtil::rwAssert
static void rwAssert(const char *expression, const char *file, int line)
Emit an assertion message and kill the program.
rw::core::Log::warningLog
static rw::core::LogWriter & warningLog()
convenience function for getting the LogWriter that is associated with the warning loglevel
Definition: core/Log.hpp:166
rw::core::Log::log
static Log & log()
convenience function of getInstance
RW_DEBUG
#define RW_DEBUG(ostreamExpression)
Emit debug message.
Definition: core/macros.hpp:123