- proper names for the global includes
[genesis3d.git] / include / ErrorLog.h
diff --git a/include/ErrorLog.h b/include/ErrorLog.h
new file mode 100644 (file)
index 0000000..5a64ae2
--- /dev/null
@@ -0,0 +1,238 @@
+/****************************************************************************************/\r
+/*  ERRORLOG.H                                                                          */\r
+/*                                                                                      */\r
+/*  Author: Mike Sandige                                                                */\r
+/*  Description: Generic error logging system interface                                 */\r
+/*                                                                                      */\r
+/*  The contents of this file are subject to the Genesis3D Public License               */\r
+/*  Version 1.01 (the "License"); you may not use this file except in                   */\r
+/*  compliance with the License. You may obtain a copy of the License at                */\r
+/*  http://www.genesis3d.com                                                            */\r
+/*                                                                                      */\r
+/*  Software distributed under the License is distributed on an "AS IS"                 */\r
+/*  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See                */\r
+/*  the License for the specific language governing rights and limitations              */\r
+/*  under the License.                                                                  */\r
+/*                                                                                      */\r
+/*  The Original Code is Genesis3D, released March 25, 1999.                            */\r
+/*  Genesis3D Version 1.1 released November 15, 1999                                 */\r
+/*  Copyright (C) 1999 WildTangent, Inc. All Rights Reserved           */\r
+/*                                                                                      */\r
+/****************************************************************************************/\r
+#ifndef GE_ERRORLOG_H\r
+#define GE_ERRORLOG_H\r
+\r
+#include "BaseType.h"\r
+\r
+#ifndef NDEBUG \r
+       #define ERRORLOG_FULL_REPORTING\r
+#endif\r
+\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+typedef enum\r
+{\r
+       GE_ERR_INVALID_DRIVER_HANDLE,                   // Driver not supported\r
+       GE_ERR_INVALID_MODE_HANDLE,                             // Mode not supported\r
+       GE_ERR_DRIVER_INIT_FAILED,                              // Could not init Driver\r
+       GE_ERR_DRIVER_ALLREADY_INITIALIZED,             // Driver init failure\r
+       GE_ERR_DRIVER_NOT_FOUND,                                // File open error for driver\r
+       GE_ERR_DRIVER_NOT_INITIALIZED,                  // Driver shutdown failure\r
+       GE_ERR_INVALID_DRIVER,                                  // Wrong driver version, or bad driver\r
+       GE_ERR_DRIVER_BEGIN_SCENE_FAILED,\r
+       GE_ERR_DRIVER_END_SCENE_FAILED,\r
+       GE_ERR_CREATE_SOUND_MANAGER_FAILED,\r
+       GE_ERR_CREATE_SOUND_BUFFER_FAILED,\r
+       GE_ERR_DS_ERROR,\r
+       GE_ERR_INVALID_WAV,\r
+       GE_ERR_NO_PERF_FREQ,\r
+       GE_ERR_FILE_OPEN_ERROR,\r
+       GE_ERR_FILE_READ_ERROR,\r
+       GE_ERR_FILE_WRITE_ERROR,\r
+       GE_ERR_PALETTE_LOAD_FAILURE,\r
+       GE_ERR_GBSP_LOAD_FAILURE,\r
+       GE_ERR_INVALID_PARMS,\r
+       GE_ERR_INVALID_CAMERA,\r
+       GE_ERR_RENDER_WORLD_FAILED,\r
+       GE_ERR_BEGIN_WORLD_FAILED,\r
+       GE_ERR_END_WORLD_FAILED,\r
+       GE_ERR_BEGIN_MODELS_FAILED,\r
+       GE_ERR_END_MODELS_FAILED,\r
+       GE_ERR_BEGIN_MESHES_FAILED,\r
+       GE_ERR_END_MESHES_FAILED,\r
+       GE_ERR_RENDER_MESH_FAILED,\r
+       GE_ERR_BAD_LMAP_EXTENTS,\r
+       GE_ERR_INVALID_TEXTURE,\r
+       GE_ERR_REGISTER_WORLD_TEXTURE_FAILED,\r
+       GE_ERR_REGISTER_LIGHTMAPS_FAILED,\r
+       GE_ERR_REGISTER_WORLD_PALETTE_FAILED,\r
+       GE_ERR_REGISTER_MISC_TEXTURE_FAILED,\r
+       GE_ERR_INVALID_MESH_FILE,\r
+       GE_ERR_LOAD_BITMAP_FAILED,\r
+       GE_ERR_MAX_MESH_DEFS,\r
+       GE_ERR_MESH_MAX_NODES,\r
+       GE_ERR_INVALID_MESH_MATERIAL,\r
+       GE_ERR_MAX_MESH_MATERIALS,\r
+       GE_ERR_MAX_MESH_CLIP_PLANES,\r
+       GE_ERR_RENDERQ_OVERFLOW,\r
+       GE_ERR_INVALID_LTYPE,\r
+       GE_ERR_MAX_ENTITIES,\r
+       GE_ERR_GET_ENTITY_DATA_ERROR,\r
+       GE_ERR_INVALID_ENTITY_FIELD_TYPE,\r
+       GE_ERR_MODEL_NOT_FOUND,\r
+       GE_ERR_MODEL_NOT_IN_ENTITY,\r
+       GE_ERR_MAX_TEXTURES,\r
+       GE_ERR_MAX_DECALS,\r
+       GE_ERR_MAX_VERTS,\r
+       GE_ERR_OUT_OF_MEMORY,\r
+       GE_ERR_INVALID_BSP_TAG,\r
+       GE_ERR_INVALID_BSP_VERSION,\r
+       GE_ERR_ERROR_READING_BSP_CHUNK,\r
+       ERR_PATH_CREATE_ENOMEM,                         // failure to create a path (memory allocation failed)\r
+       ERR_PATH_INSERT_R_KEYFRAME,                     // failure to insert a rotation keyframe\r
+       ERR_PATH_INSERT_T_KEYFRAME,                     // failure to insert a translation keyframe\r
+       ERR_PATH_DELETE_R_KEYFRAME,                     // failure to delete a rotation keyframe\r
+       ERR_PATH_DELETE_T_KEYFRAME,                     // failure to delete a translation keyframe\r
+       ERR_PATH_FILE_READ,                                     // failure to read from file\r
+       ERR_PATH_FILE_VERSION,                          // tried to create path from file with wrong/bad version\r
+       ERR_PATH_FILE_PARSE,                            // failure to parse file (unexpected format problem)\r
+       ERR_PATH_FILE_WRITE,                            // failure to read from file\r
+       ERR_MOTION_CREATE_ENOMEM,                       // failure to create (memory allocation failed)\r
+       ERR_MOTION_ADDPATH_ENOMEM,                      // failure to add path into motion (memory allocation failed)\r
+       ERR_MOTION_ADDPATH_PATH,                        // failure to add path into motion (path creation failed)\r
+       ERR_MOTION_ADDPATH_BAD_NAME,            // failure to add path into motion due to name conflict\r
+       ERR_MOTION_INSERT_EVENT,                        // failure to insert event (memory allocation failed or duplicate key)\r
+       ERR_MOTION_DELETE_EVENT,                        // failure to insert event\r
+       ERR_MOTION_FILE_READ,                           // failure to read from file\r
+       ERR_MOTION_FILE_WRITE,                          // failure to write to file\r
+       ERR_MOTION_FILE_PARSE,                          // failure to parse file (unexpected format problem)\r
+       ERR_TKARRAY_INSERT_IDENTICAL,           // failure to insert into list because of existing identical key\r
+       ERR_TKARRAY_INSERT_ENOMEM,                      // failure to insert into list because of memory allocation failure\r
+       ERR_TKARRAY_DELETE_NOT_FOUND,           // failure to delete from list because key was not found\r
+       ERR_TKARRAY_CREATE,                                     // failure to create TKArray object (out of memroy)\r
+       ERR_TKARRAY_TOO_BIG,                            // TKArray object can't be added to - it's list is as big as it can get\r
+       ERR_VKARRAY_INSERT,                                     // insertion to VKArray failed\r
+       ERR_QKARRAY_INSERT,                                     // insertion to QKArray failed\r
+       ERR_POSE_CREATE_ENOMEM,                         // Motion object failed to create (memory allocation failed)\r
+       ERR_POSE_ADDJOINT_ENOMEM,                       // Motion_AddJoint failed to allocate/reallocate memory for new joint\r
+       ERR_TKEVENTS_CREATE_ENOMEM,                     // failure to create TKEvents object (memory allocation failed)\r
+       ERR_TKEVENTS_DELETE_NOT_FOUND,          // failure to delete from list because key was not found\r
+       ERR_TKEVENTS_INSERT_ENOMEM,                     // failure to insert into list because of memory allocation failure\r
+       ERR_TKEVENTS_INSERT,                            // failure to insert into list \r
+       ERR_TKEVENTS_FILE_READ,                         // failure to read from data file\r
+       ERR_TKEVENTS_FILE_WRITE,                        // failure to write to data file\r
+       ERR_TKEVENTS_FILE_VERSION,                      // failure to read tkevents object: file has wrong version\r
+       ERR_TKEVENTS_FILE_PARSE,                        // failure to parse file (unexpected format problem)\r
+       ERR_STRBLOCK_ENOMEM,                            // failure to create, insert, or append (memory allocation failed)\r
+       ERR_STRBLOCK_STRLEN,                            // string too long to insert or append\r
+       ERR_STRBLOCK_FILE_READ,                         // failure to read from data file\r
+       ERR_STRBLOCK_FILE_WRITE,                        // failure to write to data file\r
+       ERR_STRBLOCK_FILE_PARSE,                        // failure to parse reading from input file (unexpected format problem)\r
+       ERR_BODY_ENOMEM,                                        // failure to create, or add (memory allocation failed)\r
+       ERR_BODY_FILE_PARSE,                            // failure to parse reading from input file (unexpected format problem)\r
+       ERR_BODY_FILE_READ,                                     // failure to read from data file\r
+       ERR_BODY_FILE_WRITE,                            // failure to write to data file\r
+       ERR_BODY_BONEXFARRAY,                           // XFArray object failed to return array, or array size doesn't match bone count\r
+       ERR_XFARRAY_ENOMEM,                                     // failure to create. (memory allocation failure)\r
+       ERR_PUPPET_ENOMEM,                                      // failure to create. (memory allocation failure)\r
+       ERR_PUPPET_RENDER,                                      // failure to render. \r
+       ERR_PUPPET_NO_MATERIALS,                        // failure to create: associated body has no materials.\r
+       ERR_PUPPET_LOAD_TEXTURE,                        // failure to load texture \r
+       ERR_TEXPOOL_ENOMEM,                                     // failure to create or add to. (memory allocation/reallocation failure)\r
+       ERR_TEXPOOL_TOO_BIG,                            // failure to add to pool, pool is too large.\r
+       ERR_TEXPOOL_LOAD_TEXTURE,                       // failure to load texture into pool\r
+       ERR_TEXPOOL_TEXTURE_NOT_FREE,           // texture pool destroyed without first freeing all it's shared textures\r
+       ERR_ACTOR_ENOMEM,                                       // failure to create. (memory allocation failure)\r
+       ERR_ACTOR_RENDER_PREP,                          // failure to prepare actor for rendering (bad Body or allocation failure)\r
+       ERR_ACTOR_RENDER_FAILED,                        // failure to render.  failure to get geometry from Body \r
+       ERR_ACTOR_TOO_MANY_MOTIONS,                     // failure to add motion. too many.\r
+       ERR_ACTOR_FILE_READ,                            // failure to read from data file.\r
+       ERR_ACTOR_FILE_PARSE,                           // failure to parse reading from input file(unexpected format problem)\r
+       ERR_ACTOR_FILE_WRITE,                           // failure to write to data file.\r
+       GE_ERR_INVALID_MODEL_MOTION_FILE,       // Bad model motion file (for bsp files)\r
+       GE_ERR_BAD_BSP_FILE_CHUNK_SIZE,         // Chunk size does not match structure size of kind\r
+//MRB BEGIN\r
+//geSprite\r
+       ERR_SPRITE_ENOMEM,                                      // failure to create. (memory allocation failure)\r
+       ERR_SPRITE_INVALIDBITMAP,               // failure to use bitmap because bitmap was invalid\r
+//MRB END\r
+} geErrorLog_ErrorIDEnumType;\r
+\r
+\r
+typedef enum \r
+{\r
+       GE_ERR_MEMORY_RESOURCE,\r
+       GE_ERR_DISPLAY_RESOURCE,\r
+       GE_ERR_SOUND_RESOURCE,\r
+       GE_ERR_SYSTEM_RESOURCE,\r
+       GE_ERR_INTERNAL_RESOURCE,\r
+       \r
+       GE_ERR_FILEIO_OPEN,\r
+       GE_ERR_FILEIO_CLOSE,\r
+       GE_ERR_FILEIO_READ,\r
+       GE_ERR_FILEIO_WRITE,\r
+       GE_ERR_FILEIO_FORMAT,\r
+       GE_ERR_FILEIO_VERSION,\r
+       \r
+       GE_ERR_LIST_FULL,\r
+       GE_ERR_DATA_FORMAT,\r
+       GE_ERR_SEARCH_FAILURE,\r
+} geErrorLog_ErrorClassType;\r
+\r
+GENESISAPI void geErrorLog_Clear(void);\r
+       // clears error history\r
+\r
+GENESISAPI int  geErrorLog_Count(void);\r
+       // reports size of current error log\r
+\r
+GENESISAPI void geErrorLog_AddExplicit(geErrorLog_ErrorClassType,\r
+       const char *ErrorIDString,\r
+       const char *ErrorFileString,\r
+       int LineNumber,\r
+       const char *UserString,\r
+       const char *Context);\r
+       // not intended to be used directly: use ErrorLog_Add or ErrorLog_AddString\r
+\r
+\r
+#ifdef ERRORLOG_FULL_REPORTING\r
+       // 'Debug' version includes a textual error id, and the user string\r
+\r
+       #define geErrorLog_Add(Error, Context) geErrorLog_AddExplicit(Error, #Error, __FILE__, __LINE__,"", Context)\r
+               // logs an error.  \r
+\r
+       #define geErrorLog_AddString(Error,String, Context) geErrorLog_AddExplicit(Error, #Error, __FILE__,__LINE__, String, Context)\r
+               // logs an error with additional identifing string.  \r
+       \r
+GENESISAPI     geBoolean geErrorLog_AppendStringToLastError(const char *String);// use geErrorLog_AppendString\r
+\r
+       #define geErrorLog_AppendString(XXX) geErrorLog_AppendStringToLastError(XXX)\r
+               // adds text to the previous logged error\r
+\r
+#else\r
+       // 'Release' version does not include the textual error id, or the user string\r
+\r
+       #define geErrorLog_Add(Error, Context) geErrorLog_AddExplicit(Error, "", __FILE__, __LINE__,"", Context)\r
+               // logs an error.  \r
+\r
+       #define geErrorLog_AddString(Error,String, Context) geErrorLog_AddExplicit(Error, "", __FILE__,__LINE__, "", Context)\r
+               // logs an error with additional identifing string.  \r
+       \r
+       #define geErrorLog_AppendString(XXX)\r
+               // adds text to the previous logged error\r
+\r
+#endif\r
+\r
+GENESISAPI geBoolean geErrorLog_Report(int History, geErrorLog_ErrorClassType *Error, const char **UserString);\r
+       // reports from the error log.  \r
+       // history is 0 for most recent,  1.. for second most recent etc.\r
+       // returns GE_TRUE if report succeeded.  GE_FALSE if it failed.\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif\r
+\r