RobWorkProject
Classes | Macros | Typedefs | Functions
Common utils

Various utilities and definitions of general use. More...

Classes

class  Cache< KEY, VAL >
 This class is a template for caching. More...
 
class  ConstConcatVectorIterator< T >
 Forward iterator for the concatenation of a pair of vectors of pointers to T. More...
 
class  ConcatVectorIterator< T >
 Forward iterator for the concatenation of a pair of vectors of pointers to T. More...
 
class  DOMParser
 interface for parsing documents in a DOM fasion. More...
 
class  Exception
 Standard exception type of RobWork. More...
 
class  FileCache< KEY, VAL, STAMP_T >
 a cache that use a timestamp in combination with a key to determine the uniqueness of an item in the cache. More...
 
class  IOUtil
 Collection of IO related utilities. More...
 
class  Log
 Provides basic log functionality. More...
 
class  LogBufferedChar
 Buffers characters before writing them to the output stream. More...
 
class  LogFileWriter
 Writes log output to a file. More...
 
class  LogMultiWriter
 Writes log output to multiple LogWriters. More...
 
class  LogStreamWriter
 Writes log output to a std::ostream. More...
 
class  LogWriter
 Write interface for Logs. More...
 
class  Message
 Standard type for user messages of robwork. More...
 
class  PairMap< T1, T2 >
 a specialized mapping implementation for pairs. It uses the internal structure of template T1 to provide fast O(1) lookup for mappings from a Pair to anything. The order of the Pairs does not matter. More...
 
class  Property< T >
 Property class The Property class is a template to support properties of any type. A Property is characterized by a string identifier, string description and a value of the template specified type. More...
 
class  PropertyBase
 Base class for Property handling. More...
 
class  PropertyMap
 Container for a collection of Property Objects. More...
 
class  PropertyType
 Represents type of a property. More...
 
class  Ptr< T >
 Ptr stores a pointer and optionally takes ownership of the value. More...
 
class  StringUtil
 Collection of string manipulation utilities. More...
 
class  ThreadPool
 A thread pool that can be assigned work. More...
 
class  ThreadSafeVariable< T >
 A thread safe protected variable. More...
 
class  ThreadTask
 A task that facilitates the use of a hierarchic tree of tasks and subtasks. More...
 
class  Timer
 The timer class provides an easy to use platform independent timer. More...
 
class  TimerUtil
 Access of the system clock so called wall time. More...
 
class  ConstVectorIterator< T >
 Forward iterator for vectors of pointers to const T. More...
 
class  VectorIterator< T >
 Forward iterator for vectors of pointers to T. More...
 

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::common::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::common::Log::Error, ostreamExpression)
 Writes ostreamExpression to error log. More...
 
#define RW_LOG_WARNING(ostreamExpression)   RW_LOG(rw::common::Log::Warning, ostreamExpression)
 Writes ostreamExpression to warning log. More...
 
#define RW_LOG_DEBUG(ostreamExpression)   RW_LOG(rw::common::Log::Debug, ostreamExpression)
 Writes ostreamExpression to debug log. More...
 
#define RW_LOG_INFO(ostreamExpression)   RW_LOG(rw::common::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 USE_ROBWORK_NAMESPACE
 enables the use of a robwork namespace
 

Typedefs

typedef std::pair< std::string, std::string > StringPair
 Convenient definition of a pair of strings.
 
typedef std::vector< StringPairStringPairList
 Convenient definition of a list of string pairs.
 

Functions

std::ostream & operator<< (std::ostream &out, const Exception &exp)
 Format to out the message of the exception exp. More...
 
std::ostream & operator<< (std::ostream &out, const Message &msg)
 Format to out the message msg. More...
 
template<class T >
Property< T > * toProperty (PropertyBase::Ptr base)
 cast a property base to a specific property. Notice that the pointer returned is owned by the PropertyBase::Ptr. More...
 
template<class T , class R >
bool operator== (void *p, const Ptr< R > &g)
 Comparator for comparing an ordinary pointer with a smart pointer. More...
 
template<class T >
Ptr< T > ownedPtr (T *ptr)
 A Ptr that takes ownership over a raw pointer ptr.
 

Detailed Description

Various utilities and definitions of general use.

Macro Definition Documentation

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

Debug messages can be intercepted via debugLog().

◆ RW_LOG

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

Writes ostreamExpression to log with LogIndex id.

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

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

Example:

int x = 1;
RW_LOG(rw::common::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::common::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::common::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::common::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::common::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::common::Message RW__message(__FILE__, RW__line, RW__stream.str()); \
if( rw::common::Log::log().isEnabled(rw::common::Log::Debug) ) \
throw rw::common::Exception(RW__message); \
} while (0)
void write(const std::string &str)
Writes str to the log.
static LogWriter & debugLog()
convenience function for getting the LogWriter that is associated with the debug loglevel ...
Definition: Log.hpp:167
static Log & log()
convenience function of getInstance
Standard exception type of RobWork.
Definition: Exception.hpp:44

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::common::Message RW__message(__FILE__, RW__line, RW__stream.str()); \
rw::common::Exception exp(id, RW__message); \
if( rw::common::Log::log().isEnabled(rw::common::Log::Error) ) \
throw exp; \
} while (0)
void write(const std::string &str)
Writes str to the log.
static Log & log()
convenience function of getInstance
static LogWriter & errorLog()
convenience function for getting the LogWriter that is associated with the error loglevel ...
Definition: Log.hpp:158

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::common::Message RW__message(__FILE__, RW__line, RW__stream.str()); \
if( rw::common::Log::log().isEnabled(rw::common::Log::Warning) ) \
rw::common::Log::warningLog() << RW__message << std::endl; \
} while (0)
static LogWriter & warningLog()
convenience function for getting the LogWriter that is associated with the warning loglevel ...
Definition: Log.hpp:148
static Log & log()
convenience function of getInstance

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().

Function Documentation

◆ operator<<() [1/2]

std::ostream& rw::common::operator<< ( std::ostream &  out,
const Exception exp 
)

Format to out the message of the exception exp.

The format for the text is

<file>:<line> <message>
Returns
The stream out.

◆ operator<<() [2/2]

std::ostream& rw::common::operator<< ( std::ostream &  out,
const Message msg 
)

Format to out the message msg.

The format for the exception is

<file>:<line> <message>
Returns
The stream out.

◆ operator==()

bool rw::common::operator== ( void *  p,
const Ptr< R > &  g 
)

Comparator for comparing an ordinary pointer with a smart pointer.

Note
If comparing two instances of a class without specifying the equal operator this method might be called.

◆ toProperty()

Property<T>* rw::common::toProperty ( PropertyBase::Ptr  base)

cast a property base to a specific property. Notice that the pointer returned is owned by the PropertyBase::Ptr.

Parameters
base[in] property base pointer
Returns
property of type T or null if property is of another type