42 switch(
cmd.get(0).asVocab32()) {
43 case yarp::os::createVocab32(
'h',
'e',
'l',
'p'):
44 reply.add(yarp::os::Value::makeVocab32(
"help"));
46 reply.addString(
"Event Manager configuration options");
47 reply.addString(
" help Displays this message");
48 reply.addString(
" list Print a list of available event listeners");
49 reply.addString(
" add type [type2 ...] Adds one or more event listeners");
50 reply.addString(
" remove [all|idx] Removes event listener at an index or all");
51 reply.addString(
" set [all|idx] Configures a listener");
52 reply.addString(
" stats Prints information");
56 case yarp::os::createVocab32(
'l',
'i',
's',
't'):
58 reply.add(yarp::os::Value::makeVocab32(
"help"));
60 for(
unsigned int i = 0; i < keys.size(); i++) {
61 reply.addString((std::string(
" ") + keys[i]).c_str());
67 case yarp::os::createVocab32(
'a',
'd',
'd'):
69 yarp::os::Bottle list =
cmd.tail();
70 for(
int i = 0; i < list.size(); i++) {
75 reply.addString(
"Successfully added listener(s)");
80 case yarp::os::createVocab32(
'r',
'e',
'm',
'o'):
81 case yarp::os::createVocab32(
'd',
'e',
'l'):
83 if(
cmd.get(1).isInt32() &&
cmd.get(1).asInt32() >= 1 &&
cmd.get(1).asInt32() <= this->dispatcher->countListeners()) {
85 reply.addString(
"Successfully removed listener.");
87 }
else if(
cmd.get(1).asString() ==
"all") {
88 this->dispatcher->
clear();
89 reply.addString(
"Successfully removed all listeners.");
92 throw std::runtime_error(
"Illegal index!");
97 case yarp::os::createVocab32(
's',
'e',
't'):
99 yarp::os::Bottle property;
100 property.addList() =
cmd.tail().tail();
102 std::string replymsg =
"Setting configuration option ";
103 if(
cmd.get(1).isInt32() &&
cmd.get(1).asInt32() >= 1 &&
104 cmd.get(1).asInt32() <= this->dispatcher->countListeners()) {
107 replymsg +=
ok ?
"succeeded" :
108 "failed; please check key and value type.";
109 reply.addString(replymsg.c_str());
111 }
else if(
cmd.get(1).asString() ==
"all") {
117 replymsg +=
ok ?
"succeeded" :
118 "failed; please check key and value type.";
121 reply.addString(replymsg.c_str());
124 throw std::runtime_error(
"Illegal index!");
129 case yarp::os::createVocab32(
'i',
'n',
'f',
'o'):
130 case yarp::os::createVocab32(
's',
't',
'a',
't'):
132 reply.add(yarp::os::Value::makeVocab32(
"help"));
133 std::ostringstream buffer;
134 buffer <<
"Event Manager Information (" << this->dispatcher->
countListeners() <<
" listeners)";
135 reply.addString(buffer.str().c_str());
138 buffer <<
" [" << (i + 1) <<
"] " << this->dispatcher->
getAt(i).
getInfo();
139 reply.addString(buffer.str().c_str());
150 }
catch(
const std::exception&
e) {
151 std::string msg = std::string(
"Error: ") +
e.what();
152 reply.addString(msg.c_str());