@@ -35,15 +35,19 @@ class CustomEntity : public Entity {
35
35
bool test_two_args_;
36
36
bool test_three_args_;
37
37
bool test_four_args_;
38
-
38
+ bool test_one_arg_ret_;
39
+ bool test_two_args_ret_;
40
+
39
41
virtual const std::string &getClassName () const { return CLASS_NAME; }
40
42
explicit CustomEntity (const std::string &n) : Entity(n) {
41
43
test_zero_arg_ = false ;
42
44
test_one_arg_ = false ;
43
45
test_two_args_ = false ;
44
46
test_three_args_ = false ;
45
47
test_four_args_ = false ;
46
-
48
+ test_one_arg_ret_ = false ;
49
+ test_two_args_ret_ = false ;
50
+
47
51
addCommand (" 0_arg" , makeCommandVoid0 (*this , &CustomEntity::zero_arg,
48
52
docCommandVoid0 (" zero arg" )));
49
53
@@ -73,6 +77,12 @@ class CustomEntity : public Entity {
73
77
*this , &CustomEntity::two_args_ret,
74
78
docCommandVoid2 (" two args" , " int" ," int" )));
75
79
80
+
81
+ addCommand (" cmd_verbose" ,
82
+ makeCommandVerbose (
83
+ *this ,&CustomEntity::cmd_verbose,
84
+ docCommandVerbose (" Display some information" )));
85
+
76
86
// / Generating an exception by adding a command which already exist
77
87
bool res = false ;
78
88
std::string e_1_arg (" 1_arg" );
@@ -100,11 +110,15 @@ class CustomEntity : public Entity {
100
110
test_four_args_ = true ;
101
111
}
102
112
103
- int one_arg_ret (const int &) { test_one_arg_ = true ; return 2 ;}
113
+ int one_arg_ret (const int &) { test_one_arg_ret_ = true ; return 2 ;}
104
114
105
115
std::string two_args_ret (const int &, const int &)
106
- { test_two_args_ = true ; return std::string (" return" );}
116
+ { test_two_args_ret_ = true ; return std::string (" return" );}
107
117
118
+ void cmd_verbose (std::ostream &oss)
119
+ { std::string as (" print verbose" );
120
+ oss << as;
121
+ }
108
122
};
109
123
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN (CustomEntity, " CustomEntity" );
110
124
} // namespace dynamicgraph
@@ -152,6 +166,29 @@ BOOST_AUTO_TEST_CASE(command_test) {
152
166
BOOST_CHECK (entity.test_three_args_ );
153
167
BOOST_CHECK (entity.test_four_args_ );
154
168
169
+ // With return type.
170
+ vec_fname.clear ();
171
+ vec_fname.push_back (std::string (" 1_arg_r" ));
172
+ vec_fname.push_back (std::string (" 2_args_r" ));
173
+ values.clear ();
174
+
175
+ for (unsigned int i = 0 ; i < 2 ; i++) {
176
+ it_map = aCommandMap.find (vec_fname[i]);
177
+ if (it_map == aCommandMap.end ())
178
+ {
179
+ BOOST_CHECK (false );
180
+ exit (-1 );
181
+ }
182
+ values.push_back (aValue);
183
+ it_map->second ->setParameterValues (values);
184
+ Value aValue =it_map->second ->execute ();
185
+ it_map->second ->owner ();
186
+ it_map->second ->getDocstring ();
187
+ }
188
+
189
+ BOOST_CHECK (entity.test_one_arg_ret_ );
190
+ BOOST_CHECK (entity.test_two_args_ret_ );
191
+
155
192
std::vector<Value> values_two;
156
193
values_two.push_back (aValue);
157
194
// / Wrong number of arguments
0 commit comments