args.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // $Id$
00004 //
00005 // Copyright 2008, 2009, 2010, 2011, 2012  Antonio Franchi and Paolo Stegagno    
00006 //
00007 // This file is part of MIP.
00008 //
00009 // MIP is free software: you can redistribute it and/or modify
00010 // it under the terms of the GNU General Public License as published by
00011 // the Free Software Foundation, either version 3 of the License, or
00012 // (at your option) any later version.
00013 //
00014 // MIP is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU General Public License
00020 // along with MIP. If not, see <http://www.gnu.org/licenses/>.
00021 //
00022 // Contact info: antonio.franchi@tuebingen.mpg.de stegagno@diag.uniroma1.it
00023 //
00024 // ----------------------------------------------------------------------------
00025 
00026 
00027 #ifndef EGRAPH_ARGS_H
00028 #define EGRAPH_ARGS_H
00029 
00030 #include <libplayerc++/playerc++.h>
00031 #include <iostream>
00032 #include <unistd.h>
00033 #include <string>
00034 
00035 std::string  gHostname(PlayerCc::PLAYER_HOSTNAME);
00036 uint         gPort(PlayerCc::PLAYER_PORTNUM);
00037 uint         gIndex(0);
00038 uint         gDebug(5);
00039 uint         gFrequency(10); // Hz
00040 uint         gDataMode(PLAYER_DATAMODE_PULL);
00041 uint         gEvasionMode(0);
00042 double       gMinLength(0.1);
00043 std::string  gFilename("");
00044 
00045 void print_usage(int argc, char** argv);
00046 
00047 int parse_args(int argc, char** argv)
00048 {
00049   // set the flags
00050   const char* optflags = "h:p:i:d:u:m:e:l:f:";
00051   int ch;
00052 
00053   // use getopt to parse the flags
00054   while(-1 != (ch = getopt(argc, argv, optflags)))
00055   {
00056     switch(ch)
00057     {
00058       // case values must match long_options
00059       case 'h': // hostname
00060           gHostname = optarg;
00061           break;
00062       case 'p': // port
00063           gPort = atoi(optarg);
00064           break;
00065       case 'i': // index
00066           gIndex = atoi(optarg);
00067           break;
00068       case 'd': // debug
00069           gDebug = atoi(optarg);
00070           break;
00071       case 'u': // update rate
00072           gFrequency = atoi(optarg);
00073           break;
00074       case 'm': // datamode
00075           gDataMode = atoi(optarg);
00076           break;
00077       case 'e': // evasion mode
00078           gEvasionMode = atoi(optarg);
00079           break;
00080       case 'l': // minimum length away from prior viewpoint
00081           gMinLength = atof(optarg);
00082           break;
00083       case 'f': // log file name
00084           gFilename = optarg;
00085           break;
00086       case '?': // help
00087       case ':':
00088       default:  // unknown
00089         print_usage(argc, argv);
00090         exit (-1);
00091     }
00092   }
00093 
00094   return (0);
00095 } // end parse_args
00096 
00097 
00098 void print_usage(int argc, char** argv)
00099 {
00100   using namespace std;
00101   cerr << "USAGE:  " << *argv << " [options]" << endl << endl;
00102   cerr << "Where [options] can be:" << endl;
00103   cerr << "  -h <hostname>  : hostname to connect to (default: "
00104        << PlayerCc::PLAYER_HOSTNAME << ")" << endl;
00105   cerr << "  -p <port>      : port where Player will listen (default: "
00106        << PlayerCc::PLAYER_PORTNUM << ")" << endl;
00107   cerr << "  -i <index>     : device index (default: 0)"
00108        << endl;
00109   cerr << "  -d <level>     : debug message level (0 = none -- 9 = all)"
00110        << endl;
00111   cerr << "  -u <rate>      : set server update rate to <rate> in Hz"
00112        << endl;
00113 //  cerr << "  -l      : Use laser if applicable"
00114 //       << endl;
00115   cerr << "  -m <datamode>  : set server data delivery mode"
00116        << endl;
00117   cerr << "                      PLAYER_DATAMODE_PUSH = "
00118        << PLAYER_DATAMODE_PUSH << endl;
00119   cerr << "                      PLAYER_DATAMODE_PULL = "
00120        << PLAYER_DATAMODE_PULL << endl;
00121 /*  cerr << "                      PLAYER_DATAMODE_PUSH_ALL = "
00122        << PLAYER_DATAMODE_PUSH_ALL << endl;
00123   cerr << "                      PLAYER_DATAMODE_PULL_ALL = "
00124        << PLAYER_DATAMODE_PULL_ALL << endl;
00125   cerr << "                      PLAYER_DATAMODE_PUSH_NEW = "
00126        << PLAYER_DATAMODE_PUSH_NEW << endl;
00127   cerr << "                      PLAYER_DATAMODE_PULL_NEW = "
00128        << PLAYER_DATAMODE_PULL_NEW << endl;
00129   cerr << "                      PLAYER_DATAMODE_ASYNC    = "
00130        << PLAYER_DATAMODE_ASYNC << endl;*/
00131   cerr << "  -e     : evasion style (0 - 1)"
00132        << endl;
00133   cerr << "  -l     : minimum length between viewpoints"
00134        << endl;
00135 } // end print_usage
00136 
00137 #endif    //ARGS_H

Generated on Mon Feb 20 07:01:07 2017 for MIP by  doxygen 1.5.6