|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - downloadIndex: ┃ T d ┃
Length: 7543 (0x1d77) Types: TextFile Names: »double_image.h++«
└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki └─ ⟦this⟧ »EUUGD11/euug-87hel/sec1/image/varc++/double_image.h++«
/* This file contains the definitions necessary to define an image whose data is 8-bit */ #ifndef DOUBLE_IMAGE_H #define DOUBLE_IMAGE_H /* include the support for image data types */ #include <image.h++> /* the definition of the class to manage image structures */ class double_image : image_class { double *image_buffer; // buffer to hold image double **image_rows; // pointers to the rows of the image double **window_rows; // pointers to the rows of the window /* functions for function pointers */ /* this version of next assumes the window has been initialized */ int initialized_next (); /* this version of prev assumes the window has been initialized */ int initialized_prev (); /* this version of next initializes the window */ int uninitialized_next (); /* this version of prev initializes the window */ int uninitialized_prev (); /* this version of next says that the operation is impossible */ int impossible_next (); /* this version of prev says that the operation is impossible */ int impossible_prev (); /* uninitialized version of get_w_e will just die */ double uninitialized_get_w_e ( const card i , const card j ); /* initialized version of get_w_e */ double initialized_get_w_e ( const card i , const card j ); /* uninitialized version of write_w_e will just die */ void uninitialized_write_w_e ( const card i , const card j , const double value ); /* initialized version of write_w_e */ void initialized_write_w_e ( const card i , const card j , const double value ); /* the function to write to the specified element of a window. it is a function pointer so that unitialized windows or protected images don't get read from */ double (* get_w_e_pointer )( const card i , const card j ); /* the function to write to the specified element of a window. it is a function pointer so that unitialized windows or protected images don't get read from can not check argument because it will point to internal elements */ void (* write_w_e_pointer )( const card i , const card j , const double value ); public: /* constructors */ /* the constructor when the image is being read from a file */ double_image ( const read_image_type rit , // marker that the image is being read const FILE * image_file , // file for image const card w_width = 1 , // window width const card w_length = 1 // window length ); /* the constructor when the image is built */ double_image ( const create_image_type cit , // marker that the image is being created const card n_rows , // the number of rows in the image const card n_cols , // the number of collumns in the image const FILE * image_file , // file for image const card w_width = 1 , // window width const card w_length = 1 // window length ); /* destructor (who would want to destroy an image?) */ ~double_image ( ) { ; } /* access routines for parts of data structure */ const card n_rows() { return number_rows ; } const card n_cols() { return number_cols ; } const image_prot the_prot() { return prot; } const card c_length() { return comment_length ; } const char *the_comments() { return comments ; } const card the_collumn() { return collumn ; } const card the_row() { return row ; } const card the_width() { return window_width ; } const card the_length() { return window_length ; } const FILE * the_file() { return file ; } const status image_init() { return image_status ; } const status window_init() { return window_status ; } /* access a pointer to a particular row */ const double * get_row( card row ); /* sets the comments */ void set_comments( char * string , const card length ) { this->image_class::set_comments ( string , length ); } /* adds a string to the comments */ void add_comment( char * string , const card length ) { this->image_class::add_comment ( string , length ); } /* real versions of virtual functions */ /* routine to write out the image to a file */ void write ( ) ; /* move in row n steps returns 1 when that motion is legal 0 otherwise */ int move_collumn ( const int n ) ; /* move in collumn n steps returns 1 when that motion is legal 0 otherwise */ int move_row ( const int n ) ; /* move to specified row */ void move_to_row ( const card n ) ; /* move to specified collumn */ void move_to_collumn ( const card n ) ; /* the function to get the specified element of a window it is a function pointer so that unitialized windows or protected images don't get read from this accesses the function pointer */ double get_w_e ( const card i , const card j ) { return (( double (*) (...) )(* get_w_e_pointer)) ( this , i , j ); } /* the fast function without checking for initialization of a function pointer for getting elements of a window Also no bounds checking! ( Not recommended!) */ double fast_g_w_e ( const card i , const card j ) { return window_rows[i][j]; } /* the function to write to the specified element of a window. it is a function pointer so that unitialized windows or protected images don't get read from this accesses the function pointer */ void write_w_e ( const card i , const card j , const double value ) { ((void (*) (...) )(* write_w_e_pointer)) ( this , i , j , value ); } /* the fast function without checking for initialization of a function pointer for writing elements to a window Also no bounds checking! ( Not recommended!) */ void fast_w_w_e ( const card i , const card j , const double value ) { window_rows[i][j] = value; } /* the function call on the image gets the upper left hand of the image window and returns a reference so it can be used as a lvalue or rvalue optimized so does not check that the window is initialized if the window is not initialized then odd things may happen */ double& operator() () { return **window_rows; } /* move to next legal position in image returns 1 when there is a next legal position 0 otherwise if the window is not initialized then it initializes it. with the window in the position 0,0 (if possible) */ int (* next) (...); /* this will point to member functions! */ /* move to previous legal position in image returns 1 when there is a previous legal position 0 otherwise if the window is not initialized then it initializes it. with the window in the farthest position (if possible) */ int (* prev) (...); /* this will point to member functions! */ /* Access for next and previous elements of images */ int operator++ ( ) { return (* next) ( this /* because points to member*/ ); } int operator-- ( ) { return (* prev) ( this /* because points to member*/ ); } /* Change the size of a window causes the window to become uninitialized */ void resize_window ( card width , card length ); /* Causes the window to cover the entire image. Allows one to access any part of the image with window operations */ void window_entire_image ( ); }; #endif DOUBLE_IMAGE_H /* Copyright (C) 1986, David Sher in the University of Rochester Permission is granted to any individual or institution to use, copy, or redistribute this software so long as it is not sold for profit, provided this copyright notice is retained. */