00001
00002 #pragma once
00003 #include "wvstreamclone.h"
00004 #include <map>
00005 #include <vector>
00006 #define WIN32_LEAN_AND_MEAN
00007 #define NOMINMAX
00008 #include <windows.h>
00009
00010 #define WM_SELECT (WM_USER)
00011 #define WM_DONESELECT (WM_USER+1)
00012
00013 class WvWinStreamClone :
00014 public WvStreamClone
00015 {
00016 public:
00017 WvWinStreamClone(WvStream *_cloned);
00018 ~WvWinStreamClone();
00019 static DWORD Initialize();
00020
00021 private:
00022
00023 typedef std::map<SOCKET, long> SocketEventsMap;
00024 typedef std::map<HWND, WvWinStreamClone *> WndStreamMap;
00025 typedef std::vector<HWND> WndVector;
00026
00027
00028 static ATOM s_aClass;
00029 static WndVector s_wndpool;
00030 static WndStreamMap s_wndmap;
00031 const static UINT_PTR TIMER_ID = 12345;
00032 static LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
00033
00034
00035 SelectInfo m_si;
00036 int m_msec_timeout;
00037 HWND m_hWnd;
00038 bool m_pending_callback;
00039 bool m_select_in_progress;
00040
00041 void pre_poll();
00042 void post_poll();
00043 void select_set(SocketEventsMap &sockmap, fd_set *set, long event );
00044 void select_callback(SOCKET socket, int event, int error);
00045 HWND alloc_wnd();
00046 void free_wnd(HWND w);
00047
00048 public:
00049 void setclone(IWvStream *newclone);
00050 };
00051
00052