front_idill/extern/fajran-npTuioClient/TuioClient/TuioClient.h
author bastiena
Thu, 12 Apr 2012 13:09:46 +0200
changeset 27 6c08d4d7219e
parent 21 e4e5f02787a1
child 28 9ccef81f02ab
permissions -rw-r--r--
Middleware : GPL License added. Front Processing : GPL License added. Front IDILL : extern altered to send TUIO cursors from Middleware to Front. implemented as a plugin.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     1
/*
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     2
	TUIO C++ Library - part of the reacTIVision project
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     3
	http://reactivision.sourceforge.net/
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     4
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     5
	Copyright (c) 2005-2008 Martin Kaltenbrunner <mkalten@iua.upf.edu>
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     6
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     7
    This program is free software; you can redistribute it and/or modify
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     8
    it under the terms of the GNU General Public License as published by
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     9
    the Free Software Foundation; either version 2 of the License, or
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    10
    (at your option) any later version.
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    11
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    12
    This program is distributed in the hope that it will be useful,
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    15
    GNU General Public License for more details.
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    16
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    17
    You should have received a copy of the GNU General Public License
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    18
    along with this program; if not, write to the Free Software
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    19
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    20
*/
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    22
#ifndef INCLUDED_TUIOCLIENT_H
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    23
#define INCLUDED_TUIOCLIENT_H
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    24
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    25
#ifndef WIN32
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    26
#include <pthread.h>
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    27
#include <sys/time.h>
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    28
#else
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    29
#include <windows.h>
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    30
#endif
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    31
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    32
#include <iostream>
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    33
#include <list>
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    34
#include <algorithm>
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    35
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    36
#include "osc/OscReceivedElements.h"
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    37
#include "osc/OscPrintReceivedElements.h"
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    38
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    39
#include "ip/UdpSocket.h"
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    40
#include "ip/PacketListener.h"
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    41
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    42
#include "TuioListener.h"
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    43
#include "TuioObject.h"
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    44
#include "TuioCursor.h"
27
6c08d4d7219e Middleware :
bastiena
parents: 21
diff changeset
    45
#include "TuioString.h"
21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    46
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    47
using namespace osc;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    48
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    49
class TuioClient : public PacketListener { 
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    50
	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    51
	public:
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    52
		TuioClient();
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    53
		TuioClient(int p);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    54
		~TuioClient();
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    55
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    56
		void start(bool lk=false);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    57
		void stop();
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    58
		bool isRunning() { return running; }
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    59
			
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    60
		
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    61
		TuioObject* getTuioObject(long s_id);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    62
		TuioCursor* getTuioCursor(long s_id);
27
6c08d4d7219e Middleware :
bastiena
parents: 21
diff changeset
    63
		/*
6c08d4d7219e Middleware :
bastiena
parents: 21
diff changeset
    64
		* Ajout� par alexandre.bastien@iri.centrepompidou.fr
6c08d4d7219e Middleware :
bastiena
parents: 21
diff changeset
    65
		*/
6c08d4d7219e Middleware :
bastiena
parents: 21
diff changeset
    66
		TuioString* getTuioString(long s_id);
21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    67
		std::list<TuioObject*> getTuioObjects();
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    68
		std::list<TuioCursor*> getTuioCursors();
27
6c08d4d7219e Middleware :
bastiena
parents: 21
diff changeset
    69
		/*
6c08d4d7219e Middleware :
bastiena
parents: 21
diff changeset
    70
		* Ajout� par alexandre.bastien@iri.centrepompidou.fr
6c08d4d7219e Middleware :
bastiena
parents: 21
diff changeset
    71
		*/
6c08d4d7219e Middleware :
bastiena
parents: 21
diff changeset
    72
		std::list<TuioString*> getTuioStrings();
21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    73
		
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    74
		void addTuioListener(TuioListener *listener);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    75
		void removeTuioListener(TuioListener *listener);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    76
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    77
		void ProcessPacket( const char *data, int size, const IpEndpointName& remoteEndpoint );
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    78
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    79
		UdpListeningReceiveSocket *socket;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    80
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    81
	protected:
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    82
		void ProcessBundle( const ReceivedBundle& b, const IpEndpointName& remoteEndpoint);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    83
		void ProcessMessage( const ReceivedMessage& m, const IpEndpointName& remoteEndpoint);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    84
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    85
	private:
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    86
		std::list<TuioListener*> listenerList;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    87
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    88
		std::list<TuioObject*> objectList;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    89
		std::list<long> aliveObjectList, objectBuffer;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    90
		std::list<TuioCursor*> cursorList;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    91
		std::list<long> aliveCursorList, cursorBuffer;
27
6c08d4d7219e Middleware :
bastiena
parents: 21
diff changeset
    92
		/*
6c08d4d7219e Middleware :
bastiena
parents: 21
diff changeset
    93
		* Ajout� par alexandre.bastien@iri.centrepompidou.fr
6c08d4d7219e Middleware :
bastiena
parents: 21
diff changeset
    94
		*/
6c08d4d7219e Middleware :
bastiena
parents: 21
diff changeset
    95
		std::list<TuioString*> stringList;
6c08d4d7219e Middleware :
bastiena
parents: 21
diff changeset
    96
		std::list<long> aliveStringList, stringBuffer;
21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    97
	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    98
		int32 currentFrame, lastFrame;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    99
	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   100
		long startTime;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   101
		long lastTime;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   102
		long getCurrentTime();
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   103
	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   104
		std::list<TuioCursor*> freeCursorList, freeCursorBuffer;
27
6c08d4d7219e Middleware :
bastiena
parents: 21
diff changeset
   105
		/*
6c08d4d7219e Middleware :
bastiena
parents: 21
diff changeset
   106
		* Ajout� par alexandre.bastien@iri.centrepompidou.fr
6c08d4d7219e Middleware :
bastiena
parents: 21
diff changeset
   107
		*/
6c08d4d7219e Middleware :
bastiena
parents: 21
diff changeset
   108
		std::list<TuioString*> freeStringList, freeStringBuffer;
6c08d4d7219e Middleware :
bastiena
parents: 21
diff changeset
   109
		int maxFingerID, maxStringID;
21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   110
	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   111
		#ifndef WIN32
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   112
		pthread_t thread;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   113
		#else
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   114
   		HANDLE thread;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   115
		#endif	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   116
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   117
		bool locked;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   118
		bool running;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   119
};
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   120
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   121
#endif /* INCLUDED_TUIOCLIENT_H */