00001 #ifndef HWSERVER_H
00002 #define HWSERVER_H
00003
00004 #include <string>
00005 #include <vector>
00006 #include <map>
00007 #include <pthread.h>
00008
00009 using namespace std;
00010
00011 class hwApp;
00012 class MD5;
00013 class wsRequest;
00014
00015 class hwServer
00016 {
00017 public:
00018
00019 static hwServer* getInstance();
00020
00021 void run(unsigned int port);
00022
00023 void process(wsRequest* request);
00024
00025 void setAppFactory(hwApp* app)
00026 {
00027 myAppFactory = app;
00028 }
00029
00030 hwApp* getThreadApp(pthread_t thread);
00031
00032 void threadDone(pthread_t thread);
00033
00034 private:
00035
00036 hwServer();
00037
00038 static void* process(void* data);
00039 string createKey(const string& s);
00040
00041 hwApp* myAppFactory;
00042 map<string,hwApp*> myAppMap;
00043 map<unsigned long,hwApp*> myThreadMap;
00044 static hwServer* myInstance;
00045 pthread_mutex_t myMutex1;
00046 pthread_mutex_t myMutex2;
00047 MD5* myMD5;
00048 };
00049
00050 #endif
00051