TerraLib 4.1
E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/kernel/TeAgnostic.h File Reference

This file contains a set of macros, routines and classes to deal with system checking and logging facility. They should NOT be used by anyone because the support and interfaces can be changed in future. THIS IS FOR INTERNAL USE ONLY. More...

#include <sstream>
#include <string>
#include <iostream>
#include "TeException.h"
#include "TeErrorLog.h"

Go to the source code of this file.

Namespaces

namespace  TeAgnostic
 

This namespace contains a set of routines and classes to deal with system checking and logging facility.


Defines

#define TEAGN_DEBUG_MODE
 TeAgnostic debug mode selection based on NDEBUG define.
#define TEAGN_ENABLE_STDOUT_LOG
 STDOUT logging selection flag.
#define TEAGN_LOGMSG_STDOUT(message)
 Logs a message to stdout.
#define TEAGN_LOGERR_STDOUT(message)
 Logs a error message to stderr.
#define TEAGN_LOGWARN_STDOUT(message)
 Logs a warning message to stdout.
#define TEAGN_LOGMSG(message)
 Logs a message.
#define TEAGN_LOGERR(message)
 Logs a message.
#define TEAGN_LOGWARN(message)
 Logs a warning message.
#define TEAGN_LOG_AND_THROW(message)
 Logs a message to stderr and throws.
#define TEAGN_TRUE_OR_THROW(value, message)
 Checks if value is true and throws an exception if not.
#define TEAGN_WATCH(variable)
 Variable watching.
#define TEAGN_TRUE_OR_LOG(value, message)
 Checks if value is true and logs an warning message if not.
#define TEAGN_TRUE_OR_RETURN(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.
#define TEAGN_FALSE_OR_RETURN(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.
#define TEAGN_LOG_AND_RETURN(message)
 Logs a warning message will and return false.
#define TEAGN_FALSE_OR_LOG(value, message)
 Checks if value is false and logs an warning message if not.
#define TEAGN_CHECK_EQUAL(value1, value2, message)
 Checks if two values are equal and throws an exception if not.
#define TEAGN_CHECK_NOTEQUAL(value1, value2, message)
 Checks if two values are diferent and throws an exception if not.
#define TEAGN_CHECK_EPS(value1, value2, eps, message)
 Checks if two values are equal ( within an EPS ) and throws an exception if not.
#define TEAGN_NOT_IMPLEMENTED   TEAGN_LOG_AND_THROW( "Not Implemented." );
 Throws an exception for not implemented source.
#define TEAGN_DEBUG_MODE_CHECK
 Checks if Debug mode is enabled and throws an exception if not.
#define TEAGN_DEBUG_CONDITION(value, message)   TEAGN_TRUE_OR_THROW( value , message );
 Checks if value is true and throws an exception if not.
#define TEAGN_DEBUG_RETURN(value, message)   TEAGN_TRUE_OR_RETURN( 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.

Functions

template<class T >
std::string TeAgnostic::to_string (const T &data)
 Data conversion to string.
bool TeAgnostic::debugModeCheck ()
 Checks if the code was compiled with debug mode.

Detailed Description

This file contains a set of macros, routines and classes to deal with system checking and logging facility. They should NOT be used by anyone because the support and interfaces can be changed in future. THIS IS FOR INTERNAL USE ONLY.

Author:
Emiliano F. Castejon <castejon@dpi.inpe.br>
Note:
The following macros will be used:
Parameters:
TEAGN_DEBUG_MODEIf defined, debug code macros will be compiled and used or if not defined the compiler debug flag will be used.
TEAGN_ENABLE_STDOUT_LOGIf defined, messages also will be logged to STDOUT ( otherwise only TeErrorLog will log messages ) or if not defined the compiler debug flag will be used.

Define Documentation

#define TEAGN_CHECK_EPS (   value1,
  value2,
  eps,
  message 
)
#define TEAGN_CHECK_EQUAL (   value1,
  value2,
  message 
)
Value:
TEAGN_TRUE_OR_THROW( ( ((double)( value1 ) ) == ((double)( value2 ) ) ), \
    std::string( "Values must be equal [" ) + \
    TeAgnostic::to_string( value1 ) + "!=" + \
    TeAgnostic::to_string( value2 ) + "] - " + \
    TeAgnostic::to_string( 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.
Examples:
TePDIFilterMask_test.cpp, TePDIHistogram_test.cpp, TePDIJointHistogram_test.cpp, and TePDIUtils_test.cpp.
#define TEAGN_CHECK_NOTEQUAL (   value1,
  value2,
  message 
)
Value:
TEAGN_TRUE_OR_THROW( ( ((double)( value1 )) != ((double)( value2 )) ), \
    std::string( "Values can't be equal [" ) + \
    TeAgnostic::to_string( #value1 ) + std::string( "==" ) + \
    TeAgnostic::to_string( #value2 ) + std::string( "==" ) + \
    TeAgnostic::to_string( value1 ) + std::string( "]" ) );

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.
#define TEAGN_DEBUG_CONDITION (   value,
  message 
)    TEAGN_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.
#define TEAGN_DEBUG_MODE

TeAgnostic debug mode selection based on NDEBUG define.

Debug mode selection flag.

#define TEAGN_DEBUG_MODE_CHECK
Value:
TEAGN_TRUE_OR_THROW( TeAgnostic::debugModeCheck() , \
    "Code not compiled with debug" );

Checks if Debug mode is enabled and throws an exception if not.

Examples:
TePDIDecorrelationEnhancement_test.cpp, and TePDIPrincipalComponents_test.cpp.
#define TEAGN_DEBUG_RETURN (   value,
  message 
)    TEAGN_TRUE_OR_RETURN( 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.
#define TEAGN_ENABLE_STDOUT_LOG

STDOUT logging selection flag.

#define TEAGN_FALSE_OR_LOG (   value,
  message 
)
Value:
if( ( value ) != 0 ) { \
      TEAGN_LOGWARN( TeAgnostic::to_string( message ) + \
        " - " + TeAgnostic::to_string( #value ) ); \
    };

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

Parameters:
valueValue to be checked.
messageMessage to be logged.
#define TEAGN_FALSE_OR_RETURN (   value,
  message 
)
Value:
if( ( value ) != 0 ) { \
      TEAGN_LOGWARN( TeAgnostic::to_string( message ) + \
        " - " + TeAgnostic::to_string( #value ) ); \
      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.
Examples:
TePDIOFMatching_test.cpp.
#define TEAGN_LOG_AND_RETURN (   message)
Value:
{ \
      TEAGN_LOGWARN( message ); \
      return false; \
    };

Logs a warning message will and return false.

Parameters:
messageMessage to be logged.
#define TEAGN_LOG_AND_THROW (   message)
Value:
{ \
    TEAGN_LOGERR_STDOUT( message ); \
    throw TeException( UNKNOWN_ERROR_TYPE, \
      TeAgnostic::to_string( message ), false ); \
  };

Logs a message to stderr and throws.

Parameters:
messageMessage to be logged.
#define TEAGN_LOGERR_STDOUT (   message)
Value:
std::cerr << std::endl << "Error : " \
        << __FILE__ \
        << ":" << __LINE__ \
        << " - " << TeAgnostic::to_string( message ) \
        << std::endl;

Logs a error message to stderr.

Parameters:
messageMessage to be logged.
#define TEAGN_LOGMSG_STDOUT (   message)
Value:
std::cout << std::endl << "Message : " \
        << __FILE__ \
        << ":" << __LINE__ \
        << " - " << TeAgnostic::to_string( message ) \
        << std::endl;

Logs a message to stdout.

Parameters:
messageMessage to be logged.
#define TEAGN_LOGWARN (   message)
Value:

Logs a warning message.

Parameters:
messageMessage to be logged.
#define TEAGN_LOGWARN_STDOUT (   message)
Value:
std::cout << std::endl << "Warning : " \
        << __FILE__ \
        << ":" << __LINE__ \
        << " - " << TeAgnostic::to_string( message ) \
        << std::endl;

Logs a warning message to stdout.

Parameters:
messageMessage to be logged.
#define TEAGN_NOT_IMPLEMENTED   TEAGN_LOG_AND_THROW( "Not Implemented." );

Throws an exception for not implemented source.

#define TEAGN_TRUE_OR_LOG (   value,
  message 
)
Value:
if( ( value ) == 0 ) { \
      TEAGN_LOGWARN( TeAgnostic::to_string( message ) + \
        " - " + TeAgnostic::to_string( #value ) ); \
    };

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

Parameters:
valueValue to be checked.
messageMessage to be logged.
#define TEAGN_TRUE_OR_RETURN (   value,
  message 
)
Value:
if( ( value ) == 0 ) { \
      TEAGN_LOGWARN( TeAgnostic::to_string( message ) + \
        " - " + TeAgnostic::to_string( #value ) ); \
      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.
Examples:
TePDIOFMatching_test.cpp, TePDIRaster2Vector_test.cpp, and TePDISegmentation_test.cpp.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines