30#ifndef __NCML_MODULE__NCML_DEBUG__
31#define __NCML_MODULE__NCML_DEBUG__
38#include "BESInternalError.h"
39#include "BESSyntaxUserError.h"
40#include "BESNotFoundError.h"
53#define NCML_MODULE_DBG_CHANNEL "ncml"
56#define NCML_MODULE_DBG_CHANNEL_2 "ncml:2"
61#define NCML_MODULE_FUNCTION_NAME_MACRO __PRETTY_FUNCTION__
67#define THROW_NCML_INTERNAL_ERROR(msg) do { \
68 std::ostringstream __NCML_PARSE_ERROR_OSS__; \
69 __NCML_PARSE_ERROR_OSS__ << std::string("NCMLModule InternalError: ") << "[" << __PRETTY_FUNCTION__ << "]: " << (msg); \
70 BESDEBUG(NCML_MODULE_DBG_CHANNEL, __NCML_PARSE_ERROR_OSS__.str() << std::endl); \
71 throw BESInternalError( __NCML_PARSE_ERROR_OSS__.str(), \
72 __FILE__, __LINE__); } while(false)
75#define THROW_NCML_PARSE_ERROR(parseLine, msg) { \
76 std::ostringstream __NCML_PARSE_ERROR_OSS__; \
77 __NCML_PARSE_ERROR_OSS__ << "NCMLModule ParseError: at *.ncml line=" << (parseLine) << ": " \
79 BESDEBUG(NCML_MODULE_DBG_CHANNEL, \
80 __NCML_PARSE_ERROR_OSS__.str() << std::endl); \
81 throw BESSyntaxUserError( __NCML_PARSE_ERROR_OSS__.str(), \
87#define BESDEBUG_FUNC(channel, info)
89#define BESDEBUG_FUNC(channel, info) BESDEBUG( (channel), "[" << std::string(NCML_MODULE_FUNCTION_NAME_MACRO) << "]: " << info )
93#define NCML_ASSERT(cond)
96#define NCML_ASSERT(cond) do { if (!(cond)) { THROW_NCML_INTERNAL_ERROR(std::string("ASSERTION FAILED: ") + std::string(#cond)); } } while (false)
100#define NCML_ASSERT_MSG(cond, msg)
103#define NCML_ASSERT_MSG(cond, msg) do { if (!(cond)) { \
104 BESDEBUG(NCML_MODULE_DBG_CHANNEL, __PRETTY_FUNCTION__ << ": " << (msg) << std::endl); \
105 THROW_NCML_INTERNAL_ERROR(std::string("ASSERTION FAILED: condition=( ") + std::string(#cond) + std::string(" ) ") + std::string(msg)); } } while(false)
109#define VALID_PTR(ptr)
112#define VALID_PTR(ptr) NCML_ASSERT_MSG((ptr), std::string("Null pointer:" + std::string(#ptr)))