gamelog.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //---------------------------------------------------------------------------
  2. //
  3. // gamelog.h - This file contains the class declaration for GameLog
  4. //
  5. // The Log File class allows easy dumping to a log file
  6. // from your application. It handles the string buffer (to
  7. // prevent writing to file everytime you call it).
  8. //
  9. //---------------------------------------------------------------------------//
  10. // Copyright (C) Microsoft Corporation. All rights reserved. //
  11. //===========================================================================//
  12. #ifndef GAMELOG_H
  13. #define GAMELOG_H
  14. //---------------------------------------------------------------------------
  15. // Include files
  16. #ifndef DSTD_H
  17. #include "dstd.h"
  18. #endif
  19. #ifndef DFILE_H
  20. #include "dfile.h"
  21. #endif
  22. #ifndef DGAMELOG_H
  23. #include "dgamelog.h"
  24. #endif
  25. //---------------------------------------------------------------------------
  26. #define MAX_GAMELOGS 6
  27. #define MAX_GAMELOG_LINES 50
  28. #define MAX_GAMELOG_LINELEN 200
  29. #define MAXLEN_GAMELOG_NAME 128
  30. class GameLog {
  31. public:
  32. long handle;
  33. bool inUse;
  34. char fileName[MAXLEN_GAMELOG_NAME];
  35. File* filePtr;
  36. long numLines;
  37. long totalLines;
  38. char lines[MAX_GAMELOG_LINES][MAX_GAMELOG_LINELEN];
  39. static GameLogPtr files[MAX_GAMELOGS];
  40. public:
  41. void* operator new (size_t mySize);
  42. void operator delete (void* us);
  43. void init (void) {
  44. handle = -1;
  45. inUse = false;
  46. fileName[0] = NULL;
  47. filePtr = NULL;
  48. numLines = 0;
  49. totalLines = 0;
  50. for (long i = 0; i < MAX_GAMELOG_LINES; i++)
  51. lines[i][0] = NULL;
  52. }
  53. GameLog (void) {
  54. init();
  55. }
  56. void destroy (void);
  57. ~GameLog (void) {
  58. destroy();
  59. }
  60. void dump (void);
  61. void close (void);
  62. long open (char* fileName);
  63. void write (char* s);
  64. static void setup (void);
  65. static void cleanup (void);
  66. static GameLogPtr getNewFile (void);
  67. };
  68. //---------------------------------------------------------------------------
  69. #endif