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_INSTANCE_FALSE_OR_RETURN_FALSE(value, message)
 Checks if value is false. For true values a warning message will be logged, the current instance error messsage will be updated and a return of context with false value will be done. More...
 
#define TERP_INSTANCE_LOG_AND_RETURN_FALSE(message)
 Logs a warning message, update the current instance error messsage and return false. More...
 
#define TERP_INSTANCE_TRUE_OR_RETURN_FALSE(value, message)
 Checks if value is true. For false values a warning message will be logged, the current instance error messsage will also be updated 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)
 
#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

◆ ABS

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

Absolute value.

Definition at line 439 of file Macros.h.

◆ MAX

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

Maximum of two values.

Definition at line 432 of file Macros.h.

◆ MIN

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

Minimum of two values.

Definition at line 425 of file Macros.h.

◆ TERP_CHECK_EPS

#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 354 of file Macros.h.

◆ TERP_CHECK_EQUAL

#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 313 of file Macros.h.

◆ TERP_CHECK_NOT_EQUAL

#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 333 of file Macros.h.

◆ TERP_DEBUG_MODE

#define TERP_DEBUG_MODE

Debug mode selection based on NDEBUG define.

Debug mode selection flag.

Definition at line 47 of file Macros.h.

◆ TERP_DEBUG_TRUE_OR_RETURN_FALSE

#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 415 of file Macros.h.

◆ TERP_DEBUG_TRUE_OR_THROW

#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 400 of file Macros.h.

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

◆ TERP_ENABLE_STDOUT_LOG

#define TERP_ENABLE_STDOUT_LOG

STDOUT logging selection flag.

Definition at line 51 of file Macros.h.

◆ TERP_FALSE_OR_LOG

#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 301 of file Macros.h.

◆ TERP_FALSE_OR_RETURN

#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 258 of file Macros.h.

◆ TERP_FALSE_OR_RETURN_FALSE

#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 229 of file Macros.h.

◆ TERP_INSTANCE_FALSE_OR_RETURN_FALSE

#define TERP_INSTANCE_FALSE_OR_RETURN_FALSE (   value,
  message 
)
Value:
if( ( value ) != 0 ) { \
setErrorMessage( boost::lexical_cast< std::string >( message ) ); \
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, the current instance error messsage will be updated and a return of context with false value will be done.

Parameters
valueValue to be checked.
messageMessage to be logged.

Definition at line 243 of file Macros.h.

◆ TERP_INSTANCE_LOG_AND_RETURN_FALSE

#define TERP_INSTANCE_LOG_AND_RETURN_FALSE (   message)
Value:
{ \
setErrorMessage( boost::lexical_cast< std::string >( message ) ); \
TERP_LOGWARN( message ); \
return false; \
};

Logs a warning message, update the current instance error messsage and return false.

Parameters
messageMessage to be logged.

Definition at line 279 of file Macros.h.

◆ TERP_INSTANCE_TRUE_OR_RETURN_FALSE

#define TERP_INSTANCE_TRUE_OR_RETURN_FALSE (   value,
  message 
)
Value:
if( ( value ) == 0 ) { \
setErrorMessage( boost::lexical_cast< std::string >( message ) ); \
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, the current instance error messsage will also be updated and a return of context with false value will be done.

Parameters
valueValue to be checked.
messageMessage to be logged.

Definition at line 200 of file Macros.h.

◆ TERP_LOG_AND_RETURN

#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 290 of file Macros.h.

◆ TERP_LOG_AND_RETURN_FALSE

#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 269 of file Macros.h.

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

◆ TERP_LOG_AND_THROW

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

◆ TERP_LOGERR

#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 ); \
};
static void setLastLogStr(const std::string &errorStr)
Set the last log string generated by this module.

Logs an error message.

Parameters
messageMessage to be logged.

Definition at line 117 of file Macros.h.

◆ TERP_LOGERR_STDOUT

#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.

◆ TERP_LOGMSG

#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 ); \
};
static void setLastLogStr(const std::string &errorStr)
Set the last log string generated by this module.

Logs a message.

Parameters
messageMessage to be logged.

Definition at line 106 of file Macros.h.

◆ TERP_LOGMSG_STDOUT

#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.

◆ TERP_LOGWARN

#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 ); \
};
static void setLastLogStr(const std::string &errorStr)
Set the last log string generated by this module.

Logs a warning message.

Parameters
messageMessage to be logged.

Definition at line 128 of file Macros.h.

◆ TERP_LOGWARN_STDOUT

#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.

◆ TERP_NOT_IMPLEMENTED

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

Throws an exception for not implemented source.

Definition at line 391 of file Macros.h.

◆ TERP_TRUE_OR_LOG

#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 ) ); \
};

@brief 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 172 of file Macros.h.

◆ TERP_TRUE_OR_RETURN

#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 215 of file Macros.h.

◆ TERP_TRUE_OR_RETURN_FALSE

#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 185 of file Macros.h.

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

◆ TERP_TRUE_OR_THROW

#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< rg::BaatzFeatureType >::getScanLine(), te::rp::rg::mergeSegments(), and te::rp::Matrix< rg::BaatzFeatureType >::operator=().

◆ TERP_WATCH

#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.