27 namespace learningmachine {
31 if(port.open(name.c_str()) !=
true) {
32 std::string msg(
"could not register port ");
34 throw std::runtime_error(msg);
45 std::string full_fname;
61 if(full_fname ==
"") {
62 throw std::runtime_error(
"Could not find file '" + fname +
"' in the standard search paths.");
70 yarp::os::Bottle*
cmd = (yarp::os::Bottle*) 0;
71 yarp::os::Bottle reply;
80 if(*
cmd != yarp::os::Bottle::getNullBottle()) {
81 if(
out != (yarp::os::Bottle*) 0) {
82 out->addString(
cmd->toString().c_str());
84 std::cout <<
cmd->toString().c_str() << std::endl;
86 this->safeRespond(*
cmd, reply);
88 if(
out != (yarp::os::Bottle*) 0) {
89 out->addString(reply.toString().c_str());
91 if(reply.get(0).toString() ==
"help") {
92 for(
int i=0; i<reply.size(); i++) {
93 std::cout << reply.get(i).toString().c_str() << std::endl;
96 std::cout << reply.toString().c_str() << std::endl;
102 cmd = (yarp::os::Bottle*) 0;
Template class that supports reading lines of a file to object instances using a fromString(char* lin...
virtual bool hasNext()
Checks whether there are more items left in the stream.
virtual void open(std::istream &s)
Opens the given stream for reading.
T * getNext()
Returns a pointer to the next item in the file.
virtual bool close()
Close the module.
virtual void unregisterAllPorts()=0
Unregisters all ports used by this module.
std::string findFile(std::string fname)
Finds the full path to a specified filename using the ResourceFinder.
void registerPort(yarp::os::Contactable &port, std::string name)
Register a port with a given name.
virtual yarp::os::ResourceFinder & getResourceFinder()
Returns a reference to the cached ResourceFinder.
virtual void loadCommandFile(std::string fname, yarp::os::Bottle *out=(yarp::os::Bottle *) 0)
Reads bottles from a file and sends these one by one to the respond method.
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.