//============================================================ // T C P _ S T R E A M //------------------------------------------------------------ // // maintain a iostream. // // include lossless compression //------------------------------------------------------------ // // //-------------- I M P O R T A N T ------------------------ // 1) POSSIBILITY for improvment? // reserve a large buffer size // 2) break the input/output stream into small pieces. //--------------------------------------------------------- class tcp_Stream { public: tcp_Stream () { stream_fd = 0; COMPRESSION_TYPE = COMPRESS_NON; total_byte_read =0; total_byte_write=0; total_pixel_write=0; total_compressed_coeff_write =0; } tcp_Stream ( int fd ) { stream_fd = fd; COMPRESSION_TYPE = COMPRESS_NON; total_byte_read =0; total_byte_write=0; total_pixel_write=0; total_compressed_coeff_write =0; } ~tcp_Stream () {cout << "delete stream " << stream_fd << endl; } int write_byte ( unsigned char * buffer, unsigned long nos_byte ); int write_int ( int ); int write_integers( int * buffer, long nos_int ); int write_string ( char * ); int read_int ( int *); int read_string ( char *, int ); int read_integers( int * buffer, long nos_int_to_be_read ); int read_byte ( unsigned char * buffer, unsigned long nos_byte ); // ::close refers to the original close () // the statement is redudent. // the stream should be close in the // main program which open it. // int close () {return ::close (stream_fd);} int stream_fd; unsigned long total_byte_read; unsigned long total_byte_write; unsigned long total_pixel_write; unsigned long total_compressed_coeff_write; int COMPRESSION_TYPE; static const int COMPRESS_NON = 0; static const int COMPRESS_LZW = 1; static const int COMPRESS_GZ = 2; };