Beispiel #1
0
void CEntityOutputWnd::AddInputsForClassname(const std::string &classname)
{
	CEntityRegisterEntity *regEnt = GetEntityRegister()->GetEntity(classname);
	if( regEnt )
	{
		size_t numIns = regEnt->GetNumInputs();
		for(size_t i = 0; i < numIns; i++) //iterate over possible inputs
		{
			CString inName(CA2T(regEnt->GetInput(i)->name.c_str()));
			if( m_cbInput.FindString(-1, inName) == CB_ERR )
				m_cbInput.AddString(inName);
		}
	}
}
Beispiel #2
0
void Decoder::decode(std::string inFileName,std::string outFileName,bool mode)
{
    //open input file
    std::string inName(inFileName);
    if (inName.rfind(".ebast",inName.size()-6) == std::string::npos) {
        std::cerr << "This isn't a ebast File" << std::endl;
        exit(1);
    }
    inFile.open(inFileName, std::ios::in | std::ios::binary);
    if (!inFile.is_open()) {
        std::cerr << "Unable to read File" << std::endl;
        exit(1);
    }
    
    //open output file
    std::string outName(outFileName);
    outName += ".txt";
    if(std::ifstream(outName.c_str()))
    {
        std::cerr<<outName<<" already exists!"<<std::endl;
        exit(1);
    }
    
    outFile.open(outName.c_str(),std::ios::out | std::ios::binary);
    if (!outFile.is_open()) {
        std::cerr << "Unable to create File" << std::endl;
        exit(1);
    }
    
    //reading frequency table from file
    huffmanTree->setRoot(readHeader());
    if (mode) {
        print(huffmanTree->getRoot());
    }
    //make file
    makeFile();
    
}
bool loadBenchHypergraphStream(Graph &G, List<node>& hypernodes, List<edge>* shell, std::istream& fileStream) {
	G. clear();
	hypernodes.clear();
	if(shell) shell->clear();
	node si,so;
	
	char buffer[SIMPLE_LOAD_BUFFER_SIZE];
	
	bool readNodes = true;
	Array<node> indexToNode(1,250,0);

	HashArray<String,node> hm(0);
	
	if(shell) {
//		hypernodes.pushBack( si=G.newNode() );
//		hypernodes.pushBack( so=G.newNode() );
//		shell.pushBack( G.newEdge( si, so ) );		
		shell->pushBack( G.newEdge( si=G.newNode(), so=G.newNode() ) );
	}

	int line = 0;
	while(!fileStream.eof())
	{	
		++line;
		fileStream.getline(buffer, SIMPLE_LOAD_BUFFER_SIZE-1);
		size_t l = strlen(buffer);
		if( buffer[l-1]=='\r' ) { // DOS line
			buffer[l-1]='\0';
		}
		if(!strlen(buffer) || buffer[0]==' ' || buffer[0]=='#') continue;
		if(!strncmp("INPUT(",buffer,6)) {
			String s(extractIdentifierLength(buffer+6, line),buffer+6);
			node n = G.newNode();
			hm[s] = n;
			hypernodes.pushBack(n);
			if(shell) shell->pushBack( G.newEdge(si,n) );
//			cout << "input: " << s << " -> " << n->index() << "\n";					
		} else if(!strncmp("OUTPUT(",buffer,7)) {
			String s(extractIdentifierLength(buffer+7, line),buffer+7);
			node n = G.newNode();
			hm[s] = n;
			hypernodes.pushBack(n);
			if(shell) shell->pushBack( G.newEdge(n,so) );								
//			cout << "output: " << s << " -> " << n->index() << "\n";					
		} else {
			int p = extractIdentifierLength(buffer, line);
			String s(p,buffer); // gatename
			node m = hm[s]; // found as outputname -> refOut
			if(!m) {
				m = hm[inName(s)]; // found as innernode input.
				if(!m) { // generate it anew.
					node in = G.newNode();
					node out = G.newNode();
					hm[inName(s)] = in;
					hm[s] = out;
					hypernodes.pushBack(out);
					G.newEdge(in,out);
					m = in;
				}	
			}
			p = findOpen(buffer, line);
			do {
				++p;
				p += newStartPos(buffer+p, line);
				int pp = extractIdentifierLength(buffer+p, line);
				String s(pp,buffer+p);
				p += pp;
				node mm = hm[s];
				if(!mm) {
					// new
					node in = G.newNode();
					node out = G.newNode();
					hm[inName(s)] = in;
					hm[s] = out;
					hypernodes.pushBack(out);
					G.newEdge(in,out);
					mm = out;
				}
				G.newEdge(mm,m);
//				cout << "Edge: " << s << "(" << hm[s]->index() << ") TO " << m->index() << "\n";
			} while(buffer[p] == ',');			
		}		
	}	
	
	return true;
}