Main MRPT website
>
C++ reference for MRPT 1.9.9
test.cpp
Go to the documentation of this file.
1
/* +------------------------------------------------------------------------+
2
| Mobile Robot Programming Toolkit (MRPT) |
3
| http://www.mrpt.org/ |
4
| |
5
| Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6
| See: http://www.mrpt.org/Authors - All rights reserved. |
7
| Released under BSD License. See details in http://www.mrpt.org/License |
8
+------------------------------------------------------------------------+ */
9
10
#include <
mrpt/system/TParameters.h
>
11
#include <iostream>
12
13
using namespace
std;
14
using namespace
mrpt::system
;
15
16
void
MyCoolFunction
(
const
TParametersDouble
&
params
)
17
{
18
cout <<
"'threshold' is "
<<
params
[
"threshold"
] << endl;
19
cout <<
"Is 'altitude' set? "
<<
params
.has(
"altitude"
) << endl;
20
cout <<
"Is 'level' set? "
<<
params
.has(
"level"
) << endl;
21
cout <<
"Level is : "
<<
params
.getWithDefaultVal(
"level"
, 666.0) << endl;
22
cout <<
"Dump of all params:\n"
<<
params
.getAsString() << endl;
23
cout << endl;
24
}
25
26
// ------------------------------------------------------
27
// TestParameters
28
// ------------------------------------------------------
29
void
TestParameters
()
30
{
31
{
32
// Call #1
33
cout <<
"CALL #1 ================================\n"
;
34
TParametersDouble
p
;
35
p
[
"threshold"
] = 3.05;
36
p
[
"altitude"
] = 100;
37
38
MyCoolFunction
(
p
);
39
}
40
41
{
42
// Call #2
43
cout <<
"CALL #2 ================================\n"
;
44
TParametersDouble
p
(
45
"threshold"
, 3.05,
"altitude"
,
46
100.0,
// *VERY IMPORTANT* If you put "100" here it will be an
47
// "int" and it will crash!!! Make sure all params are
48
// doubles!!
49
"level"
, -1.0,
nullptr
);
50
51
MyCoolFunction
(
p
);
52
}
53
}
54
55
// ------------------------------------------------------
56
// MAIN
57
// ------------------------------------------------------
58
int
main
()
59
{
60
try
61
{
62
TestParameters
();
63
64
return
0;
65
}
66
catch
(std::exception& e)
67
{
68
std::cout <<
"MRPT exception caught: "
<< e.what() << std::endl;
69
return
-1;
70
}
71
catch
(...)
72
{
73
printf(
"Untyped exception!!"
);
74
return
-1;
75
}
76
}
TestParameters
void TestParameters()
Definition:
vision_stereo_rectify/test.cpp:29
p
GLfloat GLfloat p
Definition:
glext.h:6305
TParameters.h
main
int main()
Definition:
vision_stereo_rectify/test.cpp:78
mrpt::system::TParameters< double >
mrpt::system
This namespace provides a OS-independent interface to many useful functions: filenames manipulation,...
Definition:
math_frwds.h:25
params
GLenum const GLfloat * params
Definition:
glext.h:3534
MyCoolFunction
void MyCoolFunction(const TParametersDouble ¶ms)
Definition:
vision_stereo_rectify/test.cpp:16
Page generated by
Doxygen 1.8.17
for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST