本文整理汇总了C++中AnyOption::autoUsagePrint方法的典型用法代码示例。如果您正苦于以下问题:C++ AnyOption::autoUsagePrint方法的具体用法?C++ AnyOption::autoUsagePrint怎么用?C++ AnyOption::autoUsagePrint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyOption
的用法示例。
在下文中一共展示了AnyOption::autoUsagePrint方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv)
{
int ret = EXIT_SUCCESS;
// Setup default error handling strategy.
// ...
// Setup the default log stream.
Log logger;
LogSetDefault(&logger);
// Setup the command line handling.
AnyOption options;
// Use this to active debug mode.
options.setFlag("debug", 'd');
options.setVerbose();
options.autoUsagePrint(true);
// Process the command line arguments.
options.processCommandArgs(argc, argv);
String file;
ret = ValidateOptions(options, file);
if( ret != EXIT_SUCCESS )
{
options.printUsage();
return ret;
}
Runtime runtime;
runtime.init();
runtime.shutdown();
return ret;
}
示例2: pfs
//+----------------------------------------------------------------------------+
//| main() |
//-----------------------------------------------------------------------------+
int
main(int argc, char** argv)
{
common::PathFileString pfs(argv[0]);
//////////////////////////////////////////////////////////////////////////////
// User command line parser
AnyOption *opt = new AnyOption();
opt->autoUsagePrint(true);
opt->addUsage( "" );
opt->addUsage( "Usage: " );
char buff[256];
sprintf(buff, " Example: %s -r example1_noisy.cfg", pfs.getFileName().c_str());
opt->addUsage( buff );
opt->addUsage( " -h --help Prints this help" );
opt->addUsage( " -r --readfile <filename> Reads the polyhedra description file" );
opt->addUsage( " -t --gltopic <topic name> (opt) ROS Topic to send OpenGL commands " );
opt->addUsage( "" );
opt->setFlag( "help", 'h' );
opt->setOption( "readfile", 'r' );
opt->processCommandArgs( argc, argv );
if( opt->getFlag( "help" ) || opt->getFlag( 'h' ) ) {opt->printUsage(); delete opt; return(1);}
std::string gltopic("OpenGLRosComTopic");
if( opt->getValue( 't' ) != NULL || opt->getValue( "gltopic" ) != NULL ) gltopic = opt->getValue( 't' );
std::cerr << "[OpenGL communication topic is set to : \"" << gltopic << "\"]\n";
std::string readfile;
if( opt->getValue( 'r' ) != NULL || opt->getValue( "readfile" ) != NULL )
{
readfile = opt->getValue( 'r' );
std::cerr << "[ World description is read from \"" << readfile << "\"]\n";
}
else{opt->printUsage(); delete opt; return(-1);}
delete opt;
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Initialize ROS and OpenGLRosCom node (visualization)
std::cerr << "["<<pfs.getFileName()<<"]:" << "[Initializing ROS]"<< std::endl;
ros::init(argc, argv, pfs.getFileName().c_str());
if(ros::isInitialized())
std::cerr << "["<<pfs.getFileName()<<"]:" << "[Initializing ROS]:[OK]\n"<< std::endl;
else{
std::cerr << "["<<pfs.getFileName()<<"]:" << "[Initializing ROS]:[FAILED]\n"<< std::endl;
return(1);
}
COpenGLRosCom glNode;
glNode.CreateNode(gltopic);
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Reading the input file
std::cerr << "Reading the input file..." << std::endl;
ShapeVector shapes;
PoseVector poses;
IDVector ID;
if(ReadPolyhedraConfigFile(readfile, shapes, poses, ID)==false)
{
std::cerr << "["<<pfs.getFileName()<<"]:" << "Error reading file \"" << readfile << "\"\n";
return(-1);
}
std::cerr << "Read " << poses.size() << " poses of " << shapes.size() << " shapes with " << ID.size() << " IDs.\n";
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Visualizing the configuration of objects
std::cerr << "Visualizing the configuration of objects..." << std::endl;
for(unsigned int i=0; i<shapes.size(); i++)
{
for(size_t j=0; j<shapes[i].F.size(); j++)
{
glNode.LineWidth(1.0f);
glNode.AddColor3(0.3f, 0.6f, 0.5f);
glNode.AddBegin("LINE_LOOP");
for(size_t k=0; k<shapes[i].F[j].Idx.size(); k++)
{
int idx = shapes[i].F[j].Idx[k];
Eigen::Matrix<Real,3,1> Vt = poses[i]*shapes[i].V[ idx ];
glNode.AddVertex(Vt.x(), Vt.y(), Vt.z());
}
glNode.AddEnd();
}
}
glNode.SendCMDbuffer();
ros::spinOnce();
common::PressEnterToContinue();
//
//////////////////////////////////////////////////////////////////////////////
//.........这里部分代码省略.........
示例3: main
int main(int argc, char **argv){
// nekonstantni nastaveni generatoru nahodnych cisel
srand((unsigned int)time(0));
// server cast
clock_t t1, t2;
t1 = clock();
int NP = 50;
double F = 0.7;
double CR = 0.6;
int Generations = 10;
int pocet_neuronu = 5;
char *nejlepsi_jedinec = "nejlepsi_jedinec.txt";
char *data = "data.txt";
int tichy = 0;
// parsovani parametru
AnyOption *opt = new AnyOption();
opt->setVerbose(); /* print warnings about unknown options */
opt->autoUsagePrint(true); /* print usage for bad options */
opt->addUsage( "" );
opt->addUsage( "NNSA (Neural Network Space Arcade) - Testovani rekuretni neuronove site na jednoduche arkade" );
opt->addUsage( "" );
opt->addUsage( "Pouziti: " );
opt->addUsage( "" );
opt->addUsage( " -h --help Zobrazi tuto napovedu " );
opt->addUsage( " -n jedinec.txt Nejlepsi jedinec " );
opt->addUsage( " -d data.txt Udaje o jednotlivych generacich " );
opt->addUsage( " " );
opt->addUsage( " --NP 60 Velikost populace " );
opt->addUsage( " --F 0.7 Mutacni konstanta " );
opt->addUsage( " --CR 0.8 Prah krizeni " );
opt->addUsage( " --generations 100 Pocet kol slechteni populace " );
opt->addUsage( " --neurons 4 Pocet neuronu v neuronove siti " );
opt->addUsage( " --quiet 1 Neukecany rezim " );
opt->addUsage( "" );
opt->setFlag( "help", 'h'); /* a flag (takes no argument), supporting long and short form */
opt->setOption('n');
opt->setOption('d');
opt->setOption("NP");
opt->setOption("F");
opt->setOption("CR");
opt->setOption("generations");
opt->setOption("neurons");
opt->setOption("quiet");
opt->processCommandArgs(argc, argv);
NP = atoi(opt->getValue("NP"));
F = atof(opt->getValue("F"));
CR = atof(opt->getValue("CR"));
Generations = atoi(opt->getValue("generations"));
pocet_neuronu = atoi(opt->getValue("neurons"));
nejlepsi_jedinec = opt->getValue('n');
data = opt->getValue('d');
tichy = atoi(opt->getValue("quiet"));
cout << "Parametry diferencialni evoluce:" << endl;
cout << " -> Velikost populace NP = " << NP << endl;
cout << " -> Mutacni konstanta F = " << F << endl;
cout << " -> Prah krizeni CR = " << CR << endl;
cout << " -> Pocet generaci = " << Generations << endl;
cout << " -> Pocet neuronu = " << pocet_neuronu << endl;
DiferencialniEvoluce *d1 = new DiferencialniEvoluce(NP, F, CR, Generations, pocet_neuronu, &ohodnoceni, tichy, data);
d1->UlozNejlepsiJedinec(nejlepsi_jedinec);
// 32bit - pretece cca po 36 minutach
t2 = clock();
cout << "Doba behu programu: " << ((double) (t2 - t1))/CLOCKS_PER_SEC << endl;
return 0;
}