#include "Name.h"

namespace cosi {

std::string Name::sQuantityName = "Name";

Name::Name() {

}

Name::Name(std::string pName) :
	StringQuantity(pName) {
}

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

void Name::Set(Name pName) {
	(*this) = pName;
	IsBot(false) ;
}

bool Name::operator ==(Name pName) {
	return ( this->GetValue() == pName.GetValue());
}

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

const Name Name::operator+(const Name &pT) const {
	Name 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 Name Name::operator-(const Name &pT) const {
	if ( IsAny() )
	return pT;
	if ( pT.IsAny())
	return Get();
	if ( Get() == pT.Get() ) {
		return pT;
	}
	return Name();
}

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