• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

MyGUI_Diagnostic.h

Go to the documentation of this file.
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 
00030 // for debugging
00031 #if MYGUI_COMPILER == MYGUI_COMPILER_MSVC
00032     #include <crtdbg.h>
00033 #endif
00034 
00035 #define MYGUI_LOG_SECTION "Core"
00036 #define MYGUI_LOG_FILENAME "MyGUI.log"
00037 #define MYGUI_LOG(level, text) MYGUI_LOGGING(MYGUI_LOG_SECTION, level, text)
00038 
00039 #define MYGUI_BASE_EXCEPT(desc, src)     throw MyGUI::Exception(desc, src, __FILE__, __LINE__);
00040 
00041 // MSVC specific: sets the breakpoint
00042 #if MYGUI_COMPILER == MYGUI_COMPILER_MSVC
00043     #define MYGUI_DBG_BREAK _CrtDbgBreak();
00044 #else
00045     #define MYGUI_DBG_BREAK
00046 #endif
00047 
00048 #define MYGUI_EXCEPT(dest) \
00049 { \
00050     MYGUI_LOG(Critical, dest); \
00051     MYGUI_DBG_BREAK;\
00052     std::ostringstream stream; \
00053     stream << dest << "\n"; \
00054     MYGUI_BASE_EXCEPT(stream.str().c_str(), "MyGUI"); \
00055 }
00056 
00057 #define MYGUI_ASSERT(exp, dest) \
00058 { \
00059     if ( ! (exp) ) \
00060     { \
00061         MYGUI_LOG(Critical, dest); \
00062         MYGUI_DBG_BREAK;\
00063         std::ostringstream stream; \
00064         stream << dest << "\n"; \
00065         MYGUI_BASE_EXCEPT(stream.str().c_str(), "MyGUI"); \
00066     } \
00067 }
00068 
00069 #define MYGUI_ASSERT_RANGE(index, size, owner) MYGUI_ASSERT(index < size, owner << " : index number " << index << " out of range [" << size << "]");
00070 #define MYGUI_ASSERT_RANGE_AND_NONE(index, size, owner) MYGUI_ASSERT(index < size || index == ITEM_NONE, owner << " : index number " << index << " out of range [" << size << "]");
00071 #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");
00072 
00073 #if MYGUI_DEBUG_MODE == 1
00074     #define MYGUI_REGISTER_VALUE(map, value) \
00075     { \
00076         MYGUI_LOG(Info, "Register value : '" << #value << "' = " << (int)value); \
00077         map[#value] = value; \
00078     }
00079     #define MYGUI_DEBUG_ASSERT(exp, dest) MYGUI_ASSERT(exp, dest)
00080 #else
00081     #define MYGUI_REGISTER_VALUE(map, value) map[#value] = value;
00082     #define MYGUI_DEBUG_ASSERT(exp, dest) ((void)0)
00083 #endif
00084 
00085 
00086 // for more info see: http://mdf-i.blogspot.com/2008/09/deprecated-gcc-vs-vs-vs-vs.html
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 == 412
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__

Generated on Sun Jan 30 2011 for MyGUI by  doxygen 1.7.1