Listing 1 Header file for GPIB stream classes

// gpibio.h
#ifndef GPIBIO
#define GPIBIO
#include "decl.h" // NI-488.2(TM) prototypes

// GENERIC Stream Class
class gstream
{
protected:
       char * base_;     // start of get buffer area
       char * ebuf_;     // end+1 of get buffer area
       char * pbase_;    // start of put area
       char * pptr_;     // next put location
       char * epptr_;    // end+1 of put area
       char * gptr_;     // next get location
       char * egptr_;    // end+1 of filled part of get buffer
       int gleng_;       // Current length of get area
public:
          gstream();     // constructor
          ~gstream();    // destructor
       void sputc(char c);
       void sput(char *);

       char sgetc();
       char sbumpc();
       virtual int underflow()=0; // fill empty buffer
       virtual void overflow()=0; // flush buffer and make more room
       void gets(char *s);
       void flush_input() {gptr_ = egptr_;}
};

// GPIB BOARD CLASS
class gpibdvr
{
   int bhandle;
public:
   gpibdvr(int b=0);
   int open_device(int d);
};

// GPIB Interface Class
class gpibio
{
   static int     rep_cnt[2];
protected:
   static gpibdvr *dvr[2];
public:
   int board;
   int device;
   int radix;
   int status;
   gpibio(int b=0);  // Constructor
   ~gpibio(); // Destructor
   int operator !(){return (status&(ERR|TIMO))!=0;}
};

// OUTPUT CLASS
class gpibout: public gpibio , public gstream
{
public:
       gpibout(int d=5,int b=0);
       gpibout & operator <<(char *s);
       gpibout & operator <<(char);
       gpibout & operator <<(short);
       gpibout & operator <<(int);
       gpibout & operator <<(long);
       gpibout & operator <<(float);
       gpibout & operator <<(double);
       gpibout & operator<< (gpibout & (*_f)(gpibout &));
       virtual void overflow();  // flush buffer and make more room
       virtual int underflow();  // dummy
};

// INPUT CLASS
class gpibin: public gpibio , public gstream
{
public:
       gpibin(int d=5,int b=0);
       int srqwait();
       gpibin& operator >(char *s);
       gpibin& operator >(float &);
       gpibin& operator >(double &);
       gpibin& operator >(char &);
       gpibin& operator >(short &);
       gpibin& operator >(int &);
       gpibin& operator >(long &);
       gpibin & operator> (gpibin & (*_f)(gpibin &));
       virtual int underflow();  // fill empty buffer
       virtual void overflow();  // dummy
};

// Manipulators
gpibout & flush(gpibout &x);
gpibout & endl(gpibout &x);
gpibout & dec(gpibout &x);
gpibout & hex(gpibout &x);
gpibout & oct(gpibout &x);
gpibout & bin(gpibout &x);
gpibin & dec(gpibin &x);
gpibin & hex(gpibin &x);
gpibin & oct(gpibin &x);
gpibin & bin(gpibin &x);
gpibin & flush(gpibin &x);

#endif
/* End of File */