Changeset 16 in flair-src for trunk/demos/Sinus/src/main.cpp


Ignore:
Timestamp:
Apr 8, 2016, 3:48:40 PM (5 years ago)
Author:
Bayard Gildas
Message:

Reformatting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/demos/Sinus/src/main.cpp

    r14 r16  
    1616#include <stdio.h>
    1717
    18 //we use namespace std, to avoid writing for examlpe std::string
     18// we use namespace std, to avoid writing for examlpe std::string
    1919using namespace std;
    20 //idem for TCLAP
     20// idem for TCLAP
    2121using namespace TCLAP;
    22 //idem for flair
     22// idem for flair
    2323using namespace flair::core;
    2424
    25 //global variables for the command line arguments
    26 string logPath;//path for logs
    27 string address;//address for FlairGCS
    28 int port;//port for FlairGCS
    29 string xmlFile;//setup xml file
    30 string name;//name
     25// global variables for the command line arguments
     26string logPath; // path for logs
     27string address; // address for FlairGCS
     28int port; // port for FlairGCS
     29string xmlFile; // setup xml file
     30string name; // name
    3131
    32 void parseOptions(int argc, char** argv);
     32void parseOptions(int argc, char **argv);
    3333
    34 int main(int argc, char* argv[]) {
    35     //get command line arguments (name,port,xml_file,log_path)
    36     parseOptions(argc,argv);
     34int main(int argc, char *argv[]) {
     35  // get command line arguments (name,port,xml_file,log_path)
     36  parseOptions(argc, argv);
    3737
    38     //creation of FrameworkManager
    39     FrameworkManager *manager;
    40     manager= new FrameworkManager(name);
    41     manager->SetupConnection(address,port);
    42     manager->SetupUserInterface(xmlFile);
    43     manager->SetupLogger(logPath);
     38  // creation of FrameworkManager
     39  FrameworkManager *manager;
     40  manager = new FrameworkManager(name);
     41  manager->SetupConnection(address, port);
     42  manager->SetupUserInterface(xmlFile);
     43  manager->SetupLogger(logPath);
    4444
    45     //creation of the
    46     Loop* example=new Loop(manager,"Loop");
     45  // creation of the
     46  Loop *example = new Loop(manager, "Loop");
    4747
    48     //start loop
    49     example->Start();
     48  // start loop
     49  example->Start();
    5050
    51     //wait for loop ends (with kill button)
    52     example->Join();
     51  // wait for loop ends (with kill button)
     52  example->Join();
    5353
    54     delete manager;
     54  delete manager;
    5555}
    5656
     57void parseOptions(int argc, char **argv) {
     58  try {
     59    CmdLine cmd("Command description message", ' ', "0.1");
    5760
    58 void parseOptions(int argc, char** argv) {
    59     try {
    60         CmdLine cmd("Command description message", ' ', "0.1");
     61    // name of the FrameworkManager, Sinus by default
     62    ValueArg<string> nameArg("n", "name", "program name", false, "Sinus",
     63                             "string");
     64    cmd.add(nameArg);
    6165
    62         //name of the FrameworkManager, Sinus by default
    63         ValueArg<string> nameArg("n","name","program name",false,"Sinus","string");
    64         cmd.add( nameArg );
     66    // setup xml file, ./Sinus.xml by default
     67    ValueArg<string> xmlArg("x", "xml", "xml file", false, "./Sinus.xml",
     68                            "string");
     69    cmd.add(xmlArg);
    6570
    66         //setup xml file, ./Sinus.xml by default
    67         ValueArg<string> xmlArg("x","xml","xml file",false,"./Sinus.xml","string");
    68         cmd.add( xmlArg );
     71    // log path, ./ by defaults
     72    ValueArg<string> logArg("l", "log", "log path", false, "/tmp", "string");
     73    cmd.add(logArg);
    6974
    70         //log path, ./ by defaults
    71         ValueArg<string> logArg("l","log","log path",false,"/tmp","string");
    72         cmd.add( logArg );
     75    // address for FlairGCS
     76    ValueArg<string> addressArg("a", "address",
     77                                "address for FlairGCS station sol", false,
     78                                "127.0.0.1", "string");
     79    cmd.add(addressArg);
    7380
    74         //address for FlairGCS
    75         ValueArg<string> addressArg("a","address","address for FlairGCS station sol",false,"127.0.0.1","string");
    76         cmd.add( addressArg );
     81    // port for FlairGCS, 9000 by default
     82    ValueArg<int> portArg("p", "port", "port for FlairGCS", false, 9000, "int");
     83    cmd.add(portArg);
    7784
    78         //port for FlairGCS, 9000 by default
    79         ValueArg<int> portArg("p","port","port for FlairGCS",false,9000,"int");
    80         cmd.add( portArg );
     85    cmd.parse(argc, argv);
    8186
    82         cmd.parse( argc, argv );
     87    // Get the value parsed by each arg.
     88    logPath = logArg.getValue();
     89    port = portArg.getValue();
     90    xmlFile = xmlArg.getValue();
     91    name = nameArg.getValue();
     92    address = addressArg.getValue();
    8393
    84         // Get the value parsed by each arg.
    85         logPath = logArg.getValue();
    86         port=portArg.getValue();
    87         xmlFile = xmlArg.getValue();
    88         name=nameArg.getValue();
    89         address=addressArg.getValue();
    90 
    91     } catch (ArgException &e) { // catch any exceptions
    92         cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
    93     }
     94  } catch (ArgException &e) { // catch any exceptions
     95    cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
     96  }
    9497}
Note: See TracChangeset for help on using the changeset viewer.