2
0

BUFFER.H 6.1 KB

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