27 #include <yarp/os/Value.h>
62 void fail(
const char *msg) {
64 why = std::string(
"could not set ") + msg;
74 if (!(ok0&&ok1&&ok2)) {
132 if (
get(
offset).isNull() && strcmp ( msg,
"collide" ) == 0 )
162 x.setting = getBool?
true:
false;
180 int kind =
state.command.get(2).asVocab32();
182 bool static_obj =
false;
185 case yarp::os::createVocab32(
's',
'b',
'o',
'x'):
187 case yarp::os::createVocab32(
'b',
'o',
'x'):
188 state.op.kind =
"box";
190 state.needIndex =
true;
192 case yarp::os::createVocab32(
's',
'c',
'y',
'l'):
194 case yarp::os::createVocab32(
'c',
'y',
'l'):
195 state.op.kind =
"cyl";
197 state.needIndex =
true;
199 case yarp::os::createVocab32(
's',
's',
'p',
'h'):
201 case yarp::os::createVocab32(
's',
'p',
'h'):
202 state.op.kind =
"sph";
204 state.needIndex =
true;
206 case yarp::os::createVocab32(
's',
'm',
'o',
'd'):
208 case yarp::os::createVocab32(
'm',
'o',
'd',
'e'):
209 state.op.kind =
"model";
211 state.needIndex =
true;
213 case yarp::os::createVocab32(
'l',
'h',
'a',
'n'):
220 case yarp::os::createVocab32(
'r',
'h',
'a',
'n'):
227 case yarp::os::createVocab32(
'm',
'd',
'i',
'r'):
230 case yarp::os::createVocab32(
't',
'a',
'b',
'l'):
231 case yarp::os::createVocab32(
'c',
'u',
'b',
'e'):
232 case yarp::os::createVocab32(
'b',
'a',
'l',
'l'):
233 case yarp::os::createVocab32(
's',
'c',
'r',
'e'):
234 case yarp::os::createVocab32(
'a',
'l',
'l'):
238 state.why =
"unrecognized object type";
244 std::string grabber =
state.get(
state.offset).asString();
246 if (grabber==
"left") {
248 }
else if (grabber==
"right") {
251 state.failed =
"true";
252 state.why =
"hand not recognized";
258 if (
state.needIndex) {
259 if (!
state.op.index.valid) {
270 return !
state.failed;
282 return !
state.failed;
287 if (
state.op.parameter.get()) {
288 if (
state.op.kind.get() ==
"mdir") {
289 state.consume(
state.op.modelName,
"model path");
291 state.result.setFail(
"parameter not recognized");
300 return !
state.failed;
305 std::string name =
state.op.kind.name;
306 if (!(name==
"box"||name==
"cyl"||name==
"sph"||name==
"model")) {
307 state.result.setFail(
"cannot create object of requested type");
313 if (name ==
"cyl" || name ==
"sph") {
319 if (name ==
"model") {
320 state.consume(
state.op.modelName,
"model name");
321 state.consume(
state.op.modelTexture,
"model texture");
325 if (name !=
"model") {
334 return !
state.failed;
344 return !
state.failed;
355 return !
state.failed;
363 return !
state.failed;
371 return !
state.failed;
375 yarp::os::Bottle& reply) {
409 state.why =
"unrecognized command";
415 if (reply.size()==0) {
416 reply.addVocab32(yarp::os::createVocab32(
'f',
'a',
'i',
'l'));
419 reply.addString(
state.why.c_str());
421 if (result.
msg!=
"") {
423 reply.addString(result.
msg.c_str());
428 if (reply.size()==0) {
438 reply.addFloat64(result.
color.
get(0));
439 reply.addFloat64(result.
color.
get(1));
440 reply.addFloat64(result.
color.
get(2));
444 reply.addString(result.
path.
get().c_str());
446 reply.addVocab32(yarp::os::createVocab32(
'o',
'k'));
bool consume(WorldOpScalar &x, const char *msg)
bool consume(WorldOpIndex &x, const char *msg)
bool consume(WorldOpFlag &x, const char *msg)
const yarp::os::Bottle & command
void fail(const char *msg)
const yarp::os::Value & get(int offset)
bool consume(WorldOpTriplet &x, const char *msg)
ManagerState(const yarp::os::Bottle &command, WorldOp &op, WorldResult &result, WorldManager &manager)
bool consume(WorldOpName &x, const char *msg)
virtual bool respond(const yarp::os::Bottle &command, yarp::os::Bottle &reply)
double get(int offset) const
void setFail(const char *msg)
bool doGet(ManagerState &state)
bool doGrab(ManagerState &state)
bool doColor(ManagerState &state)
void consumeKind(ManagerState &state)
bool doRotate(ManagerState &state)
bool doMake(ManagerState &state)
bool doNumber(ManagerState &state)
bool doDelete(ManagerState &state)
void consumeHand(ManagerState &state)
void consumeObject(ManagerState &state)
bool doSet(ManagerState &state)