DiaDes  0.1
DIAgnosis of Discrete-Event System
Parameter.hh
Go to the documentation of this file.
1 #ifndef __PARAMETER__HH__
2 #define __PARAMETER__HH__
3 
4 template<typename T>
5 void getParameter(int argc, char ** argv, int index, T & param, bool & alreadyRegistered)
6 {
7  if(!alreadyRegistered)
8  {
9  if(argc == index + 1)
10  {
11  cout << "The parameter " << argv[index] << " is not correct" << endl << endl;
12  printUsage();
13  }
14  else
15  {
16  stringstream stream;
17  stream << argv[index + 1];
18  if(stream >> param)
19  {
20  alreadyRegistered = true;
21  }
22  else
23  {
24  cout << "The parameter " << argv[index + 1] << " has an incorrect format" << endl << endl;
25  printUsage();
26  }
27  }
28  }
29 }
30 
31 
32 
33 
34 #endif
void printUsage(const string &description)
void getParameter(int argc, char **argv, int index, T &param, bool &alreadyRegistered)
Definition: Parameter.hh:5