|
21
|
1 |
/* |
|
|
2 |
TUIO C++ Library - part of the reacTIVision project |
|
|
3 |
http://reactivision.sourceforge.net/ |
|
|
4 |
|
|
|
5 |
Copyright (c) 2005-2008 Martin Kaltenbrunner <mkalten@iua.upf.edu> |
|
|
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 |
#ifndef INCLUDED_TUIOCLIENT_H |
|
|
23 |
#define INCLUDED_TUIOCLIENT_H |
|
|
24 |
|
|
|
25 |
#ifndef WIN32 |
|
|
26 |
#include <pthread.h> |
|
|
27 |
#include <sys/time.h> |
|
|
28 |
#else |
|
|
29 |
#include <windows.h> |
|
|
30 |
#endif |
|
|
31 |
|
|
|
32 |
#include <iostream> |
|
|
33 |
#include <list> |
|
|
34 |
#include <algorithm> |
|
|
35 |
|
|
|
36 |
#include "osc/OscReceivedElements.h" |
|
|
37 |
#include "osc/OscPrintReceivedElements.h" |
|
|
38 |
|
|
|
39 |
#include "ip/UdpSocket.h" |
|
|
40 |
#include "ip/PacketListener.h" |
|
|
41 |
|
|
|
42 |
#include "TuioListener.h" |
|
|
43 |
#include "TuioObject.h" |
|
|
44 |
#include "TuioCursor.h" |
|
27
|
45 |
#include "TuioString.h" |
|
21
|
46 |
|
|
|
47 |
using namespace osc; |
|
|
48 |
|
|
|
49 |
class TuioClient : public PacketListener { |
|
|
50 |
|
|
|
51 |
public: |
|
|
52 |
TuioClient(); |
|
|
53 |
TuioClient(int p); |
|
|
54 |
~TuioClient(); |
|
|
55 |
|
|
|
56 |
void start(bool lk=false); |
|
|
57 |
void stop(); |
|
|
58 |
bool isRunning() { return running; } |
|
|
59 |
|
|
|
60 |
|
|
|
61 |
TuioObject* getTuioObject(long s_id); |
|
|
62 |
TuioCursor* getTuioCursor(long s_id); |
|
27
|
63 |
/* |
|
|
64 |
* Ajout� par alexandre.bastien@iri.centrepompidou.fr |
|
|
65 |
*/ |
|
|
66 |
TuioString* getTuioString(long s_id); |
|
21
|
67 |
std::list<TuioObject*> getTuioObjects(); |
|
|
68 |
std::list<TuioCursor*> getTuioCursors(); |
|
27
|
69 |
/* |
|
|
70 |
* Ajout� par alexandre.bastien@iri.centrepompidou.fr |
|
|
71 |
*/ |
|
|
72 |
std::list<TuioString*> getTuioStrings(); |
|
21
|
73 |
|
|
|
74 |
void addTuioListener(TuioListener *listener); |
|
|
75 |
void removeTuioListener(TuioListener *listener); |
|
|
76 |
|
|
|
77 |
void ProcessPacket( const char *data, int size, const IpEndpointName& remoteEndpoint ); |
|
|
78 |
|
|
|
79 |
UdpListeningReceiveSocket *socket; |
|
|
80 |
|
|
|
81 |
protected: |
|
|
82 |
void ProcessBundle( const ReceivedBundle& b, const IpEndpointName& remoteEndpoint); |
|
|
83 |
void ProcessMessage( const ReceivedMessage& m, const IpEndpointName& remoteEndpoint); |
|
|
84 |
|
|
|
85 |
private: |
|
|
86 |
std::list<TuioListener*> listenerList; |
|
|
87 |
|
|
|
88 |
std::list<TuioObject*> objectList; |
|
|
89 |
std::list<long> aliveObjectList, objectBuffer; |
|
|
90 |
std::list<TuioCursor*> cursorList; |
|
|
91 |
std::list<long> aliveCursorList, cursorBuffer; |
|
27
|
92 |
/* |
|
|
93 |
* Ajout� par alexandre.bastien@iri.centrepompidou.fr |
|
|
94 |
*/ |
|
|
95 |
std::list<TuioString*> stringList; |
|
|
96 |
std::list<long> aliveStringList, stringBuffer; |
|
21
|
97 |
|
|
|
98 |
int32 currentFrame, lastFrame; |
|
|
99 |
|
|
|
100 |
long startTime; |
|
|
101 |
long lastTime; |
|
|
102 |
long getCurrentTime(); |
|
|
103 |
|
|
|
104 |
std::list<TuioCursor*> freeCursorList, freeCursorBuffer; |
|
27
|
105 |
/* |
|
|
106 |
* Ajout� par alexandre.bastien@iri.centrepompidou.fr |
|
|
107 |
*/ |
|
|
108 |
std::list<TuioString*> freeStringList, freeStringBuffer; |
|
|
109 |
int maxFingerID, maxStringID; |
|
21
|
110 |
|
|
|
111 |
#ifndef WIN32 |
|
|
112 |
pthread_t thread; |
|
|
113 |
#else |
|
|
114 |
HANDLE thread; |
|
|
115 |
#endif |
|
|
116 |
|
|
|
117 |
bool locked; |
|
|
118 |
bool running; |
|
|
119 |
}; |
|
|
120 |
|
|
|
121 |
#endif /* INCLUDED_TUIOCLIENT_H */ |