iCub-main
SimConfig.cpp
Go to the documentation of this file.
1 // -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2 
3 /*
4 * Copyright (C) 2010 RobotCub Consortium, European Commission FP6 Project IST-004370
5 * Author: Vadim Tikhanoff, Paul Fitzpatrick
6 * email: vadim.tikhanoff@iit.it, paulfitz@alum.mit.edu
7 * website: www.robotcub.org
8 * Permission is granted to copy, distribute, and/or modify this program
9 * under the terms of the GNU General Public License, version 2 or any
10 * later version published by the Free Software Foundation.
11 *
12 * A copy of the license can be found at
13 * http://www.robotcub.org/icub/license/gpl.txt
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
18 * Public License for more details
19 */
20 
29 #include "SimConfig.h"
30 #include <stdio.h>
31 #include <yarp/os/LogStream.h>
32 
33 using namespace yarp::os;
34 using namespace std;
35 
36 /*
37 static ResourceFinder *_the_finder = NULL;
38 
39 void SimConfig::deleteFinder(){
40  yDebug("deleting finder\n");
41  delete _the_finder;
42 }
43 */
44 
45 static string configureFinder(int argc, char *argv[],
46  string &moduleName, int & verbosity,
47  ResourceFinder& finder) {
48  //string moduleName;
49  finder.setDefaultConfigFile("simulator.ini");
50  finder.setDefaultContext("simConfig");
51  finder.configure(argc, argv);
52 
53 
54  if ( finder.check( "name" ) ) {
55  moduleName = finder.find( "name" ).asString();
56  moduleName = "/" + moduleName;
57  yInfo() << "NEW MODULE NAME " << moduleName;
58  }
59  else {
60  moduleName ="/icubSim";
61  yInfo() << "default module name: " << moduleName;
62  }
63  if ( finder.check( "verbosity" ) ) {
64  verbosity = finder.find( "verbosity" ).asInt32();
65  yInfo() << "custom verbosity level: " << verbosity;
66  }
67  else {
68  verbosity = 0;
69  yInfo() << "default verbosity level: " << verbosity;
70  }
71  return moduleName;
72 }
73 
74 /*
75 string SimConfig::find(const char *fileName) {
76  yDebug("SimConfig::find\n");
77  // yDebug("SimConfig: asked to find %s\n", fileName);
78  string location = findFile(fileName);
79  if (location!="") {
80  //yDebug("Found config: %s\n", location.c_str());
81  }
82  return location;
83 }
84 
85 string SimConfig::findPath(const char *key) {
86  yDebug("SimConfig::findPath\n");
87  // yDebug("SimConfig: asked to find %s\n", fileName);
88  return ResourceFinder::findPath(key);//find(key);
89  // return getFinder().find(key);
90 }
91 */
92 
93 string SimConfig::configure(int argc, char *argv[], string &moduleName, int &verbosity)
94 {
95  yDebug("SimConfig::configure\n");
96  //string moduleName;
97  ::configureFinder( argc, argv, moduleName, verbosity, *this );
98  this->moduleName = moduleName;
99  this->verbosity = verbosity;
100  return moduleName;
101 }
102 
103 
SimConfig::configure
std::string configure(int argc, char *argv[], std::string &moduleName, int &verbosity)
Definition: SimConfig.cpp:93
verbosity
int verbosity
Definition: main.cpp:21
configureFinder
static string configureFinder(int argc, char *argv[], string &moduleName, int &verbosity, ResourceFinder &finder)
Definition: SimConfig.cpp:45
scripting.argc
argc
Definition: scripting.py:184
SimConfig.h
Header for the automatic configuration of the iCub Simulator.