22 #define BOOST_TEST_MODULE debug - logger 24 #if BOOST_VERSION >= 105900 25 #include <boost/test/tools/output_test_stream.hpp> 27 #include <boost/test/output_test_stream.hpp> 29 #include <boost/test/unit_test.hpp> 31 using boost::test_tools::output_test_stream;
47 virtual const std::string &
getClassName()
const {
return CLASS_NAME; }
49 test_zero_arg_ =
false;
50 test_one_arg_ =
false;
51 test_two_args_ =
false;
52 test_three_args_ =
false;
53 test_four_args_ =
false;
54 test_one_arg_ret_ =
false;
55 test_two_args_ret_ =
false;
91 std::string e_1_arg(
"1_arg");
93 addCommand(e_1_arg, getNewStyleCommand(e_1_arg));
104 void one_arg(
const int &) { test_one_arg_ =
true; }
106 void two_args(
const int &,
const int &) { test_two_args_ =
true; }
109 test_three_args_ =
true;
112 void four_args(
const int &,
const int &,
const int &,
const int &) {
113 test_four_args_ =
true;
117 test_one_arg_ret_ =
true;
122 test_two_args_ret_ =
true;
123 return std::string(
"return");
127 std::string as(
"print verbose");
141 std::map<const std::string, Command *> aCommandMap =
144 std::map<const std::string, Command *>::iterator it_map;
146 it_map = aCommandMap.find(
"0_arg");
147 if (it_map == aCommandMap.end()) BOOST_CHECK(
false);
148 it_map->second->execute();
152 Value aValue(first_arg);
153 std::vector<std::string> vec_fname(4);
154 vec_fname[0] =
"1_arg";
155 vec_fname[1] =
"2_args";
156 vec_fname[2] =
"3_args";
157 vec_fname[3] =
"4_args";
158 std::vector<Value> values;
160 for (
unsigned int i = 0; i < 4; i++) {
161 it_map = aCommandMap.find(vec_fname[i]);
162 if (it_map == aCommandMap.end()) BOOST_CHECK(
false);
163 values.push_back(aValue);
164 it_map->second->setParameterValues(values);
165 it_map->second->execute();
166 it_map->second->owner();
167 it_map->second->getDocstring();
177 vec_fname.push_back(std::string(
"1_arg_r"));
178 vec_fname.push_back(std::string(
"2_args_r"));
181 for (
unsigned int i = 0; i < 2; i++) {
182 it_map = aCommandMap.find(vec_fname[i]);
183 if (it_map == aCommandMap.end()) {
187 values.push_back(aValue);
188 it_map->second->setParameterValues(values);
189 Value aValue = it_map->second->execute();
190 it_map->second->owner();
191 it_map->second->getDocstring();
197 std::vector<Value> values_two;
198 values_two.push_back(aValue);
201 it_map = aCommandMap.find(std::string(
"2_args"));
203 it_map->second->setParameterValues(values_two);
209 double snd_arg_db = 10.0;
210 Value aValue2(snd_arg_db);
211 values_two.push_back(aValue2);
215 it_map = aCommandMap.find(std::string(
"2_args"));
217 it_map->second->setParameterValues(values_two);
229 std::string empty(
"");
CommandVoid0< E > * makeCommandVoid0(E &entity, boost::function< void(void)> function, const std::string &docString)
This class represents an entity, i.e. a generic computational unit that provides input and output sig...
This class implements a variant design pattern to handle basic types in Command.
command::Command * getNewStyleCommand(const std::string &cmdName)
Provides the pointer towards the Command object cmdName.
CommandVoid1< E, T > * makeCommandVoid1(E &entity, boost::function< void(const T &)> function, const std::string &docString)
std::string docCommandVoid1(const std::string &doc, const std::string &type)
std::string docCommandVoid4(const std::string &doc, const std::string &type1, const std::string &type2, const std::string &type3, const std::string &type4)
static const std::string CLASS_NAME
std::string docCommandVoid0(const std::string &doc)
virtual const std::string & getClassName() const
std::string docCommandVoid3(const std::string &doc, const std::string &type1, const std::string &type2, const std::string &type3)
int getCode() const
Access to the error code.
CommandVoid3< E, T1, T2, T3 > * makeCommandVoid3(E &entity, typename CommandVoid3< E, T1, T2, T3 >::function_t function, const std::string &docString)
void three_args(const int &, const int &, const int &)
void cmd_verbose(std::ostream &oss)
void one_arg(const int &)
CustomEntity(const std::string &n)
std::string two_args_ret(const int &, const int &)
CommandVoid4< E, T1, T2, T3, T4 > * makeCommandVoid4(E &entity, typename CommandVoid4< E, T1, T2, T3, T4 >::function_t function, const std::string &docString)
int one_arg_ret(const int &)
CommandMap_t getNewStyleCommandMap()
Provides the std::map where all the commands are registered.
Abstract root class for all dynamic-graph exceptions.
CommandReturnType2< E, ReturnType, T1, T2 > * makeCommandReturnType2(E &entity, boost::function< ReturnType(const T1 &, const T2 &)> function, const std::string &docString)
void four_args(const int &, const int &, const int &, const int &)
Entity * newEntity(const std::string &classname, const std::string &objname) const
Instantiate (and allocate) an entity.
void two_args(const int &, const int &)
CommandVerbose< E > * makeCommandVerbose(E &entity, typename CommandVerbose< E >::function_t function, const std::string &docString)
static FactoryStorage * getInstance()
Get pointer to unique object of the class.
std::string docCommandVoid2(const std::string &doc, const std::string &type1, const std::string &type2)
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(CustomEntity, "CustomEntity")
CommandReturnType1< E, ReturnType, T > * makeCommandReturnType1(E &entity, boost::function< ReturnType(const T &)> function, const std::string &docString)
BOOST_AUTO_TEST_CASE(command_test)
std::string docCommandVerbose(const std::string &doc)
CommandVoid2< E, T1, T2 > * makeCommandVoid2(E &entity, boost::function< void(const T1 &, const T2 &)> function, const std::string &docString)