CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

BUFFER.H (6360B)


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