tagging release
[dasher.git] / trunk / Src / DasherCore / SocketInput.h
blob3fccc1a1ddc078d0f54df9e2d4e77d16f3a85d5f
1 // SocketInput.h
2 //
3 // (C) Copyright Seb Wills 2005
4 //
5 // Linux-specific subclass of SocketInputBase: provides network socket control of Dasher cursor
7 #ifndef __SocketInput_h__
8 #define __SocketInput_h__
10 #include "./SocketInputBase.h"
11 #include "./DasherComponent.h"
12 #include "./EventHandler.h"
14 #include <iostream>
15 #include <pthread.h>
17 #define GCC_VERSION (__GNUC__ * 10000 \
18 + __GNUC_MINOR__ * 100 \
19 + __GNUC_PATCHLEVEL__)
23 namespace Dasher {
24 class CSocketInput;
25 #if GCC_VERSION >= 40100
26 void *ThreadLauncherStub(void *_myClass);
27 #endif
30 using namespace Dasher;
31 using namespace std;
32 /// \ingroup Input
33 /// \{
34 class Dasher::CSocketInput:public CSocketInputBase {
36 // This non-member launcher stub function is required because pthreads can't launch a non-static member method.
37 friend void *ThreadLauncherStub(void *_myClass) {
38 CSocketInput *myClass = (CSocketInput *) _myClass;
40 pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); // kill this thread immediately if another thread cancels it
41 // don't know how this interacts with recv blocking
43 myClass->ReadForever();
45 return NULL;
48 public:
50 CSocketInput(CEventHandler * pEventHandler, CSettingsStore * pSettingsStore);
51 ~CSocketInput();
53 private:
55 pthread_t readerThread;
57 bool LaunchReaderThread();
59 void CancelReaderThread();
61 // TODO: should probably override ReportErrnoError() to popup a Gtk error message
64 /// \}
65 #endif