worldsim/include/yarpobject.h

00001 /********************************************************************************
00002  *  WorldSim -- library for robot simulations                                   *
00003  *  Copyright (C) 2008-2011 Gianluca Massera <emmegian@yahoo.it>                *
00004  *                                                                              *
00005  *  This program is free software; you can redistribute it and/or modify        *
00006  *  it under the terms of the GNU General Public License as published by        *
00007  *  the Free Software Foundation; either version 2 of the License, or           *
00008  *  (at your option) any later version.                                         *
00009  *                                                                              *
00010  *  This program is distributed in the hope that it will be useful,             *
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of              *
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
00013  *  GNU General Public License for more details.                                *
00014  *                                                                              *
00015  *  You should have received a copy of the GNU General Public License           *
00016  *  along with this program; if not, write to the Free Software                 *
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA  *
00018  ********************************************************************************/
00019 
00020 #ifdef FARSA_USE_YARP_AND_ICUB
00021 
00022 #ifndef YARPOBJECT_H
00023 #define YARPOBJECT_H
00024 
00025 #include "worldsimconfig.h"
00026 #include "world.h"
00027 #include <QMap>
00028 #include <QString>
00029 
00030 // All this stuff is to get rid of annoying warnings...
00031 #ifdef __GNUC__
00032 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5)
00033 #pragma GCC diagnostic push
00034 #pragma GCC diagnostic ignored "-Wunused-parameter"
00035 #else
00036 #pragma GCC diagnostic ignored "-Wunused-parameter"
00037 #endif
00038 #endif
00039     #include "yarp/dev/ControlBoardInterfaces.h"
00040     #include "yarp/dev/FrameGrabberInterfaces.h"
00041     #include "yarp/dev/Drivers.h"
00042     #include "yarp/dev/PolyDriver.h"
00043 #ifdef __GNUC__
00044 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5)
00045 #pragma GCC diagnostic pop
00046 #else
00047 #pragma GCC diagnostic warning "-Wunused-parameter"
00048 #endif
00049 #endif
00050 
00051 namespace farsa {
00052 
00063 class FARSA_WSIM_API YarpObject : public WObject {
00064     Q_OBJECT
00065 public:
00068     YarpObject( World* world, QString name, const wMatrix& tm = wMatrix::identity() );
00070     virtual ~YarpObject();
00072     yarp::dev::PolyDriver* polydriver( QString name ) {
00073         if ( controls.contains(name) ) {
00074             return controls[name];
00075         }
00076         return NULL;
00077     };
00078 protected:
00083     void registerServerControlBoard( yarp::dev::DeviceDriver* device, QString devicename );
00085     void removeServerControlBoard( QString devicename );
00090     void registerServerFrameGrabber( yarp::dev::DeviceDriver* device, QString devicename );
00091 private:
00093     QMap<QString, yarp::dev::PolyDriver*> controls;
00094 };
00095 
00096 } // end namespace farsa
00097 
00098 #endif
00099 
00100 #endif // FARSA_USE_YARP_AND_ICUB