iCub-main
TrainEventListener.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2010 RobotCub Consortium, European Commission FP6 Project IST-004370
3  * author: Arjan Gijsberts
4  * email: arjan.gijsberts@iit.it
5  * website: www.robotcub.org
6  * Permission is granted to copy, distribute, and/or modify this program
7  * under the terms of the GNU General Public License, version 2 or any
8  * later version published by the Free Software Foundation.
9  *
10  * A copy of the license can be found at
11  * http://www.robotcub.org/icub/license/gpl.txt
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
16  * Public License for more details
17  */
18 
19 #ifndef LM_TRAINEVENTLISTENER__
20 #define LM_TRAINEVENTLISTENER__
21 
22 #include <string>
23 
24 #include <yarp/sig/Vector.h>
25 
28 
29 namespace iCub {
30 namespace learningmachine {
31 
40 protected:
41  void vectorToBottle(const yarp::sig::Vector& vec, yarp::os::Bottle& bot) {
42  for(size_t i = 0; i < vec.size(); i++) {
43  bot.addFloat64(vec[i]);
44  }
45  }
46 
47 public:
53  TrainEventListener(std::string pp = "/lm/event/train") : IPortEventListener(pp) {
54  this->setName("Train");
55  }
56 
57  /*
58  * Inherited from IEventListener.
59  */
60  void handle(TrainEvent& e);
61 
62  /*
63  * Inherited from IEventListener.
64  */
66  return new TrainEventListener(*this);
67  }
68 
69 };
70 
71 } // learningmachine
72 } // iCub
73 
74 #endif
void setName(std::string name)
Set the name of this IEventListener.
The abstract base class for EventListeners that output to a port.
void handle(TrainEvent &e)
Handling of a TrainEvent.
TrainEventListener(std::string pp="/lm/event/train")
Constructor.
TrainEventListener * clone()
Asks the event listener to return a new object of its type.
void vectorToBottle(const yarp::sig::Vector &vec, yarp::os::Bottle &bot)
A TrainEvent is raised when the machine handles a training sample.
Definition: TrainEvent.h:44
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.