当前位置: 首页>>代码示例>>C++>>正文


C++ OptionParser::parse方法代码示例

本文整理汇总了C++中OptionParser::parse方法的典型用法代码示例。如果您正苦于以下问题:C++ OptionParser::parse方法的具体用法?C++ OptionParser::parse怎么用?C++ OptionParser::parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OptionParser的用法示例。


在下文中一共展示了OptionParser::parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Options

    Options(int argc, char *argv[]) {

        parser = new OptionParser(argc, argv);

        this->init_options();

        // Personnalisation éventuelle du comportement : que faire si l'utilisateur
        // passe une option incorrecte ?  Les valeurs possibles sont :
        //      exit (par défaut), raise, warn, ignore
        // Ici, on veut afficher les clés erronées tout en continuant l'analyse.
        // parser->on_error("warn");
        // Ici, on veut arrêter le programme en cas d'option invalide.
        parser->on_error("exit");  // inutile car c'est "exit" par défaut

        // Permet des post-traitements (vérification de cohérence d'options,...)
        pre_process_options();

        // On peut lancer l'analyse ici ou bien le faire depuis le main() de la
        // du programme principal.
        parser->parse();

        // Permet des post-traitements (vérification de cohérence entre options,...)
        post_process_options();

        // Les attributs options étant affectés, on peut supprimer le parser
        // sauf si on souhaite exploiter quelques-unes de ses méthodes ou attributs
        // e.g parser->print_values() ou parser->params
        //  delete parser;
        //  parser = NULL; // Utile ssi on veut pouvoir tester l'existence de parser !
    }
开发者ID:Razzis,项目名称:projet_ECMA,代码行数:30,代码来源:options.hpp

示例2: main

int main(int argc, char **argv)
{

	OptionParser op;
  op.addOption("verbose", OPT_BOOL, "", "enable verbose output", 'v');
  op.addOption("passes", OPT_INT, "10", "specify number of passes", 'n');
  op.addOption("size", OPT_INT, "1", "specify problem size", 's');
  op.addOption("target", OPT_INT, "0", "specify MIC target device number", 't');
  
  // If benchmark has any specific options, add those
  addBenchmarkSpecOptions(op);
  
  if (!op.parse(argc, argv))
  {
     op.usage();
     return -1;
  }

  ResultDatabase resultDB;
  // Run the test
  RunBenchmark(op, resultDB);

  // Print out results to stdout
  resultDB.DumpDetailed(cout);

	return 0;
}
开发者ID:garethcmurphy,项目名称:lotsofcoresbook2code,代码行数:27,代码来源:main.cpp

示例3: main

int main(int argc, char **argv)
{
    OptionParser cmd;
    cmd.option("-v", "--verbose", "enable verbose stuff", verbose);
    cmd.option("-r", "--required <arg>", "required arg", required);
    cmd.option("-o", "--optional [arg]", "optional arg", optional);
    cmd.parse(argc, argv);
    std::cout << cmd.normalize() << endl;
    //cmd.help();
    return 0;
}
开发者ID:wxwidget,项目名称:option_parser,代码行数:11,代码来源:test.cpp

示例4: boot

int
main(int argc, char** argv)
{
  OptionParser options;
  options.executable("lucb")
  .program(DUNE_SHORT_NAME)
  .copyright(DUNE_COPYRIGHT)
  .email(DUNE_CONTACT)
  .version(getFullVersion())
  .date(getCompileDate())
  .arch(DUNE_SYSTEM_NAME)
  .description("Utility to update firmware of LUCL based devices.")
  .add("-d", "--sys-device",
       "System device", "DEVICE")
  .add("-b", "--baud-rate",
       "Baud rate", "BAUD")
  .add("-i", "--i2c-address",
       "I2C slave address", "I2C_ADDR")
  .add("-f", "--file",
       "iHEX file", "IHEX_FILE");

  // Parse command line arguments.
  if (!options.parse(argc, argv))
  {
    if (options.bad())
      std::cerr << "ERROR: " << options.error() << std::endl;
    options.usage();
    return 1;
  }

  // Get iHEX file.
  std::string ihex = options.value("--file");
  if (ihex.empty())
  {
    std::cerr << "ERROR: you must specify one iHEX file." << std::endl;
    return 1;
  }

  // Get system device.
  std::string sys_dev = options.value("--sys-device");
  if (sys_dev.empty())
  {
    std::cerr << "ERROR: you must specify one system device." << std::endl;
    return 1;
  }

  // Get specified baud rate.
  int baud = 0;
  castLexical(options.value("--baud-rate"), baud);

  // Get I2C address (if any).
  bool is_i2c = false;
  uint8_t i2c_addr = 0;
  if (castLexical(options.value("--i2c-address"), i2c_addr))
  {
    if ((i2c_addr < 0x03) || (i2c_addr > 0x77))
    {
      std::cerr << "ERROR: I2C device address is out of range (0x03 - 0x77)" << std::endl;
      return 1;
    }

    is_i2c = true;
  }

  LUCL::Protocol proto;

  if (is_i2c)
    proto.setI2C(sys_dev, i2c_addr);
  else
    proto.setUART(sys_dev);

  try
  {
    LUCL::BootLoader boot(proto, true, baud);
    boot.flash(ihex);
  }
  catch (std::exception& e)
  {
    std::cerr << "ERROR: " << e.what() << std::endl;
  }

  return 0;
}
开发者ID:FreddyFox,项目名称:dune,代码行数:83,代码来源:dune-lucb.cpp

示例5: if

int
main(int argc, char** argv)
{
  OptionParser options;
  options.executable(argv[0])
  .program(DUNE_SHORT_NAME)
  .copyright(DUNE_COPYRIGHT)
  .email("Renato Caldas <[email protected]>")
  .version(getFullVersion())
  .date(getCompileDate())
  .arch(DUNE_SYSTEM_NAME)
  .description("Utility to update firmware of LUCL based devices.")
  .add("-d", "--sys-device",
       "System device", "DEVICE")
  .add("-i", "--i2c-address",
       "I2C slave address", "I2C_ADDR")
  .add("-c", "--command",
       "LUCL command", "CMD")
  .add("-p", "--data-payload",
       "LUCL data", "DATA0[,DATA1 ...]");

  // Parse command line arguments.
  if (!options.parse(argc, argv))
  {
    if (options.bad())
      std::cerr << "ERROR: " << options.error() << std::endl;
    options.usage();
    return 1;
  }

  // Get system device.
  std::string sys_dev = options.value("--sys-device");
  if (sys_dev.empty())
  {
    std::cerr << "ERROR: you must specify one system device." << std::endl;
    return 1;
  }

  // Get I2C address (if any).
  bool is_i2c = false;
  uint8_t i2c_addr = 0;
  if (castLexical(options.value("--i2c-address"), i2c_addr))
  {
    if ((i2c_addr < 0x03) || (i2c_addr > 0x77))
    {
      std::cerr << "ERROR: I2C device address is out of range (0x03 - 0x77)" << std::endl;
      return 1;
    }

    is_i2c = true;
  }

  // Open the device
  LUCL::Protocol proto;

  if (is_i2c)
    proto.setI2C(sys_dev, i2c_addr);
  else
    proto.setUART(sys_dev);

  try
  {
    proto.open();
  }
  catch (std::exception& e)
  {
    std::cerr << "ERROR: " << e.what() << std::endl;
    return 1;
  }

  // Check for the command token
  std::string command = options.value("--command");
  if (command.empty())
  {
    std::cerr << "ERROR: reading from stdio not supported yet." << std::endl;
    return 1;
  }

  // Get the data payload
  std::string data_str = options.value("--data-payload");
  std::vector<uint8_t> data_lst;
  if (!castLexical(data_str, data_lst))
  {
    std::cerr << "ERROR: failed to parse the data payload argument." << std::endl;
    return 1;
  }

  // Build and send the packet
  if (command.compare("Info") == 0)
  {
    std::cerr << "Requesting device information" << std::endl;
    try
    {
      proto.requestVersion();
    }
    catch (std::exception& e)
    {
      std::cerr << "ERROR: " << e.what() << std::endl;
      return 1;
    }
//.........这里部分代码省略.........
开发者ID:AndreGCGuerra,项目名称:dune,代码行数:101,代码来源:dune-lucl-talk.cpp

示例6: main

// ****************************************************************************
// Method:  main()
//
// Purpose:
//   serial and parallel main for OpenCL level0 benchmarks
//
// Arguments:
//   argc, argv
//
// Programmer:  SHOC Team
// Creation:    The Epoch
//
// Modifications:
//   Jeremy Meredith, Tue Jan 12 15:09:33 EST 2010
//   Changed the way device selection works.  It now defaults to the device
//   index corresponding to the process's rank within a node if no devices
//   are specified on the command command line, and otherwise, round-robins
//   the list of devices among the tasks.
//
//   Gabriel Marin, Tue Jun 01 15:38 EST 2010
//   Check that we have valid (not NULL) context and queue objects before
//   running the benchmarks. Errors inside CreateContextFromSingleDevice or
//   CreateCommandQueueForContextAndDevice were not propagated out to the main
//   program.
//
//   Jeremy Meredith, Wed Nov 10 14:20:47 EST 2010
//   Split timing reports into detailed and summary.  For serial code, we
//   report all trial values, and for parallel, skip the per-process vals.
//   Also detect and print outliers from parallel runs.
//
// ****************************************************************************
int main(int argc, char *argv[])
{
    int ret = 0;

    try
    {
#ifdef PARALLEL
        int rank, size;
        MPI_Init(&argc,&argv);
        MPI_Comm_size(MPI_COMM_WORLD, &size);
        MPI_Comm_rank(MPI_COMM_WORLD, &rank);
        cout << "MPI Task "<< rank << "/" << size - 1 << " starting....\n";
#endif

        OptionParser op;

        //Add shared options to the parser
        op.addOption("platform", OPT_INT, "0", "specify OpenCL platform to use",
                'p');
        op.addOption("device", OPT_VECINT, "", "specify device(s) to run on", 'd');
        op.addOption("passes", OPT_INT, "10", "specify number of passes", 'n');
        op.addOption("size", OPT_VECINT, "1", "specify problem size", 's');
        op.addOption("infoDevices", OPT_BOOL, "",
                "show info for available platforms and devices", 'i');
        op.addOption("verbose", OPT_BOOL, "", "enable verbose output", 'v');
        op.addOption("quiet", OPT_BOOL, "", "write minimum necessary to standard output", 'q');

        addBenchmarkSpecOptions(op);

        if (!op.parse(argc, argv))
        {
#ifdef PARALLEL
            if (rank == 0)
                op.usage();
            MPI_Finalize();
#else
            op.usage();
#endif
            return (op.HelpRequested() ? 0 : 1 );
        }

        if (op.getOptionBool("infoDevices"))
        {
#define DEBUG_DEVICE_CONTAINER 0
#ifdef PARALLEL
            // execute following code only if I am the process of lowest
            // rank on this node
            NodeInfo NI;
            int mynoderank = NI.nodeRank();
            if (mynoderank==0)
            {
                int nlrrank, nlrsize;
                MPI_Comm nlrcomm = NI.getNLRComm();
                MPI_Comm_size(nlrcomm, &nlrsize);
                MPI_Comm_rank(nlrcomm, &nlrrank);

                OpenCLNodePlatformContainer ndc1;
                OpenCLMultiNodeContainer localMnc(ndc1);
                localMnc.doMerge (nlrrank, nlrsize, nlrcomm);
                if (rank==0)  // I am the global rank 0, print all configurations
                    localMnc.Print (cout);
            }
#else
            OpenCLNodePlatformContainer ndc1;
            ndc1.Print (cout);
#if DEBUG_DEVICE_CONTAINER
            OpenCLMultiNodeContainer mnc1(ndc1), mnc2;
            mnc1.Print (cout);
            ostringstream oss;
//.........这里部分代码省略.........
开发者ID:ManavA,项目名称:shoc,代码行数:101,代码来源:main.cpp

示例7: main

int main(int argc, char **argv) {
   OptionParser opts;

   string mapFile, evidFile;

   int factor;

   opts.addOption(new StringOption("map", 
            "--map <filename>                 : map file",
            "../input/grid.bmp", mapFile, false));

   opts.addOption(new StringOption("evidence", 
            "--evidence <filename>            : evidence file",
            "", evidFile, true));

   opts.addOption(new IntOption("factor",
            "--factor <int>                   : scaling factor",
            1, factor, true));

   opts.parse(argc,argv);
   JetColorMap jet;
   RGBTRIPLE black = {0,0,0};

   RGBTRIPLE white = {255,255,255};

   RGBTRIPLE red;
   red.R = 255;
   red.G = 0;
   red.B = 0;

   RGBTRIPLE blue;
   blue.R = 0;
   blue.G = 0;
   blue.B = 255;

   RGBTRIPLE green;
   green.R = 0;
   green.G = 255;
   green.B = 0; 

   RGBTRIPLE initialColor;
   initialColor.R = 111; 
   initialColor.G = 49;
   initialColor.B = 152;
//   initialColor.G = 152;
//   initialColor.B = 49;


   RGBTRIPLE currentColor;
   currentColor.R = 181;
   currentColor.G = 165;
   currentColor.B = 213;
//   currentColor.G = 213;
//   currentColor.B = 165;


   RGBTRIPLE magenta;
   magenta.R = 255;
   magenta.G = 0;
   magenta.B = 255;

   RGBTRIPLE cyan;
   cyan.R = 0;
   cyan.G = 255;
   cyan.B = 255;

   RGBTRIPLE yellow;
   yellow.R = 255;
   yellow.G = 255;
   yellow.B = 0;

   BMPFile bmpFile(mapFile);

   Grid grid(bmpFile, black);

   
   Evidence testSet(evidFile, grid, factor);
 /* 
   if (1) { 
	   evid.split(trainSet, testSet, 0.8);
   }else{
	   evid.deterministicsplit(trainSet, testSet);
   }*/

#if 0 
   cout << "Creating Markov Model"<<endl;
   MarkovModel markmodel(grid, trainSet);

   double totalObj = 0.0;

   for (int i=0; i < testSet.size(); i++) {
      vector<pair<int, int> > path = testSet.at(i);
      cout << "Calling eval"<<endl;
      double obj = markmodel.eval(path);
      cout << "OBJ: "<<i<<" "<<obj<<endl;
	
      totalObj += obj;
   }

   cout << "TOTAL OBJ: "<<totalObj<<endl;
//.........这里部分代码省略.........
开发者ID:yy147379138,项目名称:local_IOC,代码行数:101,代码来源:forecast.cpp

示例8: main

int main(int argc, char *argv[])
{
    int numdev=0, totalnumdev=0, numtasks, mympirank, dest, source, rc,
        mypair=0, count, tag=2, mynoderank,myclusterrank,nodenprocs;
    int *grp1, *grp2;
    int mygrprank,grpnumtasks;
    MPI_Group orig_group,bmgrp;
    MPI_Comm bmcomm,nlrcomm;
    ResultDatabase resultDB,resultDBWU,resultDB1;
    OptionParser op;
    ParallelResultDatabase pardb, pardb1;
    bool amGPUTask = false;
    volatile unsigned long long *mpidone;
    int i,shmid;

    /* Allocate System V shared memory */

    MPI_Init(&argc,&argv);
    MPI_Comm_size(MPI_COMM_WORLD, &numtasks);
    MPI_Comm_rank(MPI_COMM_WORLD, &mympirank);
    MPI_Comm_group(MPI_COMM_WORLD, &orig_group);


    //Add shared options to the parser
    op.addOption("device", OPT_VECINT, "0", "specify device(s) to run on",
		    'd');
    op.addOption("verbose", OPT_BOOL, "", "enable verbose output", 'v');
    op.addOption("quiet", OPT_BOOL, "",
		    "write minimum necessary to standard output", 'q');
    op.addOption("passes", OPT_INT, "10", "specify number of passes", 'z');
    op.addOption("size", OPT_VECINT, "1", "specify problem size", 's');
    op.addOption("time", OPT_INT, "5", "specify running time in miuntes", 't');
    op.addOption("outputFile", OPT_STRING, "output.txt", "specify output file",
       'o');
    op.addOption("infoDevices", OPT_BOOL, "", "show summary info for available devices",
       'i');
    op.addOption("fullInfoDevices", OPT_BOOL, "", "show full info for available devices");
    op.addOption("MPIminmsg", OPT_INT, "0", "specify minimum MPI message size");
    op.addOption("MPImaxmsg", OPT_INT, "16384",
                    "specify maximum MPI message size");
    op.addOption("MPIiter", OPT_INT, "1000",
                    "specify number of MPI benchmark iterations for each size");
    op.addOption("platform", OPT_INT, "0", "specify platform for device selection", 'y');

    if (!op.parse(argc, argv))
    {
        if (mympirank == 0)
            op.usage();
        MPI_Finalize();
        return 0;
    }

    int npasses = op.getOptionInt("passes");

    //our simple mapping
    NodeInfo NI;
    mynoderank = NI.nodeRank();         // rank of my process within the node
    myclusterrank = NI.clusterRank();   // cluster (essentially, node) id
    MPI_Comm smpcomm = NI.getSMPComm();

    if(mynoderank==0){
        shmid = shmget(IPC_PRIVATE,
                 sizeof(unsigned long long),
                 (IPC_CREAT | 0600));
    }

    MPI_Bcast(&shmid, 1, MPI_INT, 0, NI.getSMPComm());

    mpidone = ((volatile unsigned long long*) shmat(shmid, 0, 0));
    if (mynoderank == 0)
        shmctl(shmid, IPC_RMID, 0);
    *mpidone = 0;

    nlrcomm = NI.getNLRComm(); // communcator of all the lowest rank processes
                               // on all the nodes
    int numnodes = NI.numNodes();
    if ( numnodes%2!=0 )
    {
        if(mympirank==0)
            printf("\nThis test needs an even number of nodes\n");
        MPI_Finalize();
	exit(0);
    }
    int nodealr = NI.nodeALR();

    nodenprocs=NI.nodeNprocs();

    // determine how many GPU devices we are to use
    int devsPerNode = op.getOptionVecInt( "device" ).size();
    //cout<<mympirank<<":numgpus="<<devsPerNode<<endl;

    // if there are as many or more devices as the nprocs, only use half of
    // the nproc
    if ( devsPerNode >= nodenprocs ) devsPerNode = nodenprocs/2;

    numdev = (mynoderank == 0) ? devsPerNode : 0;
    MPI_Allreduce(&numdev, &totalnumdev, 1, MPI_INT, MPI_SUM,
                    MPI_COMM_WORLD);
    numdev = devsPerNode;

//.........这里部分代码省略.........
开发者ID:BenjaminCoquelle,项目名称:shoc,代码行数:101,代码来源:bcmain.cpp

示例9: SMITHLABException

int
main(int argc, const char **argv) {

  try {
    
    string prb_file;
    string seqfile;
    string outfile;
    size_t n_reads = 1000;
    size_t read_width = 25;
    size_t max_errors = 0;
    double meth_rate = 0.0;
    double bs_rate = 1.0;
    size_t random_number_seed = numeric_limits<size_t>::max();

    bool VERBOSE = false;
    bool FASTQ_OUTPUT = false;
    bool AG_WILDCARD = false;
    
    /****************** COMMAND LINE OPTIONS ********************/
    static OptionParser 
      opt_parse("simreadsbs",
		"program for generating simulated bisulfite treated reads with "
		"simulated quality scores",
		"<fasta-chrom-files>");
    opt_parse.add_opt("output", 'o', "Name of output file (default: stdout)", false , outfile);
    opt_parse.add_opt("reads", 'n', "number of reads to simulate", false , n_reads);
    opt_parse.add_opt("width", 'w', "width of reads to simulate", false, read_width);
    opt_parse.add_opt("err", 'e', "maximum number of simulated sequencing errors", 
		      false, max_errors);
    opt_parse.add_opt("verbose", 'v', "print more run info", 
		      false, VERBOSE);
    opt_parse.add_opt("fastq", 'q', "write FASTQ format reads", 
		      false, FASTQ_OUTPUT);
    opt_parse.add_opt("prob", 'p', "prb output file", false, prb_file);
    opt_parse.add_opt("meth", 'm', "rate of CpG methylation", 
		      false, meth_rate); 
    opt_parse.add_opt("bs", 'b', "rate of bisulfite conversion", 
		      false, bs_rate);
    opt_parse.add_opt("ag", 'A', "generate A/G wildcard reads", 
		      false, AG_WILDCARD);
    opt_parse.add_opt("seed", 'S', "random number seed", 
		      false, random_number_seed);
    vector<string> leftover_args;
    opt_parse.parse(argc, argv, leftover_args);
    if (argc == 1 || opt_parse.help_requested()) {
      cerr << opt_parse.help_message() << endl;
      return EXIT_SUCCESS;
    }
    if (opt_parse.about_requested()) {
      cerr << opt_parse.about_message() << endl;
      return EXIT_SUCCESS;
    }
    if (opt_parse.option_missing()) {
      cerr << opt_parse.option_missing_message() << endl;
      return EXIT_SUCCESS;
    }
    if (leftover_args.empty()) {
      cerr << opt_parse.help_message() << endl;
      return EXIT_SUCCESS;
    }
    vector<string> filenames(leftover_args);
    /****************** END COMMAND LINE OPTIONS *****************/
    
    if (FASTQ_OUTPUT && !prb_file.empty())
      throw SMITHLABException("fastq output is incompatible "
			  "with specifying a prb file");
    
    const Runif rng(random_number_seed);
    
    vector<string> reads, read_names;
    vector<vector<vector<double> > > probs;
    
    vector<size_t> filesizes;
    double total = 0;
    for (size_t i = 0; i < filenames.size(); ++i) {
      filesizes.push_back(get_filesize(filenames[i]));
      total += filesizes.back();
    }
    
    vector<size_t> samples;
    for (size_t i = 0; i < filesizes.size(); ++i)
      samples.push_back(n_reads*filesizes[i]/total);

    if (!outfile.empty())
      ofstream out(outfile.c_str());

    if (!prb_file.empty())
      ofstream prb(prb_file.c_str());
    
    for (size_t i = 0; i < filenames.size(); ++i) {
      if (VERBOSE)
	cerr << filenames[i] << endl;
      
      vector<string> names, sequences;
      read_fasta_file(filenames[i].c_str(), names, sequences);
      
      for (size_t j = 0; j < names.size(); ++j) {
	const size_t offset = names[j].find(':');
	const string name(names[j].substr(0, offset));
//.........这里部分代码省略.........
开发者ID:Shicheng-Guo,项目名称:rmap,代码行数:101,代码来源:simreadsbs.cpp

示例10: itf

int
main(int argc, char** argv)
{
  OptionParser options;
  options.executable(argv[0])
  .program("DUNE UCTK Flash Programmer")
  .copyright(DUNE_COPYRIGHT)
  .email("Ricardo Martins <[email protected]>")
  .version(getFullVersion())
  .date(getCompileDate())
  .arch(DUNE_SYSTEM_NAME)
  .description("Utility to update the firmware of UCTK based devices.")
  .add("-d", "--dev",
       "System device", "DEVICE")
  .add("-t", "--dev-type",
       "System device type", "TYPE")
  .add("-f", "--file",
       "iHEX file", "IHEX_FILE");

  // Parse command line arguments.
  if (!options.parse(argc, argv))
  {
    if (options.bad())
      std::cerr << "ERROR: " << options.error() << std::endl;
    options.usage();
    return 1;
  }

  // Get iHEX file.
  std::string ihex = options.value("--file");
  if (ihex.empty())
  {
    std::cerr << "ERROR: you must specify one iHEX file." << std::endl;
    return 1;
  }

  if (Path(ihex).type() != Path::PT_FILE)
  {
    std::cerr << "ERROR: no such file: '" << ihex << "'" << std::endl;
    return 1;
  }

  // Get system device.
  std::string sys_dev = options.value("--dev");
  if (sys_dev.empty())
  {
    std::cerr << "ERROR: you must specify one system device." << std::endl;
    return 1;
  }

  // Get device type.
  IO::Handle* handle = NULL;
  std::string dev_type = options.value("--dev-type");
  if (dev_type == "escc")
    handle = new ESCC(sys_dev);
  else
    handle = new SerialPort(sys_dev, c_baud_rate);

  UCTK::Interface itf(handle);
  UCTK::Bootloader* boot = new UCTK::Bootloader(&itf, true);
  boot->program(ihex);
  delete boot;
  delete handle;

  return 0;
}
开发者ID:FreddyFox,项目名称:dune,代码行数:66,代码来源:dune-uctk.cpp

示例11: defined

int
main(int argc, char** argv)
{
  OptionParser options;
  options.executable("dune-test-tail")
  .program(DUNE_SHORT_NAME)
  .copyright(DUNE_COPYRIGHT)
  .email(DUNE_CONTACT)
  .version(getFullVersion())
  .date(getCompileDate())
  .arch(DUNE_SYSTEM_NAME)
  .add("-i", "--address",
       "Vehicle's IP address", "ADDRESS")
  .add("-w", "--wait",
       "Wait DELAY seconds before starting test", "DELAY")
  .add("-d", "--duration",
       "Test duration in seconds", "DURATION")
  .add("-s", "--speed",
       "Speed in percentage", "SPEED")
  .add("-t", "--angle",
       "Angle in degrees", "ANGLE");

  // Parse command line arguments.
  if (!options.parse(argc, argv))
  {
    if (options.bad())
      std::cerr << "ERROR: " << options.error() << std::endl;
    options.usage();
    return 1;
  }

  // Set destination address.
  if (options.value("--address") == "")
    g_addr = "127.0.0.1";
  else
    g_addr = options.value("--address").c_str();

  // Set start delay.
  double sdelay = 0;
  if (options.value("--wait") == "")
    sdelay = 0;
  else
    sdelay = castLexical<double>(options.value("--wait"));

  // Set duration.
  double duration = 0;
  if (options.value("--duration") == "")
    duration = 0;
  else
    duration = castLexical<double>(options.value("--duration"));

  // Set speed.
  double speed = 0;
  if (options.value("--speed") == "")
    speed = 0;
  else
  {
    speed = castLexical<double>(options.value("--speed"));
    speed /= 100.0;
  }

  // Set Angle
  double angle = 0;
  if (options.value("--angle") == "")
    angle = 0;
  else
    angle = castLexical<double>(options.value("--angle"));

  // POSIX implementation.
#if defined(DUNE_SYS_HAS_SIGACTION)
  struct sigaction actions;
  std::memset(&actions, 0, sizeof(actions));
  sigemptyset(&actions.sa_mask);
  actions.sa_flags = 0;
  actions.sa_handler = handleTerminate;
  sigaction(SIGALRM, &actions, 0);
  sigaction(SIGHUP, &actions, 0);
  sigaction(SIGINT, &actions, 0);
  sigaction(SIGQUIT, &actions, 0);
  sigaction(SIGTERM, &actions, 0);
  sigaction(SIGCHLD, &actions, 0);
  sigaction(SIGCONT, &actions, 0);
#endif

  setThrust(0);
  Delay::wait(sdelay);

  setLog("mcrt_endurance");
  Delay::wait(2.0);

  double deadline = Clock::get() + duration;
  setThrust(speed);

  while ((Clock::get() < deadline) && !g_stop)
  {
    setFin(0, -angle);
    setFin(1, -angle);
    setFin(2, -angle);
    setFin(3, -angle);

//.........这里部分代码省略.........
开发者ID:retlaw84,项目名称:dune,代码行数:101,代码来源:dune-test-tail.cpp

示例12: main

/*!
 * Main function.
 */
int main(int argc, char** argv) {
	OptionParser parser;
	parser.parse(argc, argv, CONFIG_FILE);
	po::variables_map cfg = parser.getOptions();

	string sInfile = "", sOutfile = "";
	
	// Processing flags
	bool bSourceIsFile = true;
	bool bDestIsFile = true;
	bool bUseGPU = false;
	bool bThreaded = false;
	unsigned int iModelFrames = DEFAULT_MODEL_TRAINING_COUNT;
	double dLearningRate = DEFAULT_LEARNING_RATE;
	detectionAlgorithm algo = ALGO_MOVING;
	
	// Source video information
	unsigned int iInputWidth, iInputHeight, iInputFps;
	
	/* OPTION READ-IN BEGIN */
	if(cfg.count("help")) {
		cerr << parser.getDescription() << endl;
		return EXIT_SUCCESS;
	}

	if(cfg.count("source")) {
		if(cfg["source"].as<string>() == "CAM")
			bSourceIsFile = false;
		else if(cfg["source"].as<string>() == "DISK")
			bSourceIsFile = true;
		else {
			cerr << ERROR("unrecognized video source") << endl;
			return EXIT_FAILURE;
		}
	}
	
	if(cfg.count("infile"))
		sInfile.assign(cfg["infile"].as<string>());
	
	if(cfg.count("destination")) {
		if(cfg["destination"].as<string>() == "SCREEN") {
			bDestIsFile = false;
			sOutfile = "SCREEN";
		} else if(cfg["destination"].as<string>() == "DISK")
			bDestIsFile = true;
		else {
			cerr << ERROR("unrecognized output destination") << endl;
			return EXIT_FAILURE;
		}
	}
	
	if(bDestIsFile && cfg.count("outfile"))
		sOutfile.assign(cfg["outfile"].as<string>());
	
	if(cfg.count("modelframes")) {
		iModelFrames = cfg["modelframes"].as<unsigned>();
		if(iModelFrames == 0 || iModelFrames > 1000) {
			cerr << ERROR("bad model frame count") << endl;
			return EXIT_FAILURE;
		}
	}
	
	if(cfg.count("learnrate")) {
		dLearningRate = cfg["learnrate"].as<double>();
		if(dLearningRate <= 0.0 || dLearningRate >= 1.0) {
			cerr << ERROR("bad model learning rate") << endl;
			return EXIT_FAILURE;
		}
	}
	
	if(cfg.count("detection")) {
		algo = (detectionAlgorithm)cfg["detection"].as<int>();
		if(algo < ALGO_MOVING || algo > ALGO_CANDIDATESNEW) {
			cerr << parser.getDescription() << endl;
			return EXIT_FAILURE;
		}
	}
	
	if(cfg.count("gpu"))
		bUseGPU = true;
	
	if(cfg.count("threaded"))
		bThreaded = true;
	/* OPTION READ-IN END */

	/* FRONT END SETUP BEGIN */
	VideoCapture cap;	
	// Try to open the video stream
	if(bSourceIsFile) {
		cap.open(sInfile);
	} else {
		cap.open(DEFAULT_CAMERA);
	}
	
	if(!cap.isOpened()) {
		cerr << ERROR("could not open video source");
		return EXIT_FAILURE;
//.........这里部分代码省略.........
开发者ID:nucleus,项目名称:tracker,代码行数:101,代码来源:main.cpp

示例13: main

// ****************************************************************************
// Function: main
//
// Purpose:
//   The main function takes care of initialization (device and MPI),  then
//   performs the benchmark and prints results.
//
// Arguments:
//
//
// Programmer: Jeremy Meredith
// Creation:
//
// Modifications:
//   Jeremy Meredith, Wed Nov 10 14:20:47 EST 2010
//   Split timing reports into detailed and summary.  For serial code, we
//   report all trial values, and for parallel, skip the per-process vals.
//   Also detect and print outliers from parallel runs.
//
// ****************************************************************************
int main(int argc, char *argv[])
{
    int ret = 0;
    bool noprompt = false;

    try
    {
#ifdef PARALLEL
        int rank, size;
        MPI_Init(&argc,&argv);
        MPI_Comm_size(MPI_COMM_WORLD, &size);
        MPI_Comm_rank(MPI_COMM_WORLD, &rank);
        cerr << "MPI Task " << rank << "/" << size - 1 << " starting....\n";
#endif

        // Get args
        OptionParser op;
       
        //Add shared options to the parser
        op.addOption("device", OPT_VECINT, "0",
                "specify device(s) to run on", 'd');
        op.addOption("verbose", OPT_BOOL, "", "enable verbose output", 'v');
        op.addOption("passes", OPT_INT, "10", "specify number of passes", 'n');
        op.addOption("size", OPT_INT, "1", "specify problem size", 's');
        op.addOption("infoDevices", OPT_BOOL, "",
                "show info for available platforms and devices", 'i');
        op.addOption("quiet", OPT_BOOL, "", "write minimum necessary to standard output", 'q');
#ifdef _WIN32
        op.addOption("noprompt", OPT_BOOL, "", "don't wait for prompt at program exit");
#endif

        addBenchmarkSpecOptions(op);

        if (!op.parse(argc, argv))
        {
#ifdef PARALLEL
            if (rank == 0)
                op.usage();
            MPI_Finalize();
#else
            op.usage();
#endif
            return (op.HelpRequested() ? 0 : 1);
        }
        
        bool verbose = op.getOptionBool("verbose");
        bool infoDev = op.getOptionBool("infoDevices");
#ifdef _WIN32
        noprompt = op.getOptionBool("noprompt");
#endif

        int device;
#ifdef PARALLEL
        NodeInfo ni;
        int myNodeRank = ni.nodeRank();
        vector<long long> deviceVec = op.getOptionVecInt("device");
        if (myNodeRank >= deviceVec.size()) {
            // Default is for task i to test device i
            device = myNodeRank;
        } else {
            device = deviceVec[myNodeRank];
        }
#else
        device = op.getOptionVecInt("device")[0];
#endif
        int deviceCount;
        cudaGetDeviceCount(&deviceCount);
        if (device >= deviceCount) {
            cerr << "Warning: device index: " << device <<
            " out of range, defaulting to device 0.\n";
            device = 0;
        }

        // Initialization
        EnumerateDevicesAndChoose(device, infoDev);
        if( infoDev )
        {
            return 0;
        }
        ResultDatabase resultDB;
//.........这里部分代码省略.........
开发者ID:Poojachitral,项目名称:shoc,代码行数:101,代码来源:main.cpp

示例14: daemon

int
main(int argc, char** argv)
{
  Tasks::Context context;
  I18N::setLanguage(context.dir_i18n);
  Scheduler::set(Scheduler::POLICY_RR);

  OptionParser options;
  options.executable("dune")
  .program(DUNE_SHORT_NAME)
  .copyright(DUNE_COPYRIGHT)
  .email(DUNE_CONTACT)
  .version(getFullVersion())
  .date(getCompileDate())
  .arch(DUNE_SYSTEM_NAME)
  .add("-d", "--config-dir",
       "Configuration directory", "DIR")
  .add("-w", "--www-dir",
       "HTTP server base directory", "DIR")
  .add("-c", "--config-file",
       "Load configuration file CONFIG", "CONFIG")
  .add("-m", "--lock-memory",
       "Lock memory")
  .add("-p", "--profiles",
       "Execution Profiles", "PROFILES")
  .add("-V", "--vehicle",
       "Vehicle name override", "VEHICLE")
  .add("-X", "--dump-params-xml",
       "Dump parameters XML to folder DIR", "DIR");

  // Parse command line arguments.
  if (!options.parse(argc, argv))
  {
    if (options.bad())
      std::cerr << "ERROR: " << options.error() << std::endl;
    options.usage();
    return 1;
  }

  // If requested, lock memory.
  if (!options.value("--lock-memory").empty())
  {
#if defined(DUNE_USING_TLSF) && defined(DUNE_CLIB_GNU)
    Resources::lockMemory(c_memory, c_memory_size);
#else
    Resources::lockMemory();
#endif
  }

  // If requested, set alternate configuration directory.
  if (options.value("--config-dir") != "")
  {
    context.dir_cfg = options.value("--config-dir");
  }

  // If requested, set alternate HTTP server directory.
  if (options.value("--www-dir") != "")
  {
    context.dir_www = options.value("--www-dir");
  }

  DUNE::Tasks::Factory::registerDynamicTasks(context.dir_lib.c_str());
  registerStaticTasks();

  // Retrieve configuration file and try parsing it.
  if (options.value("--config-file") == "")
  {
    std::cerr << String::str(DTR("ERROR: no configuration file was given, "
                                 "see options --config-list and --config-file\n"))
              << std::endl;
    return 1;
  }

  Path cfg_file = context.dir_cfg / options.value("--config-file") + ".ini";
  try
  {
    context.config.parseFile(cfg_file.c_str());
  }
  catch (std::runtime_error& e)
  {
    try
    {
      cfg_file = context.dir_usr_cfg / options.value("--config-file") + ".ini";
      context.config.parseFile(cfg_file.c_str());
      context.dir_cfg = context.dir_usr_cfg;
    }
    catch (std::runtime_error& e2)
    {
      std::cerr << String::str("ERROR: %s\n", e.what()) << std::endl;
      std::cerr << String::str("ERROR: %s\n", e2.what()) << std::endl;
      return 1;
    }
  }

  if (!options.value("--vehicle").empty())
    context.config.set("General", "Vehicle", options.value("--vehicle"));

  try
  {
    DUNE::Daemon daemon(context, options.value("--profiles"));
//.........这里部分代码省略.........
开发者ID:AndreGCGuerra,项目名称:dune,代码行数:101,代码来源:Daemon.cpp

示例15: opt_parse

int
main(int argc, const char **argv) {

  try {
    
    string prb_file;
    string seqfile;
    string outfile;
    size_t n_reads = 1000;
    size_t read_width = 25;
    size_t max_errors = 0;
    size_t random_number_seed = numeric_limits<size_t>::max();
    
    bool VERBOSE = false;
    bool FASTQ_OUTPUT = false;

    /****************** COMMAND LINE OPTIONS ********************/
    static OptionParser opt_parse("simreads",
				  "program for generating simulated reads"
				  " with simulated quality scores",
				  "<fasta-chrom-files>");
    opt_parse.add_opt("output", 'o', "Name of output file (default: stdout)",
		      false , outfile);
    opt_parse.add_opt("reads", 'n', "number of reads to simulate", 
		      false, n_reads);
    opt_parse.add_opt("width", 'w', "width of reads to simulate", 
		      false, read_width);
    opt_parse.add_opt("err", 'e', "maximum number of simulated sequencing errors",
		      false, max_errors);
    opt_parse.add_opt("verbose", 'v', "print more run info", 
		      false, VERBOSE);
    opt_parse.add_opt("fastq", 'q', "write FASTQ format reads", 
		      false, FASTQ_OUTPUT);
    opt_parse.add_opt("prob", 'p', "prb output file", 
		      false, prb_file);
    opt_parse.add_opt("seed", 'S', "random number seed", 
		      false, random_number_seed);
    vector<string> leftover_args;
    opt_parse.parse(argc, argv, leftover_args);
    if (argc == 1 || opt_parse.help_requested()) {
      cerr << opt_parse.help_message() << endl;
      return EXIT_SUCCESS;
    }
    if (opt_parse.about_requested()) {
      cerr << opt_parse.about_message() << endl;
      return EXIT_SUCCESS;
    }
    if (opt_parse.option_missing()) {
      cerr << opt_parse.option_missing_message() << endl;
      return EXIT_SUCCESS;
    }
    if (leftover_args.empty()) {
      cerr << opt_parse.help_message() << endl;
      return EXIT_SUCCESS;
    }
    vector<string> filenames(leftover_args);
    /****************** END COMMAND LINE OPTIONS *****************/
    
    if (FASTQ_OUTPUT && !prb_file.empty())
      throw SMITHLABException("fastq output is incompatible "
			  "with specifying a prb file");

    const Runif rng(random_number_seed);
    
    vector<string> reads, read_names;
    vector<vector<vector<double> > > probs;
    
    vector<size_t> filesizes;
    double total = 0;
    for (size_t i = 0; i < filenames.size(); ++i) {
      filesizes.push_back(get_filesize(filenames[i]));
      total += filesizes.back();
    }

    if (VERBOSE)
      cerr << "[OBTAINING READ SAMPLE DISTRIBUTION]";
    vector<size_t> samples;
    for (size_t i = 0; i < filesizes.size(); ++i)
      samples.push_back(n_reads*filesizes[i]/total);
    if (VERBOSE) cerr << "[DONE]" << endl;
    
    if (!outfile.empty())
      ofstream out(outfile.c_str());
    
    if (!prb_file.empty())
      ofstream prb(prb_file.c_str());
    
    for (size_t i = 0; i < filenames.size(); ++i) {
      if (isdir(filenames[i].c_str()))
	throw SMITHLABException("\"" + filenames[i] + 
			    "\" not a FASTA format sequence file?");
      if (VERBOSE)
	cerr << "[LOADING=" << filenames[i] << "]";
      vector<string> names, sequences;
      read_fasta_file(filenames[i].c_str(), names, sequences);
      if (VERBOSE) cerr << "[DONE]" << endl;

      double sub_total = 0;
      for (size_t k = 0; k < sequences.size(); ++k)
	sub_total += sequences[i].length();
//.........这里部分代码省略.........
开发者ID:Shicheng-Guo,项目名称:rmap,代码行数:101,代码来源:simreads.cpp


注:本文中的OptionParser::parse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。