本文整理汇总了C++中Genome::buildOrganismFromGenome方法的典型用法代码示例。如果您正苦于以下问题:C++ Genome::buildOrganismFromGenome方法的具体用法?C++ Genome::buildOrganismFromGenome怎么用?C++ Genome::buildOrganismFromGenome使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Genome
的用法示例。
在下文中一共展示了Genome::buildOrganismFromGenome方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Genome
Agent * add_agent(char * filename, Agent *mother) {
Genome * myGenome;
myGenome = new Genome(filename);
Agent * newAgent;
char portNum[256]; sprintf(portNum, "%i", curPort);
int pid = myGenome->buildOrganismFromGenome(portNum);
newAgent = new Agent(myGenome, pid, curPort++);
agents.push_back(newAgent);
printf("loaded %s on port %i (%p)\n", filename, newAgent->get_port(), newAgent);
return newAgent;
}
示例2: file_info
Agent * add_agent(const char * filename) {
static int curPort=49153;
QFileInfo file_info(filename);
if(!file_info.exists()) return (Agent*)0;
ifstream validateStream(filename, ios::in);
char magic[8];
validateStream.getline(magic, 8);
if(strcmp(magic, "//body")) return (Agent*)0;
Genome * myGenome;
myGenome = new Genome(filename);
Agent * newAgent;
char portNum[256]; sprintf(portNum, "%i", curPort);
pid_t pid = myGenome->buildOrganismFromGenome(portNum);
if(pid<0 || waitpid(pid, (int*)0, WNOHANG)>0) return (Agent*)0;
newAgent = new Agent(myGenome, pid, curPort++);
agents.push_back(newAgent);
printf("loaded %s on port %i (%p)\n", filename, newAgent->get_port(), newAgent);
return newAgent;
}