yarpobject.h
1 /********************************************************************************
2  * WorldSim -- library for robot simulations *
3  * Copyright (C) 2008-2011 Gianluca Massera <emmegian@yahoo.it> *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the Free Software *
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
18  ********************************************************************************/
19 
20 #ifdef FARSA_USE_YARP_AND_ICUB
21 
22 #ifndef YARPOBJECT_H
23 #define YARPOBJECT_H
24 
25 #include "worldsimconfig.h"
26 #include "world.h"
27 #include <QMap>
28 #include <QString>
29 
30 // All this stuff is to get rid of annoying warnings...
31 #ifdef __GNUC__
32 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5)
33 #pragma GCC diagnostic push
34 #pragma GCC diagnostic ignored "-Wunused-parameter"
35 #else
36 #pragma GCC diagnostic ignored "-Wunused-parameter"
37 #endif
38 #endif
39  #include "yarp/dev/ControlBoardInterfaces.h"
40  #include "yarp/dev/FrameGrabberInterfaces.h"
41  #include "yarp/dev/Drivers.h"
42  #include "yarp/dev/PolyDriver.h"
43 #ifdef __GNUC__
44 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5)
45 #pragma GCC diagnostic pop
46 #else
47 #pragma GCC diagnostic warning "-Wunused-parameter"
48 #endif
49 #endif
50 
51 namespace farsa {
52 
63 class FARSA_WSIM_API YarpObject : public WObject {
64  Q_OBJECT
65 public:
68  YarpObject( World* world, QString name, const wMatrix& tm = wMatrix::identity() );
70  virtual ~YarpObject();
72  yarp::dev::PolyDriver* polydriver( QString name ) {
73  if ( controls.contains(name) ) {
74  return controls[name];
75  }
76  return NULL;
77  };
78 protected:
83  void registerServerControlBoard( yarp::dev::DeviceDriver* device, QString devicename );
85  void removeServerControlBoard( QString devicename );
90  void registerServerFrameGrabber( yarp::dev::DeviceDriver* device, QString devicename );
91 private:
93  QMap<QString, yarp::dev::PolyDriver*> controls;
94 };
95 
96 } // end namespace farsa
97 
98 #endif
99 
100 #endif // FARSA_USE_YARP_AND_ICUB