home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 14 / CDACTUAL.iso / cdactual / demobin / share / program / c / XMS11.ZIP / XMSHNDL.H < prev    next >
Encoding:
Text File  |  1990-08-31  |  2.8 KB  |  77 lines

  1. // Microsoft eXtended Memory Specification
  2. // C++ Interface Library Header File
  3. // by Richard Vuduc 
  4. // Copyright 1990, Richard Vuduc
  5.  
  6. // Flags structure (union)
  7. // Not fully implemented as of yet...
  8. union SwapFlags
  9. {
  10.     unsigned char fbyte;
  11.     struct {
  12.         unsigned Present:1;        // Is data segment in conv. mem.?
  13.         unsigned Accessed:1;    // Has data been accessed recently?
  14.         unsigned Read:1;        // Is the data readable?
  15.         unsigned Write:1;        // Is the data writable?
  16.         unsigned Swap:1;        // Is the data swappable to ext. mem?
  17.         unsigned Cache:1;        // Is the conv. mem. data cache on?
  18.     } fbits;
  19. };
  20.  
  21. // Element in the linked list of extended memory blocks
  22. // In conjunction with the XMSDriver class, it provides a
  23. // reasonable set of data managment commands
  24. class XMSHandle
  25. {
  26.     unsigned Handle;              // Extended Memory Handle No.
  27.     long ByteSize;                // Size of 'Data' in bytes
  28.     long Index;                // Index into the data
  29.     SwapFlags SwFlags;            // Swapping Flags
  30.     void *Data;                // Conventional Memory Cache
  31.     long CStart;                // Cache start index
  32.     long CLen;                // Cache end index
  33.     long CIndex;                // Cache index
  34.     XMSHandle *Prev, *Next;        // Pointers to next and prev. in the chain
  35. public:
  36.     XMSHandle( unsigned csize = 50 );        // Constructor
  37.     ~XMSHandle( void );                    // Destructor
  38.     boolean Realloc( unsigned ksize );        // Realloc block
  39.     boolean CRealloc( unsigned size );        // Reallocate cache block
  40.  
  41.     boolean Bounds( long i ) {            // Is 'i' within length?
  42.         return ((i < ByteSize) && (i >= 0) ? True : False);
  43.     }    
  44.     boolean SetPtr( long i );            // Set 'Index'
  45.     long GetPtr( void ) { return Index; }    // Return Index
  46.     void IncPtr( long size = 0 );            // Increment Index
  47.  
  48.     void SetSwap( boolean s ) {            // Set swappable flag
  49.         SwFlags.fbits.Swap = s;
  50.     }
  51.     unsigned GetHandle( void ) {                // Get handle number
  52.         return Handle;
  53.     }
  54.     boolean GetCache( void ) {             // Is the cache on right now?
  55.         return (boolean) SwFlags.fbits.Cache;
  56.     }
  57.     long GetSize( void ) { return ByteSize; }    // Get size of EMB
  58.  
  59.     void Get( char& a );               // Get a character data item
  60.     void Get( int&  a );               // Get an integer data item
  61.     void Get( long& a );               // Get a long data item
  62.     boolean Get( void far *a, unsigned& len, long off = -1 );
  63.  
  64.     void Store( char& a );            // Store a char into cur pos.
  65.     void Store( int&  a );            // Store an integer
  66.     void Store( long& a );            // Store a long into cur pos.
  67.     boolean Store( void far *a, unsigned& len, long off = -1 );
  68.  
  69.     void SetCache( boolean s );            // Toggle cache buffer
  70.     void CacheRead( void );                // Load the cache buffer
  71.     void CacheWrite( void );                // Flush the cache buffer to EMB
  72.     void CacheUpdate( unsigned chksize=1 ); // Update the cache buffer
  73.     boolean CBounds( long i );            // Confirm that 'i' is in buffer
  74.     friend XMSDriver;                    // Allow XMSDriver access
  75. };
  76. // END XMSHNDL.H
  77.