#ifndef SYSCCODEGEN_H_
#define SYSCCODEGEN_H_

#include <fstream>
#include <sstream>
#include <string>
#include <map>
#include "networks/onchipcommunication/Specification.h"
#include "networks/onchipcommunication/PlatformInstance.h"
#include "networks/onchipcommunication/Implementation.h"
#include "include/onchipcommunication/CosiGlobal.h"

namespace cosi {

namespace io {

namespace onchipcommunication {

using namespace std;

class SyscCodeGen {
public:
	SyscCodeGen(string FileName, string MakeFileName,
	cosi::commstruct::onchipcommunication::Implementation* I, cosi::commstruct::onchipcommunication::Specification* PtP, int pFlitWidth,
	double pClockPeriod);
	~SyscCodeGen();
	void Run();
private:
	void SyscMakeFileGen();

	void SyscOpen();

	void SyscScMain();

	string SyscTrace() ;
	
	void SyscPrintStat(ofstream* f,
			cosi::commstruct::onchipcommunication::Implementation* G,
			cosi::commstruct::onchipcommunication::Specification* PtP);

	void SyscClose();

	string SyscSource( int S, string P);

	string SyscDest( int D, string P);

	string SyscRouter(int V);

	string SyscSourceNetworkInterface( int S , string P);

	string SyscDestNetworkInterface(int D , string P);

	string SyscConnect(
			cosi::commstruct::onchipcommunication::Implementation* G, int U,
			int V);

	int InputIndex(int, string);
	int OutputIndex(int, string);
	void InputIndex(int, string , int );
	void OutputIndex(int, string , int );

	std::map< std::pair<int,std::string> , int > mInputPortIndex;
	std::map< std::pair<int,std::string> , int > mOutputPortIndex;

	
	string mFileName ;
	string mMakefileName ;
	cosi::commstruct::onchipcommunication::Specification* mSpec ;
	cosi::commstruct::onchipcommunication::Implementation* mI ;
	int mFlitWidth ;
	double mClockPeriod;
	
	ofstream* mF ;
	
};

}
}
}

#endif /*SYSCCODEGEN_H_*/
