Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleParam.cpp
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 /** @example ExampleParam.cpp
26  * @relates Param
27  @ingroup g_examples
28  @brief Example for using the BIAS::Param parameter object
29  @author MIP */
30 
31 #include <iostream>
32 
33 #include <Utils/Param.hh>
34 #include <Base/Math/Vector.hh>
35 using namespace std;
36 using namespace BIAS;
37 
38 // class MyAlgorithm : public ParamCallbackInterface
39 // {
40 // public:
41 // MyAlgorithm(){};
42 // ~MyAlgorithm(){};
43 
44 // void AddParam(Param &p) {
45 // p.AddParamInt("coollevel","Really cool threshold");
46 // };
47 // };
48 
49 
50 int main(int argc, char *argv[])
51 {
52 
53  Param *p = new Param();
54 
55  Vector<double> vd(3);
56  Vector<int> vi(3);
57  vector<string> myenums;
58  // p.SetDebugLevel(D_PARAM_PARSECMDL);
59 
60  myenums.push_back("foo");
61  myenums.push_back("bar");
62 
63  p->AddParamInt("int-test","Help for testint",42,3,100,'i');
64  p->AddParamDouble("dbl-test","Help for testdbl",1.42,-3.1415,3.1415);
65  p->AddParamString("str-test","Help for teststr","halloe!");
66  p->AddParamDouble("dbl-more-test","Help for testdbl",1.42,-3.1415,3.1415);
67  p->AddParamString("str-more-test","Help for teststr","halloe!");
68  p->AddParamBool("bool","Help for bool",false);
69  p->AddParamVecDbl("dbl-vec","Help me, if you can",vd);
70  p->AddParamVecInt("int-vec","Help me, if you can",vi);
71  p->AddParamEnum("enum","Help me, if you can",myenums);
72 
73  p->ParseCommandLine(argc,argv);
74 
75  p->ShowData();
76 
77  return 0;
78 }
bool * AddParamBool(const std::string &name, const std::string &help, bool deflt=false, char cmdshort=0, int Group=GRP_NOSHOW)
Definition: Param.cpp:305
double * AddParamDouble(const std::string &name, const std::string &help, double deflt=0.0, double min=-DBL_MAX, double max=DBL_MAX, char cmdshort=0, int Group=GRP_NOSHOW)
Definition: Param.cpp:351
int * AddParamEnum(const std::string &name, const std::string &help, const std::vector< std::string > &enums, const int deflt=0, const std::vector< int > *IDs=NULL, const char cmdshort=0, const int Group=GRP_NOSHOW)
Definition: Param.cpp:468
int ParseCommandLine(int &argc, char *argv[])
scan command line arguments for valid parameters
Definition: Param.cpp:1028
BIAS::Vector< int > * AddParamVecInt(const std::string &name, const std::string &help, const BIAS::Vector< int > &deflt, char cmdshort=0, int Group=GRP_NOSHOW)
Add a parameter that expects a string on command line like &quot;&lt;value0&gt; &lt;value1&gt; &lt;value2&gt; ...
Definition: Param.cpp:423
BIAS::Vector< double > * AddParamVecDbl(const std::string &name, const std::string &help, const BIAS::Vector< double > &deflt, char cmdshort=0, int Group=GRP_NOSHOW)
Add a parameter that expects a string on command line like &quot;&lt;value0&gt; &lt;value1&gt; &lt;value2&gt; ...
Definition: Param.cpp:378
This class Param provides generic support for parameters.
Definition: Param.hh:231
int * AddParamInt(const std::string &name, const std::string &help, int deflt=0, int min=std::numeric_limits< int >::min(), int max=std::numeric_limits< int >::max(), char cmdshort=0, int Group=GRP_NOSHOW)
For all adding routines:
Definition: Param.cpp:276
void ShowData(std::ostream &os=std::cout, int grp=GRP_ALL, bool showenhanced=true)
print all data in group grp including current values to os if grp = GRP_ALL, print all values if show...
Definition: Param.cpp:121
std::string * AddParamString(const std::string &name, const std::string &help, std::string deflt="", char cmdshort=0, int Group=GRP_NOSHOW)
Definition: Param.cpp:327