#include "Interface.h"

namespace cosi {

namespace quantity {

namespace onchipcommunication {

Interface::Interface() {
}

Interface::~Interface() {
}

Interface::tDirection Interface::GetDirection() const {
	return mDir ;
}
void Interface::SetDirection(Interface::tDirection pDir) {
	mDir = pDir ;
}
std::string Interface::GetName() const {
	return mName ;
}
void Interface::SetName(std::string pName) {
	mName = pName ;
}

bool Interface::operator==(const Interface &pP) const {
	//this is the right thing to do
	//however, each field in the physical interface
	//should be a quantity so that the bot and
	//top values can be used
//	if ( mName == pP.GetName() && mDir == pP.GetDirection() &&
//			(PhysicalInterface)(*this) == (PhysicalInterface)(pP)) {
//		return true;
//	} else {
//		return false;
//	}

	//By now simply check name and direction
	if ( mName == pP.GetName() && mDir == pP.GetDirection()) {
		return true;
	} else {
		return false;
	}
}

bool Interface::operator!=(const Interface &pP) const {
	return ( !( (*this) == pP ));
}

std::ostream& operator<<(std::ostream &pOs , const Interface &pP) {
	pOs << pP.mName << " ";
	if ( pP.mDir == Interface::IN ) {
		pOs << "IN";
	} else if (pP.mDir == Interface::OUT ) {
		pOs << "OUT";
	} else if (pP.mDir == Interface::INOUT ) {
		pOs << "INOUT";
	}
	pOs << std::endl;
	pOs << (PhysicalInterface)pP;
	return pOs;
}

}

}

}
