本文整理汇总了C++中Platform::processors_size方法的典型用法代码示例。如果您正苦于以下问题:C++ Platform::processors_size方法的具体用法?C++ Platform::processors_size怎么用?C++ Platform::processors_size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Platform
的用法示例。
在下文中一共展示了Platform::processors_size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: add_links
int add_links(Platform& hw)
{
cout<<"ADD LINKS"<<endl;
for (int i=0; i<hw.processors_size(); i++)
for (int j=i; j<hw.processors_size(); j++) {
cout<<"Insert byte/second of the link between ";
cout<<i<<" and "<<j<<": ";
int speed;
cin>>speed;
Link *link = hw.add_links();
link->set_id1(i);
link->set_id2(j);
link->set_speed(speed);
}
return 1;
}
示例2: main
int main (int argc, char* argv[])
{
//check parameters
GOOGLE_PROTOBUF_VERIFY_VERSION;
google::ParseCommandLineFlags(&argc, &argv, false);
if (FLAGS_srcFile.compare("")==0) {
cerr<<"The source file is mandatory"<<endl;
return 1;
}
Platform hw;
fstream input(FLAGS_srcFile.c_str(), ios::in | ios::binary);
if (!hw.ParseFromIstream(&input)) {
cerr << "Failed to parse " << FLAGS_srcFile << "." << endl;
exit(0);
}
input.close();
cout<<"#Processors : "<<hw.processors_size()<<endl;
cout<<"\t"<<setw(5)<<"ID"<<setw(15)<<"NAME"<<setw(10)<<"SPEED"<<endl;
for (int i=0; i<hw.processors_size(); i++) {
Processor p = hw.processors(i);
cout<<"\t"<<setw(5)<<p.id()<<setw(15)<<p.name()<<setw(10)<<p.speed();
cout<<endl;
}
cout<<endl;
cout<<"#Links : "<<hw.links_size()<<endl;
cout<<"\t"<<setw(10)<<"FROM"<<setw(10)<<"TO"<<setw(15)<<"BANDWIDTH"<<endl;
for (int i=0; i<hw.links_size(); i++) {
Link l = hw.links(i);
cout<<"\t"<<setw(10)<<l.id1()<<setw(10)<<l.id2()<<setw(15)<<l.speed();
cout<<endl;
}
google::protobuf::ShutdownProtobufLibrary();
return 0;
}