#include "Type.h"

namespace cosi {

std::string Type::sQuantityName = "Type";

Type::Type() {

}

Type::Type(std::string pType) :
	StringQuantity(pType) {

}

Type Type::Get() const {
	return (*this);
}

void Type::Set(Type pType) {
	(*this) = pType ;
}

bool Type::operator ==(Type pType) {
	return ( this->GetValue() == pType.GetValue());
}

void Type::operator << ( Type pValue ) {
	(*this) = pValue;
}

const Type Type::operator+(const Type &pT) const{
	Type T ;
	if ( IsBot() ) {
		return pT ;
	}
	if ( pT.IsBot()) {
		return Get() ;
	}
	if ( ! (Get() == pT.Get()) || IsAny() || pT.IsAny() ) {
		T.IsAny(true) ;
		return T ;
	}
	//they are equal
	return pT ;
}

const Type Type::operator-(const Type &pT) const{
	if ( IsAny() )
		return pT ;
	if ( pT.IsAny())
		return Get();
	if ( Get() == pT.Get() ) {
		return pT ;
	}
	return Type() ;
}

std::ostream& operator <<(std::ostream &pOs, const Type &pT) {
	pOs << pT.mValue;
	return pOs;
}

}
