#pragma implementation
#include "Connection.h"

template<class SAMPLE> 
Connection<SAMPLE>::Connection<SAMPLE>(BufferedFile fd) {	
	init(fd,"Unnamed");
}
template<class SAMPLE> 
Connection<SAMPLE>::~Connection<SAMPLE>() {	
}
template<class SAMPLE> 
Connection<SAMPLE>::Connection<SAMPLE>(BufferedFile fd,string name) {	
	init(fd,name);
}
template<class SAMPLE> 
void   Connection<SAMPLE>::disconnect() {
	file.Close();
}
template<class SAMPLE> 
string Connection<SAMPLE>::getName() {
	return connectionName;
}
template<class SAMPLE> 
bool   Connection<SAMPLE>::readable() {
	return true;
}
template<class SAMPLE> 
bool   Connection<SAMPLE>::writable() {
	return true;
}
template<class SAMPLE> 
int Connection<SAMPLE>::write(const SAMPLE * data, int size) { //is char valid? void would be more acceptable..
	//return write(filehandle,(void *)data, sizeof(SAMPLE)*size);
	return file.Write((char *)data,sizeof(SAMPLE)*size);
}
template<class SAMPLE> 
int Connection<SAMPLE>::read(SAMPLE * data, int size) { //is char valid? void would be more acceptable...
	//return read(this.filehandle,(void *)data, sizeof(SAMPLE)*size);
	return file.Read((char *) data,sizeof(SAMPLE)*size);
}
template<class SAMPLE> 
void Connection<SAMPLE>::init(BufferedFile file,string name) {
	connectionName = new string(name);
	this.file = file;
	type = "short";
}
template<class SAMPLE> 
int Connection<SAMPLE>::getFileHandle() {
	return file.getFileHandle();
}
template<class SAMPLE> 
string Connection<SAMPLE>::getType() {
	return type;
}
template<class SAMPLE> 
void Connection<SAMPLE>::setType(string type) {
	this.type = string(type);
}
