BUFFER.H 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. //
  2. // Copyright 2020 Electronic Arts Inc.
  3. //
  4. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
  5. // software: you can redistribute it and/or modify it under the terms of
  6. // the GNU General Public License as published by the Free Software Foundation,
  7. // either version 3 of the License, or (at your option) any later version.
  8. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. /***************************************************************************
  15. ** C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S **
  16. ***************************************************************************
  17. * *
  18. * Project Name : Westwood 32 Bit Library *
  19. * *
  20. * File Name : GBUFFER.H *
  21. * *
  22. * Programmer : Phil W. Gorrow *
  23. * *
  24. * Start Date : May 26, 1994 *
  25. * *
  26. * Last Update : July 5, 1994 [PWG] *
  27. * *
  28. *-------------------------------------------------------------------------*
  29. * Functions: *
  30. * BC::Get_Size -- Returns the buffer size of the BufferClass instance *
  31. * BC::Get_Buffer -- Returns pointer to buffer inherent to BufferClass *
  32. * BC::BufferClass -- inline constructor for BufferClass with size only *
  33. * BC::To_Page -- Copys a buffer class to a page with definable x, y, w, h*
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #ifndef BUFFER_H
  36. #define BUFFER_H
  37. /*=========================================================================*/
  38. /* If we have not already loaded the standard library header, than we can */
  39. /* load it. */
  40. /*=========================================================================*/
  41. #ifndef WWSTD_H
  42. #include "wwstd.h"
  43. #endif
  44. class GraphicViewPortClass;
  45. /*=========================================================================*/
  46. /* BufferClass - A base class which holds buffer information including a */
  47. /* pointer and the size of the buffer. */
  48. /*=========================================================================*/
  49. class BufferClass {
  50. public:
  51. /*===================================================================*/
  52. /* Define the base constructor and destructors for the class */
  53. /*===================================================================*/
  54. BufferClass(void *ptr, long size);
  55. BufferClass(long size);
  56. BufferClass();
  57. ~BufferClass();
  58. /*===================================================================*/
  59. /* Define functions which work with the buffer class. */
  60. /*===================================================================*/
  61. long To_Page(GraphicViewPortClass &view);
  62. long To_Page(int w, int h, GraphicViewPortClass &view);
  63. long To_Page(int x, int y, int w, int h, GraphicViewPortClass &view);
  64. /*===================================================================*/
  65. /* define functions to get at the protected data members */
  66. /*===================================================================*/
  67. void *Get_Buffer(void);
  68. long Get_Size(void);
  69. private:
  70. /*===================================================================*/
  71. /* Define the operators we do not want to happen which are the copy */
  72. /* and equal constructors. These are bad because the Allocated flag */
  73. /* could be copied and the associated buffer freed. If this were to */
  74. /* gappen it could cause weird general protection fault. */
  75. /*===================================================================*/
  76. BufferClass(BufferClass const &);
  77. BufferClass &operator=(BufferClass const &);
  78. protected:
  79. void *Buffer;
  80. long Size;
  81. BOOL Allocated;
  82. };
  83. /***************************************************************************
  84. * BC::GET_SIZE -- Returns the buffer size of the BufferClass instance *
  85. * *
  86. * INPUT: none *
  87. * *
  88. * OUTPUT: long the size of the buffer *
  89. * *
  90. * HISTORY: *
  91. * 06/01/1994 PWG : Created. *
  92. *=========================================================================*/
  93. inline long BufferClass::Get_Size(void)
  94. {
  95. return(Size);
  96. }
  97. /***************************************************************************
  98. * BC::GET_BUFFER -- Returns pointer to buffer inherent to BufferClass *
  99. * *
  100. * INPUT: none *
  101. * *
  102. * OUTPUT: void * to the inherent buffer. *
  103. * *
  104. * HISTORY: *
  105. * 06/01/1994 PWG : Created. *
  106. *=========================================================================*/
  107. inline void *BufferClass::Get_Buffer(void)
  108. {
  109. return(Buffer);
  110. }
  111. #endif