#include "LinkParameter.h"

namespace cosi {

namespace quantity {

namespace onchipcommunication {

LinkParameter::LinkParameter() {
}

LinkParameter::LinkParameter(
		cosi::library::onchipcommunication::Technology pTech) {
	mTech = pTech ;
	IsBot(false) ;
}

LinkParameter::~LinkParameter() {
}

LinkParameter LinkParameter::Get() {
	return (*this);
}

void LinkParameter::Set(LinkParameter pLp) {
	(*this) = pLp ;
	IsBot(false) ;
}

cosi::library::onchipcommunication::Technology LinkParameter::GetTechnology() const {
	return mTech ;
}

void LinkParameter::SetTechnology(
		cosi::library::onchipcommunication::Technology pTech) {
	mTech = pTech ;
	IsBot(false) ;
}

bool LinkParameter::operator ==(const LinkParameter &pP) const {
	if ( IsAny() && pP.IsAny() ) {
		return true;
	}
	if ( IsBot() && pP.IsBot() ) {
		return true;
	}
	if ( mTech == pP.GetTechnology()) {
		return true;
	} else {
		return false;
	}
}

bool LinkParameter::operator <(const LinkParameter &pP) const {
	if ( pP.IsAny() && ! IsAny()) {
		return true;
	}
	if ( IsBot() && ! pP.IsBot() ) {
		return true;
	}
	return false;
}

LinkParameter LinkParameter::operator+(LinkParameter pT) {
	if ( IsAny() )
	return pT;
	if ( pT.IsAny())
	return (*this);
	if ( (*this) == pT ) {
		return (*this);
	} else {
		return LinkParameter();
	}
}
LinkParameter LinkParameter::operator-(LinkParameter pT) {
	if ( IsAny() )
	return pT;
	if ( pT.IsAny())
	return (*this);
	if ( (*this) == pT ) {
		return (*this);
	} else {
		return LinkParameter();
	}
}

std::ostream& operator <<(std::ostream &pOs, const LinkParameter &pP) {
	pOs << "Technology " ;
	if ( pP.GetTechnology() == cosi::library::onchipcommunication::T90 )
		pOs << " 90 nm" ;
	else if ( pP.GetTechnology() == cosi::library::onchipcommunication::T65 )
		pOs << " 65 nm" ;
	else if ( pP.GetTechnology() == cosi::library::onchipcommunication::T45 )
			pOs << " 45 nm" ;
	else if ( pP.GetTechnology() == cosi::library::onchipcommunication::T32 )
			pOs << " 32 nm" ;
	return pOs;
}

std::string LinkParameter::sQuantityType="()";
std::string LinkParameter::sQuantityName="LinkParameters";

}

}

}
