@@ -35,15 +35,19 @@ class CustomEntity : public Entity {
3535 bool test_two_args_;
3636 bool test_three_args_;
3737 bool test_four_args_;
38-
38+ bool test_one_arg_ret_;
39+ bool test_two_args_ret_;
40+
3941 virtual const std::string &getClassName () const { return CLASS_NAME; }
4042 explicit CustomEntity (const std::string &n) : Entity(n) {
4143 test_zero_arg_ = false ;
4244 test_one_arg_ = false ;
4345 test_two_args_ = false ;
4446 test_three_args_ = false ;
4547 test_four_args_ = false ;
46-
48+ test_one_arg_ret_ = false ;
49+ test_two_args_ret_ = false ;
50+
4751 addCommand (" 0_arg" , makeCommandVoid0 (*this , &CustomEntity::zero_arg,
4852 docCommandVoid0 (" zero arg" )));
4953
@@ -73,6 +77,12 @@ class CustomEntity : public Entity {
7377 *this , &CustomEntity::two_args_ret,
7478 docCommandVoid2 (" two args" , " int" ," int" )));
7579
80+
81+ addCommand (" cmd_verbose" ,
82+ makeCommandVerbose (
83+ *this ,&CustomEntity::cmd_verbose,
84+ docCommandVerbose (" Display some information" )));
85+
7686 // / Generating an exception by adding a command which already exist
7787 bool res = false ;
7888 std::string e_1_arg (" 1_arg" );
@@ -100,11 +110,15 @@ class CustomEntity : public Entity {
100110 test_four_args_ = true ;
101111 }
102112
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 ;}
104114
105115 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" );}
107117
118+ void cmd_verbose (std::ostream &oss)
119+ { std::string as (" print verbose" );
120+ oss << as;
121+ }
108122};
109123DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN (CustomEntity, " CustomEntity" );
110124} // namespace dynamicgraph
@@ -152,6 +166,29 @@ BOOST_AUTO_TEST_CASE(command_test) {
152166 BOOST_CHECK (entity.test_three_args_ );
153167 BOOST_CHECK (entity.test_four_args_ );
154168
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+
155192 std::vector<Value> values_two;
156193 values_two.push_back (aValue);
157194 // / Wrong number of arguments
0 commit comments