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