Macros.h File Reference
#include "../common/Logger.h"
#include "../common/Config.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 ROUND(x)   ( ( (x) >= 0 ) ? (long int)( (x) + 0.5 ) : (long int)( (x) - 0.5 ) )
 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 402 of file Macros.h.

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

Maximum of two values.

Definition at line 388 of file Macros.h.

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

Minimum of two values.

Definition at line 381 of file Macros.h.

#define ROUND (   x)    ( ( (x) >= 0 ) ? (long int)( (x) + 0.5 ) : (long int)( (x) - 0.5 ) )

Minimum of two values.

Definition at line 395 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 310 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 ); \
};
#define TERP_LOGERR(message)
Logs an error message.
Definition: Macros.h:116
#define TERP_LOG_AND_THROW(message)
Logs a error message and throws.
Definition: Macros.h:138

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 269 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 ); \
};
#define TERP_LOGERR(message)
Logs an error message.
Definition: Macros.h:116
#define TERP_LOG_AND_THROW(message)
Logs a error message and throws.
Definition: Macros.h:138

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

#define TERP_DEBUG_MODE

Debug mode selection based on NDEBUG define.

Debug mode selection flag.

Definition at line 46 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 371 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 356 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 50 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 ) ); \
};
#define TERP_LOGWARN(message)
Logs a warning message.
Definition: Macros.h:127

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

Parameters
valueValue to be checked.
messageMessage to be logged.

Definition at line 257 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; \
};
#define TERP_LOGWARN(message)
Logs a warning message.
Definition: Macros.h:127

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 225 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; \
};
#define TERP_LOGWARN(message)
Logs a warning message.
Definition: Macros.h:127

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

#define TERP_LOG_AND_RETURN (   message)
Value:
{ \
TERP_LOGWARN( message ); \
return; \
};
#define TERP_LOGWARN(message)
Logs a warning message.
Definition: Macros.h:127

Logs a warning message will and return.

Parameters
messageMessage to be logged.

Definition at line 246 of file Macros.h.

#define TERP_LOG_AND_RETURN_FALSE (   message)
Value:
{ \
TERP_LOGWARN( message ); \
return false; \
};
#define TERP_LOGWARN(message)
Logs a warning message.
Definition: Macros.h:127

Logs a warning message will and return false.

Parameters
messageMessage to be logged.

Definition at line 236 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 ) ); \
};
#define TERP_LOGERR(message)
Logs an error message.
Definition: Macros.h:116

Logs a error message and throws.

Parameters
messageMessage to be logged.

Definition at line 138 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 ); \
};
#define TERP_LOGERR_STDOUT(message)
Logs a error message to stderr.
Definition: Macros.h:75
#define TE_LOG_ERROR(msg)
Use this tag in order to log a message to a specified logger with the ERROR level.
Definition: Logger.h:77
static void setLastLogStr(const std::string &errorStr)
Set the last log string generated by this module.
Definition: Module.h:58

Logs an error message.

Parameters
messageMessage to be logged.

Definition at line 116 of file Macros.h.

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

#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 75 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 ); \
};
#define TERP_LOGMSG_STDOUT(message)
Logs a message to stdout.
Definition: Macros.h:60
#define TE_LOG_INFO(msg)
Use this tag in order to log a message to a specified logger with the INFO level. ...
Definition: Logger.h:107
static void setLastLogStr(const std::string &errorStr)
Set the last log string generated by this module.
Definition: Module.h:58

Logs a message.

Parameters
messageMessage to be logged.

Definition at line 105 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 60 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 ); \
};
#define TERP_LOGWARN_STDOUT(message)
Logs a warning message to stdout.
Definition: Macros.h:90
#define TE_LOG_WARN(msg)
Use this tag in order to log a message to a specified logger with the WARN level. ...
Definition: Logger.h:92
static void setLastLogStr(const std::string &errorStr)
Set the last log string generated by this module.
Definition: Module.h:58

Logs a warning message.

Parameters
messageMessage to be logged.

Definition at line 127 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 90 of file Macros.h.

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

Throws an exception for not implemented source.

Definition at line 347 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 ) ); \
};
#define TERP_LOGWARN(message)
Logs a warning message.
Definition: Macros.h:127

! *

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 170 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; \
};
#define TERP_LOGWARN(message)
Logs a warning message.
Definition: Macros.h:127

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 197 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; \
};
#define TERP_LOGWARN(message)
Logs a warning message.
Definition: Macros.h:127

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

Referenced by te::rp::Matrix< TemplateElementType >::createNewDiskFile(), and 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 ) ); \
};
#define TERP_LOGERR(message)
Logs an error message.
Definition: Macros.h:116

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

Parameters
valueValue to be checked.
messageMessage to be logged.

Definition at line 149 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 ) +"]" ); \
};
#define TERP_LOGMSG(message)
Logs a message.
Definition: Macros.h:105

Variable watching.

Parameters
variableVariable to be logged.

Definition at line 160 of file Macros.h.