WvStreams
include/wvwinstreamclone.h
1/* -*- Mode: C++ -*- */
2#pragma once
3#include "wvstreamclone.h"
4#include <map>
5#include <vector>
6#define WIN32_LEAN_AND_MEAN
7//#define NOMINMAX
8#include <windows.h>
9
10#define WM_SELECT (WM_USER)
11#define WM_DONESELECT (WM_USER+1)
12
13class WvWinStreamClone :
14 public WvStreamClone
15{
16public:
17 WvWinStreamClone(WvStream *_cloned);
19 static DWORD Initialize();
20
21private:
22 // types
23 typedef std::map<SOCKET, long> SocketEventsMap;
24 typedef std::map<HWND, WvWinStreamClone *> WndStreamMap;
25 typedef std::vector<HWND> WndVector;
26
27 // class members
28 static ATOM s_aClass;
29 static WndVector s_wndpool;
30 static WndStreamMap s_wndmap;
31 const static UINT_PTR TIMER_ID = 12345;
32 static LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
33
34 // instance members
35 SelectInfo m_si;
36 int m_msec_timeout;
37 HWND m_hWnd;
38 bool m_pending_callback;
39 bool m_select_in_progress;
40
41 void pre_poll();
42 void post_poll();
43 void select_set(SocketEventsMap &sockmap, fd_set *set, long event );
44 void select_callback(SOCKET socket, int event, int error);
45 HWND alloc_wnd();
46 void free_wnd(HWND w);
47
48public:
49 void setclone(IWvStream *newclone);
50};
51
52
WvStreamClone simply forwards all requests to the "cloned" stream.
Unified support for streams, that is, sequences of bytes that may or may not be ready for read/write ...
void setclone(IWvStream *newclone)
WvStreamClone takes ownership of the given stream; it will WVRELEASE() the stream when you setclone()...