Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Connection.h

Go to the documentation of this file.
00001 #ifndef CONNECTION_H
00002 #define CONNECTION_H
00003 #include <string>
00004 #include <iostream>
00005 #include <vector>
00006 #include "BufferedFile.h"
00016 template<class SAMPLE>
00017 class Connection {
00018         public:
00022         virtual void   disconnect() {
00023                 file->Close();
00024         }
00028         virtual string getName() {
00029                 return connectionName;
00030         }
00034         virtual bool   readable() {
00035                 return true;
00036         }
00040         virtual bool   writable() {
00041                 return true;
00042         }
00046         virtual int write(const SAMPLE * data, int size) {
00047                 return file->Write((char *)data,sizeof(SAMPLE)*size);
00048         }
00052         virtual int read(SAMPLE * data, int size){
00053                 return file->Read((char *) data,sizeof(SAMPLE)*size);
00054         }
00058         virtual int getFileHandle() {
00059                 return file->getFileHandle();
00060         }
00064         virtual string getType(){
00065                 return type;
00066         }
00070         virtual void setType(string type) {
00071                 this->type = string(type);
00072         }
00076         Connection()  {
00077                 //NO INIT CALLED
00078         }
00082         Connection(BufferedFile * fd) {
00083                 init(fd,string("Unnamed"));
00084         }
00088         Connection(BufferedFile * fd,string name) {
00089                 init(fd,name);
00090         }
00094         virtual ~Connection() { 
00095                 //cout << "~Connection()\n";
00096                 delete file;
00097         }
00101         virtual bool readReady() {
00102                 return file->readReady();
00103         }
00107         virtual int getDataSize() {
00108                 return 1*sizeof(SAMPLE);
00109         }
00113         virtual bool writeReady() {
00114                 return file->writeReady();
00115         }
00116         protected:
00117         string type;
00118         string connectionName;
00119         BufferedFile * file;
00120         void init(BufferedFile * fd,string name){
00121                 connectionName = string(name);
00122                 this->file = fd;
00123                 type = "short";
00124         }
00125 };
00126 #endif

Generated on Tue Dec 17 21:14:13 2002 for AUSS_Connector by doxygen1.2.18