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