10 #ifndef YARP_OS_IMPL_DISPATCHER_H
11 #define YARP_OS_IMPL_DISPATCHER_H
29 template <
class T,
class RET>
37 RET (T::*fn)(
int argc,
char* argv[]);
39 Entry(
const char* name, RET (T::*fn)(
int argc,
char* argv[])) :
51 std::map<std::string, Entry> action;
52 std::vector<std::string> names;
55 void add(
const char* name, RET (T::*fn)(
int argc,
char* argv[]))
58 action[std::string(name)] = e;
60 names.push_back(std::string(name));
63 RET
dispatch(T* owner,
const char* name,
int argc,
char* argv[])
65 std::string sname(name);
66 typename std::map<std::string, Entry>::const_iterator it = action.find(sname);
67 if (it != action.end()) {
68 return (owner->*(it->second.fn))(argc, argv);
86 #endif // YARP_OS_IMPL_DISPATCHER_H