home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / tvision / tvpal / tvpal.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-09  |  4.2 KB  |  162 lines

  1. //
  2. // PALETTE.H
  3. //
  4. // Copyright (c) 1992 CC Software
  5. // All rights reserved
  6. //
  7. // Class TStreamPalette : Streamable TPalette object
  8. //
  9.  
  10. #if !defined( __TVPAL_H )
  11. #define __TVPAL_H
  12.  
  13. // Interface Dependencies ---------------------------------------------
  14. //
  15.  
  16. #define Uses_TPalette
  17. #define Uses_TStreamable
  18. #define Uses_TStreamableClass
  19. #include <tv.h>
  20.  
  21. //
  22. // END Interface Dependencies -----------------------------------------
  23.  
  24.  
  25. // Class TStreamPalette //
  26.  
  27. // Description --------------------------------------------------------
  28. //
  29. //      Joins the functionality of the TStreamable and TPalette to create
  30. //      streamable Palette objects.
  31. //
  32. // Member Functions
  33. //
  34. //      read( ipstream& )
  35. //
  36. //      Reads the palette from the given input source stream.
  37. //
  38. //      write( opstream& )
  39. //
  40. //      Writes the palette to the given sink stream.
  41. //
  42. //      build()
  43. //
  44. //      Creates a TStreamPalette object by reading it from the given
  45. //      input stream.
  46. //
  47. //      streamableName()
  48. //
  49. //      Returns the name of the class TStreamPalette
  50. //
  51. //
  52. // Inherited Member Functions
  53. //
  54. //      operator =( const TPalette& )
  55. //
  56. //      operator []( int index )
  57. //
  58. // END Description ====================================================
  59.  
  60. class TStreamPalette : public TPalette, public TStreamable {
  61. public:
  62.        TStreamPalette( const char _FAR* bytes, ushort len );
  63.        TStreamPalette( const TPalette _FAR& );
  64.  
  65.        static char _FAR* name;
  66.        static TStreamable _FAR* build();
  67.  
  68. protected:
  69.        TStreamPalette( StreamableInit );
  70.        virtual void write( opstream _FAR& );
  71.        virtual void _FAR* read( ipstream _FAR& );
  72.  
  73. private:
  74.        virtual const char _FAR* streamableName() const { return name; };
  75. };
  76. // END TStreamPalette =================================================
  77.  
  78.  
  79.  
  80. // TStreamable Inline Member functions //
  81.  
  82. // Constructor //
  83.  
  84. inline TStreamPalette::TStreamPalette( const char *bytes, ushort len ) :
  85.          TPalette( bytes, len )
  86. // Summary ------------------------------------------------------------
  87. //
  88. //      Creates the TStreamPalette instance based on the data string
  89. //      and length of that string.
  90. //
  91. // Parameters
  92. //
  93. //      bytes
  94. //
  95. //      Pointer to a char string (possible nulls inside) containing
  96. //      the palette entries.
  97. //
  98. //      len
  99. //
  100. //      The overall length of the palette "string."
  101. //
  102. // END Summary --------------------------------------------------------
  103. {
  104. };
  105. // END TStreamPalette::TStreamPalette ---------------------------------
  106.  
  107.  
  108.  
  109. // Constructor //
  110.  
  111. inline TStreamPalette::TStreamPalette( const TPalette _FAR& p ) :
  112.          TPalette( p )
  113. // Summary ------------------------------------------------------------
  114. //
  115. //      Again, here we have a constructor to copy a TPalette derived
  116. //      class.  This is made specially for TPalette copying into
  117. //      TStreamPalette streamable objects.
  118. //
  119. // Parameters
  120. //
  121. //      p
  122. //
  123. //      A TPalette derived class for creating TStreamPalette instances
  124. //      from TPalette instances.
  125. //
  126. // END Summary --------------------------------------------------------
  127. {
  128. };
  129. // END TStreamPalette::TStreamPalette ---------------------------------
  130.  
  131.  
  132.  
  133. // Protected Constructor //
  134.  
  135. inline TStreamPalette::TStreamPalette( StreamableInit ) :
  136.          TPalette( NULL, 0 )
  137. // Summary ------------------------------------------------------------
  138. //
  139. //      Build constructor for a TStreamPalette.  Since we don't yet
  140. //      know what the palette entries are we won't reserve any memory
  141. //      for them.
  142. //
  143. // END Summary --------------------------------------------------------
  144. {
  145. };
  146. // END TStreamPalette::TStreamPalette ---------------------------------
  147.  
  148.  
  149.  
  150. // Stream Inserters and Extractors //
  151.  
  152. inline ipstream&  operator >> ( ipstream& is, TStreamPalette& cl )
  153.     { return is >> (TStreamable&)cl; }
  154. inline ipstream& operator >> ( ipstream& is, TStreamPalette*& cl )
  155.     { return is >> (void *&)cl; }
  156.  
  157. inline opstream& operator << ( opstream& os, TStreamPalette& cl )
  158.     { return os << (TStreamable&)cl; }
  159. inline opstream& operator << ( opstream& os, TStreamPalette* cl )
  160.     { return os << (TStreamable *)cl; }
  161.  
  162. #endif // __TVPAL_H