Player
Frontpage
Contents
User
Installation
Quick start
Supported devices
Tutorials
Utilities
Client libraries
FAQ
Help
Developer
Architecture
libplayercore
interfaces
libplayerdrivers
drivers
libplayercommon
libplayerutils
libplayersd
libplayertcp
libplayerxdr
TODO
Online
Homepage
Download
Project
Bugs
Help
libplayercore
device.h
1
/*
2
* Player - One Hell of a Robot Server
3
* Copyright (C) 2000
4
* Brian Gerkey, Kasper Stoy, Richard Vaughan, & Andrew Howard
5
*
6
*
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
10
* (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
*
21
*/
22
/********************************************************************
23
*
24
* This library is free software; you can redistribute it and/or
25
* modify it under the terms of the GNU Lesser General Public
26
* License as published by the Free Software Foundation; either
27
* version 2.1 of the License, or (at your option) any later version.
28
*
29
* This library is distributed in the hope that it will be useful,
30
* but WITHOUT ANY WARRANTY; without even the implied warranty of
31
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
32
* Lesser General Public License for more details.
33
*
34
* You should have received a copy of the GNU Lesser General Public
35
* License along with this library; if not, write to the Free Software
36
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
37
*
38
********************************************************************/
39
40
/*
41
* $Id: device.h 8462 2009-12-16 00:27:55Z gbiggs $
42
*
43
* A device is a driver/interface pair.
44
*/
45
46
#ifndef _DEVICE_H
47
#define _DEVICE_H
48
49
#if defined (WIN32)
50
#if defined (PLAYER_STATIC)
51
#define PLAYERCORE_EXPORT
52
#elif defined (playercore_EXPORTS)
53
#define PLAYERCORE_EXPORT __declspec (dllexport)
54
#else
55
#define PLAYERCORE_EXPORT __declspec (dllimport)
56
#endif
57
#else
58
#define PLAYERCORE_EXPORT
59
#endif
60
61
#include <libplayerinterface/player.h>
62
#include <libplayercore/message.h>
63
64
#define LOCALHOST_ADDR 16777343
65
66
// Forward declarations
67
class
Driver
;
68
74
class
PLAYERCORE_EXPORT
Device
75
{
76
public
:
81
Device
(
player_devaddr_t
addr,
Driver
*driver);
82
84
~
Device
();
85
89
int
Subscribe(
QueuePointer
&sub_queue);
90
94
int
Unsubscribe(
QueuePointer
&sub_queue);
95
109
void
PutMsg(
QueuePointer
&resp_queue,
110
uint8_t type,
111
uint8_t subtype,
112
void
* src,
113
size_t
deprecated,
114
double
* timestamp);
115
125
void
PutMsg(
QueuePointer
&resp_queue,
126
player_msghdr_t
* hdr,
127
void
* src,
128
bool
copy=
true
);
129
152
Message
* Request(
QueuePointer
&resp_queue,
153
uint8_t type,
154
uint8_t subtype,
155
void
* src,
156
size_t
deprecated,
157
double
* timestamp,
158
bool
threaded =
true
);
159
187
Message
* TimedRequest(
QueuePointer
&resp_queue,
188
uint8_t type,
189
uint8_t subtype,
190
void
* src,
191
double
timeout = 0,
192
double
* timestamp = NULL,
193
bool
threaded =
true
);
194
195
201
static
bool
MatchDeviceAddress(
player_devaddr_t
addr1,
202
player_devaddr_t
addr2)
203
{
204
// On some machines, looking up "localhost" gives you
205
// "127.0.0.1", which packs into a 32-bit int as 16777343. On other
206
// machines, it gives you "0.0.0.0", which packs as 0. In order to
207
// be able to do things like play back logfiles made on any machine,
208
// we'll treat these two addresses as identical.
209
return
(((addr1.
host
== addr2.
host
) ||
210
((addr1.
host
== 0) && (addr2.
host
== LOCALHOST_ADDR)) ||
211
((addr1.
host
== LOCALHOST_ADDR) && (addr2.
host
== 0))) &&
212
(addr1.
robot
== addr2.
robot
) &&
213
(addr1.
interf
== addr2.
interf
) &&
214
(addr1.
index
== addr2.
index
));
215
}
216
218
Device
*
next
;
219
221
player_devaddr_t
addr
;
222
224
char
drivername[
PLAYER_MAX_DRIVER_STRING_LEN
];
225
226
228
QueuePointer
InQueue
;
229
231
QueuePointer
*
queues
;
232
234
size_t
len_queues
;
235
237
Driver
*
driver
;
238
239
private
:
242
pthread_mutex_t
accessMutex
;
244
void
Lock(
void
);
246
void
Unlock(
void
);
247
248
249
};
250
251
#endif
Last updated 12 September 2005 21:38:45