| TerraLib 4.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

Namespaces | Defines | Functions
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_MODE | If defined, debug code macros will be compiled and used or if not defined the compiler debug flag will be used.
  TEAGN_ENABLE_STDOUT_LOG | If 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
| ) |  |

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

Parameters:

  value1 | Value to be checked.
  value2 | Value to be checked.
  eps | EPS ( threshold )
  message | Message to be logged.

Examples:
  TePDIColorTransform_test.cpp, TePDIContrast_test.cpp, TePDICorrelationMatching_test.cpp, TePDIFilterMask_test.cpp, TePDIHaralick_test.cpp, TePDIHistogram_test.cpp, TePDIInterpolator_test.cpp, TePDIJointHistogram_test.cpp, TePDIMatrixFunctions_test.cpp, TePDIMIMatching_test.cpp, TePDIMMIOMatching_test.cpp, TePDIOFMatching_test.cpp, TePDIParameters_test.cpp, TePDIRaster2Vector_test.cpp, TePDIRegister_test.cpp, TePDISegmentation_test.cpp, TePDIStatistic_test.cpp, and TePDIUtils_test.cpp.

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

  value1 | Value to be checked.
  value2 | Value to be checked.
  message | Message 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:

  value1 | Value to be checked.
  value2 | Value to be checked.
  message | Message 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:

  value | Value to be checked.
  message | Message 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:

  value | Value to be checked.
  message | Message 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:

  value | Value to be checked.
  message | Message 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:

  value | Value to be checked.
  message | Message 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:

  message | Message 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:

  message | Message to be logged.

#define TEAGN_LOGERR | ( |  | message | ) |

Value:

    { \
        TeErrorLog::instance().insert( UNKNOWN_ERROR_TYPE, \
          TeAgnostic::to_string( message ) ); \
        TEAGN_LOGERR_STDOUT( message ); \
      };

Logs a message.

Parameters:

  message | Message to be logged.

Examples:
  TePDIBDFilter_test.cpp, TePDIClassification_test.cpp, TePDIColorTransform_test.cpp, TePDICorrelationMatching_test.cpp, TePDIDecorrelationEnhancement_test.cpp, TePDIFFT_test.cpp, TePDIFilterMask_test.cpp, TePDIFusion_test.cpp, TePDIHants_test.cpp, TePDIHaralick_test.cpp, TePDIHistogram_test.cpp, TePDIInterpolator_test.cpp, TePDIJointHistogram_test.cpp, TePDILinearFilter_test.cpp, TePDIMathFunctions_test.cpp, TePDIMatrixFunctions_test.cpp, TePDIMIMatching_test.cpp, TePDIMixModel_test.cpp, TePDIMorfFilter_test.cpp, TePDIParameters_test.cpp, TePDIPrincipalComponents_test.cpp, TePDIRaster2Vector_test.cpp, TePDIRegister_test.cpp, TePDIRgbPalette_test.cpp, TePDISegmentation_test.cpp, TePDISensorSimulator_test.cpp, TePDIStatistic_test.cpp, and TePDIWavelets_test.cpp.

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

  message | Message to be logged.

#define TEAGN_LOGMSG | ( |  | message | ) |

Value:

    { \
        TeErrorLog::instance().insert( LOG_MESSAGE, \
          TeAgnostic::to_string( message ) ); \
        TEAGN_LOGMSG_STDOUT( message ); \
      };

Logs a message.

Parameters:

  message | Message to be logged.

Examples:
  TePDIArithmetic_test.cpp, TePDIBDFilter_test.cpp, TePDIBlender_test.cpp, TePDIClassification_test.cpp, TePDIColorTransform_test.cpp, TePDIContrast_test.cpp, TePDICorrelationMatching_test.cpp, TePDIDecorrelationEnhancement_test.cpp, TePDIFFT_test.cpp, TePDIFilterMask_test.cpp, TePDIFusion_test.cpp, TePDIHants_test.cpp, TePDIHaralick_test.cpp, TePDIHistogram_test.cpp, TePDIInterpolator_test.cpp, TePDIJointHistogram_test.cpp, TePDILinearFilter_test.cpp, TePDIMathFunctions_test.cpp, TePDIMatrix_test.cpp, TePDIMatrixFunctions_test.cpp, TePDIMIMatching_test.cpp, TePDIMixModel_test.cpp, TePDIMMIOMatching_test.cpp, TePDIMorfFilter_test.cpp, TePDIMosaic_test.cpp, TePDIOFMatching_test.cpp, TePDIParallelSegmenter_test.cpp, TePDIParameters_test.cpp, TePDIPrincipalComponents_test.cpp, TePDIRadarFilters_test.cpp, TePDIRaster2Vector_test.cpp, TePDIRegister_test.cpp, TePDIRgbPalette_test.cpp, TePDISegmentation_test.cpp, TePDISensorSimulator_test.cpp, TePDIStatistic_test.cpp, TePDIUtils_test.cpp, and TePDIWavelets_test.cpp.

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

  message | Message to be logged.

#define TEAGN_LOGWARN | ( |  | message | ) |

Value:

    { \
        TeErrorLog::instance().insert( LOG_MESSAGE, \
         TeAgnostic::to_string( message ) ); \
        TEAGN_LOGWARN_STDOUT( message ); \
      };

Logs a warning message.

Parameters:

  message | Message 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:

  message | Message 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:

  value | Value to be checked.
  message | Message 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:

  value | Value to be checked.
  message | Message to be logged.

Examples:
  TePDIOFMatching_test.cpp, TePDIRaster2Vector_test.cpp, and TePDISegmentation_test.cpp.

#define TEAGN_TRUE_OR_THROW | ( |  | value,
|  |  | message
| ) |  |

Value:

    if( ( value ) == 0 ) { \
          TEAGN_LOGERR_STDOUT( TeAgnostic::to_string( message ) + \
            " - " + TeAgnostic::to_string( #value ) ); \
          throw TeException( UNKNOWN_ERROR_TYPE, \
            TeAgnostic::to_string( message ), false ); \
        };

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

Parameters:

  value | Value to be checked.
  message | Message to be logged.

Examples:
  TePDIArithmetic_test.cpp, TePDIBDFilter_test.cpp, TePDIBlender_test.cpp, TePDIClassification_test.cpp, TePDIColorTransform_test.cpp, TePDIContrast_test.cpp, TePDICorrelationMatching_test.cpp, TePDIDecorrelationEnhancement_test.cpp, TePDIFFT_test.cpp, TePDIFilterMask_test.cpp, TePDIFusion_test.cpp, TePDIHants_test.cpp, TePDIHaralick_test.cpp, TePDIHistogram_test.cpp, TePDIInterpolator_test.cpp, TePDIJointHistogram_test.cpp, TePDILinearFilter_test.cpp, TePDIMathFunctions_test.cpp, TePDIMatrix_test.cpp, TePDIMatrixFunctions_test.cpp, TePDIMIMatching_test.cpp, TePDIMixModel_test.cpp, TePDIMMIOMatching_test.cpp, TePDIMorfFilter_test.cpp, TePDIMosaic_test.cpp, TePDIOFMatching_test.cpp, TePDIParallelSegmenter_test.cpp, TePDIParameters_test.cpp, TePDIPrincipalComponents_test.cpp, TePDIRadarFilters_test.cpp, TePDIRaster2Vector_test.cpp, TePDIRegister_test.cpp, TePDIRgbPalette_test.cpp, TePDISegmentation_test.cpp, TePDISensorSimulator_test.cpp, TePDISimplex_test.cpp, TePDIStatistic_test.cpp, TePDIUtils_test.cpp, and TePDIWavelets_test.cpp.

#define TEAGN_WATCH | ( |  | variable | ) |

Value:

    { \
          TEAGN_LOGMSG( "WATCH - " + TeAgnostic::to_string( #variable ) + \
            "=[" + TeAgnostic::to_string( variable ) +"]" ); \
        };

Variable watching.

Parameters:

  variable | Variable to be logged.

Examples:
  TePDIArithmetic_test.cpp, TePDICorrelationMatching_test.cpp, TePDIHistogram_test.cpp, TePDIJointHistogram_test.cpp, TePDIMIMatching_test.cpp, TePDIMMIOMatching_test.cpp, TePDIOFMatching_test.cpp, and TePDISegmentation_test.cpp.

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines