virtual void onRead(VelocityBuffer & data){ VelocityBuffer * vb = new VelocityBuffer(); vb->setData(data); bfrMutex.wait(); velBfr.push(vb); bfrMutex.post(); }
VelocityBuffer * getVelocities(){ VelocityBuffer * res = NULL; bfrMutex.wait(); if (velBfr.size() > 0){ res = velBfr.front(); velBfr.pop(); } bfrMutex.post(); return res; }
virtual bool apply(yarp::os::Bottle& cmd, yarp::os::Bottle& reply, yarp::os::Bottle& event, yarp::os::Contact& remote) { bool ok = false; mutex.wait(); printf(" + %s\n", cmd.toString().c_str()); reply.clear(); ConstString tag = cmd.get(0).asString(); if (tag=="register") { ok = cmdRegister(cmd,reply,remote); } else if (tag=="unregister") { ok = cmdUnregister(cmd,reply,remote); } else if (tag=="query") { ok = cmdQuery(cmd,reply,remote); } else if (tag=="list") { ok = cmdList(cmd,reply,remote); } else { reply.addString("old"); reply.addString("I have no idea what you are talking about"); } mutex.post(); return ok; }