home *** CD-ROM | disk | FTP | other *** search
- #ifndef __VIRIMG_H
- #define __VIRIMG_H
-
-
- #define XDISK 1
- #define XXMS 2
-
-
- /* This file contains a two macros for creating extedend arrays and defines
- the following extended array types
- xdouble, xfloat, xint, xchar
- xxdouble, xxfloat, xxint, xxchar
-
- A variable x of type xx<type> will return a variable
- of type x<type> from x[<index>]
- */
-
- /* The following are various external parameters for the Virtual Arrays
- all have defaults which are shown as the first in the list */
- /* Do you want to keep Extended memory safe : 1=Yes 0=No */
- extern char ___safety;
- /* What is the file used for keeping extended memory safe : c:\!safety!.xms
- extern char *___safe_filename;
- /* Do you want informative messages from the array manager : 1=Yes 0=No */
- extern char ___msgs;
- /* What is the filename for the disk caching manger swap file : virarray.swp*/
- extern char *___xfilename;
- /* What is the size of the file buffer for the disk manager : 32768*/
- extern int ___xfile_buf;
- /* Where are the CPP arrays to be cached : XXMS = Extended memory
- XDISK = Disk */
- extern char ___xarrays;
- /* How many blocks are to be held in coventional memory for CPP arrays : 4*/
- extern int __mem_buf;
- /* What is the block size for the CPP manager : 32768 */
- extern long __block_size;
- /* How many block does the CPP manager want : 16 */
- extern int __blocks;
- /* If there is not enough Xtended memory should the manger cache to disk
- instead : 1=Yes 0=No */
- extern char ___auto_disk;
-
- /* The main variables for XARRAY.H are
- __mem_buf, __block_size and __blocks
-
- __mem_buf is the number of memory block in conventional memory
- __block_size is the size of the cache block
- __blocks is the total number of block needed
- __block is restricted to 16 in the demo version
-
- The conventional memory used is __mem_buf*__block_size
- The cache memory used is __blocks*__block_size
-
- By juggling these values around you can trade off speed with memory used
- */
-
-
- extern "C" {
- void initialise_virtual_arrays(int real_img,long array_size,unsigned int no_imgs, int dorx);
- void *pointer_add(void *tes,long no);
- void *large_array(int no,long ind);
- void *img(int no);
- void create_xms_array (long x, long y, int size, long **offset, int **block);
- void delete_xms_array (long **offset, int **block);
-
- /*Timer to measure the time taken for sections of code */
- void start_timer();
- void stop_timer();
- }
-
- #define XARRAY(type) class x##type { private: long *offset; int *block;\
- char xorxx; char temp; long xxind;\
- public: x##type() {temp = 1;}; x##type (long size) {construct (size);} \
- void construct (long size) {temp = 0; \
- long y=size/256; if ((size%256)>0) y++;\
- create_xms_array (y,256,sizeof(type), &offset, &block); xorxx=1; } \
- x##type (const x##type& x) { \
- offset=x.offset; block=x.block, xorxx=x.xorxx; xxind=x.xxind; temp=1;}\
- void destroy() { if (!temp) delete_xms_array (&offset, &block);} \
- ~x##type() { destroy();} \
- type##& operator[](long index) { long ind= index>>8; \
- if (xorxx) return *( type *)\
- (large_array(block[ind],offset[ind]+((index&255)*sizeof(type))));\
- return *( type *)\
- (large_array(block[xxind],offset[xxind]+(index*sizeof(type))));}\
- friend class xx##type;\
- };
-
- #define XXARRAY(type)\
- class xx##type { \
- private :\
- x##type normal; \
- public: \
- xx##type () {normal.temp=1;}; \
- xx##type (long x, long y) { construct (x,y);} \
- xx##type (const xx##type& x) { \
- normal=x.normal; \
- normal.temp=1; } \
- void construct (long x, long y) \
- { create_xms_array (x,y,sizeof(type), &normal.offset, &normal.block);\
- normal.xorxx=0; normal.temp=0;}\
- void destroy() { normal.destroy();} \
- ~xx##type() { destroy();} \
- x##type##& operator[](long index) { \
- normal.xxind=index; \
- return /*( x##type *)*/normal; } };
-
- #define FXXARRAY(type) class fxx##type { private : long *offset; int *block;\
- public: fxx##type () {;}; fxx##type (long x, long y) \
- { construct (x,y);} void construct (long x, long y) \
- { create_xms_array (x,y,sizeof(type), &offset, &block); }\
- type##* operator[](long index) { \
- return ( type *)(large_array(block[index],offset[index])); } };
-
-
- XARRAY (float)
- XXARRAY (float)
- XARRAY (double)
- XXARRAY (double)
- XARRAY (int)
- XXARRAY (int)
- XARRAY (char)
- XXARRAY (char)
-
-
- #endif
-