#include "Node.h"

namespace cosi {

Interface::Interface() {

}

Interface::~Interface() {

}

void Interface::Add(string pName, string pType) {
	(*this)[pName] = pType ;
}
void Interface::Add(string pName, string pType, int pCount) {
	stringstream S;
	for (int i = 0; i<pCount ; i++) {
		//Generate name
		S << pName << "."<< i ;
		(*this)[pName] = pType ;
		S.clear() ;
	}
}

bool Interface::HasPortType(string pType) {
	map<string,string>::iterator It;
	for (It = this->begin() ; It != this->end() ; It++) {
		if (It->second == pType)
			return true;
	}
	return false;
}

bool Interface::HasPortName(string pName) {
	map<string,string>::iterator It;
	for (It = this->begin() ; It != this->end() ; It++) {
		if ( (It->first).find( pName , 0) != string::npos )
			return true ;
	}
	return false;
}

Node::Node() {
	mName = "NA";
	mType = "NA";
}

Node::~Node() {
}

void Node::SetName(string pName) {
	mName = pName;
}

string Node::GetName() {
	return mName;
}

void Node::SetType(string pType) {
	mType = pType;
}

string Node::GetType() {
	return mType;
}

}
