Macros.h File Reference
#include "../core/logger/Logger.h"
#include "../common/Config.h"
#include "../common/MathUtils.h"
#include "Module.h"
#include "Exception.h"
#include <boost/lexical_cast.hpp>
#include <sstream>
#include <string>
#include <iostream>

Go to the source code of this file.

Macros

#define ABS(x)   std::abs( x )
 Absolute value. More...
 
#define MAX(x, y)   std::max( x , y )
 Maximum of two values. More...
 
#define MIN(x, y)   std::min( x , y )
 Minimum of two values. More...
 
#define TERP_CHECK_EPS(value1, value2, eps, message)
 Checks if two values are equal ( within an EPS ) and throws an exception if not. More...
 
#define TERP_CHECK_EQUAL(value1, value2, message)
 Checks if two values are equal and throws an exception if not. More...
 
#define TERP_CHECK_NOT_EQUAL(value1, value2, message)
 Checks if two values are diferent and throws an exception if not. More...
 
#define TERP_DEBUG_MODE
 Debug mode selection based on NDEBUG define. More...
 
#define TERP_DEBUG_TRUE_OR_RETURN_FALSE(value, message)   TERP_TRUE_OR_RETURN_FALSE( value , message );
 Checks if value is true. For false values a warning message will be logged and a return of context with false value will be done. More...
 
#define TERP_DEBUG_TRUE_OR_THROW(value, message)   TERP_TRUE_OR_THROW( value , message );
 Checks if value is true and throws an exception if not. More...
 
#define TERP_ENABLE_STDOUT_LOG
 STDOUT logging selection flag. More...
 
#define TERP_FALSE_OR_LOG(value, message)
 Checks if value is false and logs an warning message if not. More...
 
#define TERP_FALSE_OR_RETURN(value, message)
 Checks if value is false. For true values a warning message will be logged and a return of context will be done. More...
 
#define TERP_FALSE_OR_RETURN_FALSE(value, message)
 Checks if value is false. For true values a warning message will be logged and a return of context with false value will be done. More...
 
#define TERP_LOG_AND_RETURN(message)
 Logs a warning message will and return. More...
 
#define TERP_LOG_AND_RETURN_FALSE(message)
 Logs a warning message will and return false. More...
 
#define TERP_LOG_AND_THROW(message)
 Logs a error message and throws. More...
 
#define TERP_LOGERR(message)
 Logs an error message. More...
 
#define TERP_LOGERR_STDOUT(message)
 Logs a error message to stderr. More...
 
#define TERP_LOGMSG(message)
 Logs a message. More...
 
#define TERP_LOGMSG_STDOUT(message)
 Logs a message to stdout. More...
 
#define TERP_LOGWARN(message)
 Logs a warning message. More...
 
#define TERP_LOGWARN_STDOUT(message)
 Logs a warning message to stdout. More...
 
#define TERP_NOT_IMPLEMENTED   TERP_LOG_AND_THROW( "Not Implemented." );
 Throws an exception for not implemented source. More...
 
#define TERP_TRUE_OR_LOG(value, message)
 ! * More...
 
#define TERP_TRUE_OR_RETURN(value, message)
 Checks if value is true. For false values a warning message will be logged and a return of context will be done. More...
 
#define TERP_TRUE_OR_RETURN_FALSE(value, message)
 Checks if value is true. For false values a warning message will be logged and a return of context with false value will be done. More...
 
#define TERP_TRUE_OR_THROW(value, message)
 Checks if value is true and throws an exception if not. More...
 
#define TERP_WATCH(variable)
 Variable watching. More...
 

Macro Definition Documentation

#define ABS (   x)    std::abs( x )

Absolute value.

Definition at line 396 of file Macros.h.

#define MAX (   x,
 
)    std::max( x , y )

Maximum of two values.

Definition at line 389 of file Macros.h.

#define MIN (   x,
 
)    std::min( x , y )

Minimum of two values.

Definition at line 382 of file Macros.h.

#define TERP_CHECK_EPS (   value1,
  value2,
  eps,
  message 
)

Checks if two values are equal ( within an EPS ) and throws an exception if not.

Parameters
value1Value to be checked.
value2Value to be checked.
epsEPS ( threshold )
messageMessage to be logged.

Definition at line 311 of file Macros.h.

#define TERP_CHECK_EQUAL (   value1,
  value2,
  message 
)
Value:
if( value1 != value2 ) \
{ \
TERP_LOGERR(std::string( "[" ) + \
boost::lexical_cast< std::string >( #value1 ) \
+ std::string( "!=" ) + \
+ boost::lexical_cast< std::string >( #value2 ) \
+ "][" \
+ boost::lexical_cast< std::string >( value1 ) \
+ std::string( "!=" ) + \
+ boost::lexical_cast< std::string >( value2 ) ); \
TERP_LOG_AND_THROW( message ); \
};

Checks if two values are equal and throws an exception if not.

Parameters
value1Value to be checked.
value2Value to be checked.
messageMessage to be logged.

Definition at line 270 of file Macros.h.

#define TERP_CHECK_NOT_EQUAL (   value1,
  value2,
  message 
)
Value:
if( value1 == value2 ) \
{ \
TERP_LOGERR(std::string( "[" ) + \
boost::lexical_cast< std::string >( #value1 ) \
+ std::string( "==" ) + \
+ boost::lexical_cast< std::string >( #value2 ) \
+ "][" \
+ boost::lexical_cast< std::string >( value1 ) \
+ std::string( "==" ) + \
+ boost::lexical_cast< std::string >( value2 ) ); \
TERP_LOG_AND_THROW( message ); \
};

Checks if two values are diferent and throws an exception if not.

Parameters
value1Value to be checked.
value2Value to be checked.
messageMessage to be logged.

Definition at line 290 of file Macros.h.

#define TERP_DEBUG_MODE

Debug mode selection based on NDEBUG define.

Debug mode selection flag.

Definition at line 47 of file Macros.h.

#define TERP_DEBUG_TRUE_OR_RETURN_FALSE (   value,
  message 
)    TERP_TRUE_OR_RETURN_FALSE( value , message );

Checks if value is true. For false values a warning message will be logged and a return of context with false value will be done.

Note
This macro will be disabled for non debug mode.
Parameters
valueValue to be checked.
messageMessage to be logged.

Definition at line 372 of file Macros.h.

#define TERP_DEBUG_TRUE_OR_THROW (   value,
  message 
)    TERP_TRUE_OR_THROW( value , message );

Checks if value is true and throws an exception if not.

Note
This macro will be disabled for non debug mode.
Parameters
valueValue to be checked.
messageMessage to be logged.

Definition at line 357 of file Macros.h.

Referenced by te::rp::Blender::getBlendedValues(), te::rp::Matrix< TemplateElementType >::getScanLine(), and te::rp::Matrix< rg::BaatzFeatureType >::operator()().

#define TERP_ENABLE_STDOUT_LOG

STDOUT logging selection flag.

Definition at line 51 of file Macros.h.

#define TERP_FALSE_OR_LOG (   value,
  message 
)
Value:
if( ( value ) != 0 ) { \
TERP_LOGWARN( boost::lexical_cast< std::string >( #value ) ); \
TERP_LOGWARN( boost::lexical_cast< std::string >( message ) ); \
};

Checks if value is false and logs an warning message if not.

Parameters
valueValue to be checked.
messageMessage to be logged.

Definition at line 258 of file Macros.h.

#define TERP_FALSE_OR_RETURN (   value,
  message 
)
Value:
if( ( value ) != 0 ) { \
TERP_LOGWARN( boost::lexical_cast< std::string >( #value ) ); \
TERP_LOGWARN( boost::lexical_cast< std::string >( message ) ); \
return; \
};

Checks if value is false. For true values a warning message will be logged and a return of context will be done.

Parameters
valueValue to be checked.
messageMessage to be logged.

Definition at line 226 of file Macros.h.

#define TERP_FALSE_OR_RETURN_FALSE (   value,
  message 
)
Value:
if( ( value ) != 0 ) { \
TERP_LOGWARN( boost::lexical_cast< std::string >( #value ) ); \
TERP_LOGWARN( boost::lexical_cast< std::string >( message ) ); \
return false; \
};

Checks if value is false. For true values a warning message will be logged and a return of context with false value will be done.

Parameters
valueValue to be checked.
messageMessage to be logged.

Definition at line 212 of file Macros.h.

#define TERP_LOG_AND_RETURN (   message)
Value:
{ \
TERP_LOGWARN( message ); \
return; \
};

Logs a warning message will and return.

Parameters
messageMessage to be logged.

Definition at line 247 of file Macros.h.

#define TERP_LOG_AND_RETURN_FALSE (   message)
Value:
{ \
TERP_LOGWARN( message ); \
return false; \
};

Logs a warning message will and return false.

Parameters
messageMessage to be logged.

Definition at line 237 of file Macros.h.

Referenced by te::rp::Matrix< TemplateElementType >::reset().

#define TERP_LOG_AND_THROW (   message)
Value:
{ \
TERP_LOGERR( message ); \
throw te::rp::Exception( boost::lexical_cast< std::string >( message ) ); \
};

Logs a error message and throws.

Parameters
messageMessage to be logged.

Definition at line 139 of file Macros.h.

Referenced by te::rp::srf::getSRF().

#define TERP_LOGERR (   message)
Value:
{ \
te::rp::Module::setLastLogStr( boost::lexical_cast< std::string >( message ) ); \
TE_LOG_ERROR( boost::lexical_cast< std::string >( message ).c_str() ); \
TERP_LOGERR_STDOUT( message ); \
};

Logs an error message.

Parameters
messageMessage to be logged.

Definition at line 117 of file Macros.h.

Referenced by te::rp::Matrix< TemplateElementType >::allocateDiskLines().

#define TERP_LOGERR_STDOUT (   message)
Value:
std::cerr << std::endl << "Error : " \
<< __FILE__ \
<< ":" << __LINE__ \
<< " - " << boost::lexical_cast< std::string >( message ) \
<< std::endl;

Logs a error message to stderr.

Parameters
messageMessage to be logged.

Definition at line 76 of file Macros.h.

#define TERP_LOGMSG (   message)
Value:
{ \
te::rp::Module::setLastLogStr( boost::lexical_cast< std::string >( message ) ); \
TE_LOG_INFO( boost::lexical_cast< std::string >( message ).c_str() ); \
TERP_LOGMSG_STDOUT( message ); \
};

Logs a message.

Parameters
messageMessage to be logged.

Definition at line 106 of file Macros.h.

#define TERP_LOGMSG_STDOUT (   message)
Value:
std::cout << std::endl << "Message : " \
<< __FILE__ \
<< ":" << __LINE__ \
<< " - " << boost::lexical_cast< std::string >( message ) \
<< std::endl;

Logs a message to stdout.

Parameters
messageMessage to be logged.

Definition at line 61 of file Macros.h.

#define TERP_LOGWARN (   message)
Value:
{ \
te::rp::Module::setLastLogStr( boost::lexical_cast< std::string >( message ) ); \
TE_LOG_WARN( boost::lexical_cast< std::string >( message ).c_str() ); \
TERP_LOGWARN_STDOUT( message ); \
};

Logs a warning message.

Parameters
messageMessage to be logged.

Definition at line 128 of file Macros.h.

#define TERP_LOGWARN_STDOUT (   message)
Value:
std::cout << std::endl << "Warning : " \
<< __FILE__ \
<< ":" << __LINE__ \
<< " - " << boost::lexical_cast< std::string >( message ) \
<< std::endl;

Logs a warning message to stdout.

Parameters
messageMessage to be logged.

Definition at line 91 of file Macros.h.

#define TERP_NOT_IMPLEMENTED   TERP_LOG_AND_THROW( "Not Implemented." );

Throws an exception for not implemented source.

Definition at line 348 of file Macros.h.

#define TERP_TRUE_OR_LOG (   value,
  message 
)
Value:
if( ( value ) == 0 ) { \
TERP_LOGWARN( boost::lexical_cast< std::string >( #value ) ); \
TERP_LOGWARN( boost::lexical_cast< std::string >( message ) ); \
};

! *

Checks if value is true and logs an warning message if not.

Parameters
valueValue to be checked. @param message Message to be logged.

Definition at line 171 of file Macros.h.

#define TERP_TRUE_OR_RETURN (   value,
  message 
)
Value:
if( ( value ) == 0 ) { \
TERP_LOGWARN( boost::lexical_cast< std::string >( #value ) ); \
TERP_LOGWARN( boost::lexical_cast< std::string >( message ) ); \
return; \
};

Checks if value is true. For false values a warning message will be logged and a return of context will be done.

Parameters
valueValue to be checked.
messageMessage to be logged.

Definition at line 198 of file Macros.h.

#define TERP_TRUE_OR_RETURN_FALSE (   value,
  message 
)
Value:
if( ( value ) == 0 ) { \
TERP_LOGWARN( boost::lexical_cast< std::string >( #value ) ); \
TERP_LOGWARN( boost::lexical_cast< std::string >( message ) ); \
return false; \
};

Checks if value is true. For false values a warning message will be logged and a return of context with false value will be done.

Parameters
valueValue to be checked.
messageMessage to be logged.

Definition at line 184 of file Macros.h.

Referenced by te::rp::CreateRasterFileFromMatrix().

#define TERP_TRUE_OR_THROW (   value,
  message 
)
Value:
if( ( value ) == 0 ) { \
TERP_LOGERR( boost::lexical_cast< std::string >( #value ) ); \
TERP_LOGERR( boost::lexical_cast< std::string >( message ) ); \
throw te::rp::Exception( boost::lexical_cast< std::string >( message ) ); \
};

Checks if value is true and throws an exception if not.

Parameters
valueValue to be checked.
messageMessage to be logged.

Definition at line 150 of file Macros.h.

Referenced by te::rp::Matrix< TemplateElementType >::getScanLine(), te::rp::rg::mergeSegments(), and te::rp::Matrix< TemplateElementType >::operator=().

#define TERP_WATCH (   variable)
Value:
{ \
TERP_LOGMSG( "WATCH - " + boost::lexical_cast< std::string >( #variable ) + \
"=[" + boost::lexical_cast< std::string >( variable ) +"]" ); \
};

Variable watching.

Parameters
variableVariable to be logged.

Definition at line 161 of file Macros.h.