MyGUI
3.2.0
|
00001 00007 /* 00008 This file is part of MyGUI. 00009 00010 MyGUI is free software: you can redistribute it and/or modify 00011 it under the terms of the GNU Lesser General Public License as published by 00012 the Free Software Foundation, either version 3 of the License, or 00013 (at your option) any later version. 00014 00015 MyGUI is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 GNU Lesser General Public License for more details. 00019 00020 You should have received a copy of the GNU Lesser General Public License 00021 along with MyGUI. If not, see <http://www.gnu.org/licenses/>. 00022 */ 00023 #ifndef __MYGUI_DIAGNOSTIC_H__ 00024 #define __MYGUI_DIAGNOSTIC_H__ 00025 00026 #include "MyGUI_Prerequest.h" 00027 #include "MyGUI_Exception.h" 00028 #include "MyGUI_LogManager.h" 00029 #include <sstream> 00030 00031 // for debugging 00032 #if MYGUI_COMPILER == MYGUI_COMPILER_MSVC 00033 #include <crtdbg.h> 00034 #endif 00035 00036 #define MYGUI_LOG_SECTION "Core" 00037 #define MYGUI_LOG_FILENAME "MyGUI.log" 00038 #define MYGUI_LOG(level, text) MYGUI_LOGGING(MYGUI_LOG_SECTION, level, text) 00039 00040 #define MYGUI_BASE_EXCEPT(desc, src) throw MyGUI::Exception(desc, src, __FILE__, __LINE__); 00041 00042 // MSVC specific: sets the breakpoint 00043 #if MYGUI_COMPILER == MYGUI_COMPILER_MSVC 00044 #define MYGUI_DBG_BREAK _CrtDbgBreak(); 00045 #else 00046 #define MYGUI_DBG_BREAK 00047 #endif 00048 00049 #define MYGUI_EXCEPT(dest) \ 00050 { \ 00051 MYGUI_LOG(Critical, dest); \ 00052 MYGUI_DBG_BREAK;\ 00053 std::ostringstream stream; \ 00054 stream << dest << "\n"; \ 00055 MYGUI_BASE_EXCEPT(stream.str().c_str(), "MyGUI"); \ 00056 } 00057 00058 #define MYGUI_ASSERT(exp, dest) \ 00059 { \ 00060 if ( ! (exp) ) \ 00061 { \ 00062 MYGUI_LOG(Critical, dest); \ 00063 MYGUI_DBG_BREAK;\ 00064 std::ostringstream stream; \ 00065 stream << dest << "\n"; \ 00066 MYGUI_BASE_EXCEPT(stream.str().c_str(), "MyGUI"); \ 00067 } \ 00068 } 00069 00070 #define MYGUI_ASSERT_RANGE(index, size, owner) MYGUI_ASSERT(index < size, owner << " : index number " << index << " out of range [" << size << "]"); 00071 #define MYGUI_ASSERT_RANGE_AND_NONE(index, size, owner) MYGUI_ASSERT(index < size || index == ITEM_NONE, owner << " : index number " << index << " out of range [" << size << "]"); 00072 #define MYGUI_ASSERT_RANGE_INSERT(index, size, owner) MYGUI_ASSERT((index <= size) || (index == MyGUI::ITEM_NONE), owner << " : insert index number " << index << " out of range [" << size << "] or not ITEM_NONE"); 00073 00074 #if MYGUI_DEBUG_MODE == 1 00075 #define MYGUI_REGISTER_VALUE(map, value) \ 00076 { \ 00077 MYGUI_LOG(Info, "Register value : '" << #value << "' = " << (int)value); \ 00078 map[#value] = value; \ 00079 } 00080 #define MYGUI_DEBUG_ASSERT(exp, dest) MYGUI_ASSERT(exp, dest) 00081 #else 00082 #define MYGUI_REGISTER_VALUE(map, value) map[#value] = value; 00083 #define MYGUI_DEBUG_ASSERT(exp, dest) ((void)0) 00084 #endif 00085 00086 00087 #if MYGUI_COMPILER == MYGUI_COMPILER_MSVC 00088 #if MYGUI_COMP_VER < 1310 // VC++ 7.1 00089 #define MYGUI_OBSOLETE_START(text) 00090 #define MYGUI_OBSOLETE_END 00091 #else 00092 #define MYGUI_OBSOLETE_START(text) __declspec(deprecated(text)) 00093 #define MYGUI_OBSOLETE_END 00094 #endif 00095 00096 #elif MYGUI_COMPILER == MYGUI_COMPILER_GNUC 00097 #if MYGUI_PLATFORM == MYGUI_PLATFORM_LINUX && MYGUI_COMP_VER < 310 // gcc 3.1 00098 #define MYGUI_OBSOLETE_START(text) 00099 #define MYGUI_OBSOLETE_END 00100 #else 00101 #define MYGUI_OBSOLETE_START(text) 00102 #define MYGUI_OBSOLETE_END __attribute__((deprecated)) 00103 #endif 00104 00105 #else 00106 #define MYGUI_OBSOLETE_START(text) 00107 #define MYGUI_OBSOLETE_END 00108 00109 #endif 00110 00111 #define MYGUI_OBSOLETE(text) MYGUI_OBSOLETE_START(text)MYGUI_OBSOLETE_END 00112 00113 #endif // __MYGUI_DIAGNOSTIC_H__