00001 00002 // 00003 // utils 00004 // 00005 // Copyright (c) 2004 Bioware Copr. 00006 // 00007 // The source code included in this file is confidential, 00008 // secret, or propietary information of Bioware Corp. It 00009 // may not be used in whole or in part without express 00010 // written permission from Bioware Corp. 00011 // 00013 // 00017 // 00019 // 00020 // Created On: 10:12:2008 14:19 00021 // 00023 00024 #ifndef _UTILS_H 00025 #define _UTILS_H 00026 00027 class EclipseObject; 00028 00029 // Use a namespace to protect some of the utility functions we have here just 00030 // scattered around. 00031 namespace Utils 00032 { 00040 void PrintMessage( const char* a_sMsg, ... ); 00041 00042 00044 // 00049 // 00055 // 00057 class ErrorManager 00058 { 00059 public: 00060 00061 // --------------------------------------------------------------------- 00062 // Structures, enums, definitions 00063 // --------------------------------------------------------------------- 00064 00069 enum eErrorType 00070 { 00071 ErrorType_Assert, 00072 ErrorType_Params, 00073 ErrorType_Instance, 00074 ErrorType_Internal, 00075 00076 // ... 00077 ErrorType_Unknown 00078 }; 00079 00084 struct ErrorEvent 00085 { 00086 EclipseObject* s_pFailedObject; 00087 char* s_sFailMessage; 00088 eErrorType s_nType; 00089 ErrorEvent* s_pNextError; 00090 }; 00091 00092 // --------------------------------------------------------------------- 00093 // Start/stop 00094 // --------------------------------------------------------------------- 00095 00101 static void Start( int a_nErrorHeapSize ); 00102 00107 static void Stop(); 00108 00109 // --------------------------------------------------------------------- 00110 // Utilities 00111 // --------------------------------------------------------------------- 00112 00120 static void Report( eErrorType a_nType, EclipseObject* a_pObject, const char* a_sDsc, ... ); 00121 00126 static int GetErrorCount(); 00127 00132 static void Clear(); 00133 00141 static ErrorEvent* GetError( int a_nIndex ); 00142 00143 private: 00144 00145 // Deletes the children of the provided event, then deletes the event 00146 static void KillEvent( ErrorEvent*& a_pEvent ); 00147 00148 // Returns the next available error slot so we can add info to it 00149 static ErrorEvent* GetNextAvailableEvent(); 00150 00151 // Initializes an error 00152 static void InitializeError( ErrorEvent* a_pError, bool a_bRecycled = false ); 00153 00154 static int m_nHeapSize; 00155 static ErrorEvent* m_pFirstError; 00156 static bool m_bStarted; 00157 00158 00159 }; 00160 00161 // ... 00162 00163 } 00164 00165 00166 00167 00168 00169 #endif