device.h

00001 /*
00002  *  Player - One Hell of a Robot Server
00003  *  Copyright (C) 2000  
00004  *     Brian Gerkey, Kasper Stoy, Richard Vaughan, & Andrew Howard
00005  *                      
00006  *
00007  *  This program is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License as published by
00009  *  the Free Software Foundation; either version 2 of the License, or
00010  *  (at your option) any later version.
00011  *
00012  *  This program is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *  GNU General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License
00018  *  along with this program; if not, write to the Free Software
00019  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  *
00021  */
00022 
00023 /*
00024  * $Id: device.h,v 1.11 2006/02/15 06:48:38 gerkey Exp $
00025  *
00026  * A device is a driver/interface pair.
00027  */
00028 
00029 #ifndef _DEVICE_H
00030 #define _DEVICE_H
00031 
00032 #include <libplayercore/player.h>
00033 #include <libplayercore/message.h>
00034 
00035 // Forward declarations
00036 class Driver;
00037 
00043 class Device
00044 {
00045   private:
00046   public:
00047   
00052     Device(player_devaddr_t addr, Driver *driver);
00053 
00055     ~Device();
00056 
00060     int Subscribe(MessageQueue* sub_queue);
00061 
00065     int Unsubscribe(MessageQueue* sub_queue);
00066 
00080     void PutMsg(MessageQueue* resp_queue,
00081                 uint8_t type, 
00082                 uint8_t subtype,
00083                 void* src, 
00084                 size_t len,
00085                 double* timestamp);
00086 
00095     void PutMsg(MessageQueue* resp_queue,
00096                 player_msghdr_t* hdr,
00097                 void* src);
00098 
00121     Message* Request(MessageQueue* resp_queue,
00122                      uint8_t type,
00123                      uint8_t subtype,
00124                      void* src,
00125                      size_t len,
00126                      double* timestamp,
00127                      bool threaded = true);
00128 
00134     static bool MatchDeviceAddress(player_devaddr_t addr1,
00135                                    player_devaddr_t addr2)
00136     {
00137       return((addr1.host == addr2.host) &&
00138              (addr1.robot == addr2.robot) &&
00139              (addr1.interf == addr2.interf) &&
00140              (addr1.index == addr2.index));
00141     }
00142 
00144     Device* next;
00145 
00147     player_devaddr_t addr;
00148 
00150     char drivername[PLAYER_MAX_DRIVER_STRING_LEN];
00151 
00153     Driver* driver;
00154 
00156     MessageQueue** queues;
00157 
00159     size_t len_queues;
00160 };
00161 
00162 #endif

Last updated 12 September 2005 21:38:45