#include "Factory.h"

namespace cosi {

Factory::Factory() {
}

Factory::~Factory() {
}

//Define the object to generate
void Factory::AllocateNetwork(string pType) {
	if (pType=="NocSpecification") {
		mNetwork = new NocSpecification("");
	} else if (pType =="") {

	} else if (pType =="") {

	}
}
void Factory::SetNetworkName(string pName) {
	mNetwork->SetName(pName) ;
}

//Fill in the graph
void Factory::AddVertex(Vertex pV) {
	mNetwork->AddVertex(pV) ;
}

void Factory::AddVertex(Vertex pV, string pName) {
	mNetwork->AddVertex(pV) ;
	mNetwork->SetName(pV, pName) ;
}

void Factory::AddEdge(Edge pE) {
	mNetwork->AddEdge(pE);
}

void Factory::AddEdge(Edge pE, string pName) {
	mNetwork->AddEdge(pE);
	mNetwork->SetName(pE, pName) ;
}

void Factory::SetLabelMapEntry(string pMapName, Vertex pV,
		list<string> pString, list<int> pInt, list<double> pDouble) {

	//Depends on the name of map
	if (pMapName == "Area") {
		double Area = *(pDouble.begin()) ;
		dynamic_cast<NocSpecification*>(mNetwork)->MapArea::Set(pV, Area ) ;
	} else if (pMapName == "InterfaceType") {
		((MapInterfaceType*) mNetwork)->Set(pV,*(pString.begin())) ;
	}

}
void Factory::SetLabelMapEntry(string pMapName, Edge pE, list<string> pString,
		list<int> pInt, list<double> pDouble) {

	if (pMapName == "Bandwidth") {
		double Tmp = *(pDouble.begin()) ;
		cerr << Tmp << endl ;
		dynamic_cast<NocSpecification*>(mNetwork)->MapBandwidth::Set(pE,Tmp) ;
	} else if (pMapName == "HopConstraint") {
		int Tmp = *(pInt.begin()) ;
		cerr << Tmp << endl ;
		dynamic_cast<NocSpecification*>(mNetwork)->MapHopConstraint::Set(pE, Tmp ) ;
	}

}

//Return the object
IdGraph* Factory::GetNetwork() {
	return mNetwork ;
}

}
