soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SIpcParamHelper.hpp
1#pragma once
2
3#define FUNID(id) \
4 enum \
5 { \
6 FUN_ID = id \
7 }; \
8 UINT GetID() \
9 { \
10 return FUN_ID; \
11 }
12
13#define FUN_BEGIN \
14 bool HandleFun(UINT uMsg, SNS::SParamStream &ps) \
15 { \
16 bool bHandled = false;
17
18#define FUN_HANDLER(x, fun) \
19 if (!bHandled && uMsg == x::FUN_ID) \
20 { \
21 x param; \
22 GetIpcHandle()->FromStream4Input(&param, ps.GetBuffer()); \
23 DWORD dwPos = ps.GetBuffer()->Tell(); \
24 fun(param); \
25 ps.GetBuffer()->Seek(SNS::IShareBuffer::seek_set, dwPos); \
26 GetIpcHandle()->ToStream4Output(&param, ps.GetBuffer()); \
27 bHandled = true; \
28 }
29
30#define FUN_END \
31 return bHandled; \
32 }
33
34#define CHAIN_MSG_MAP_2_IPC(ipc) \
35 if (ipc) \
36 { \
37 BOOL bHandled = FALSE; \
38 lResult = (ipc)->OnMessage((ULONG_PTR)hWnd, uMsg, wParam, lParam, bHandled); \
39 if (bHandled) \
40 { \
41 return true; \
42 } \
43 }
44
45/////////////////////////////////////////////////////////////////////
46template <typename P1>
47void toParamStream(SNS::SParamStream &ps, P1 &p1)
48{
49 ps << p1;
50}
51template <typename P1>
52void fromParamStream(SNS::SParamStream &ps, P1 &p1)
53{
54 ps >> p1;
55}
56
57#define PARAMS1(type, p1) \
58 void ToStream4##type(SNS::SParamStream &ps) \
59 { \
60 toParamStream(ps, p1); \
61 } \
62 void FromStream4##type(SNS::SParamStream &ps) \
63 { \
64 fromParamStream(ps, p1); \
65 }
66
67/////////////////////////////////////////////////////////////
68template <typename P1, typename P2>
69void toParamStream(SNS::SParamStream &ps, P1 &p1, P2 &p2)
70{
71 ps << p1 << p2;
72}
73template <typename P1, typename P2>
74void fromParamStream(SNS::SParamStream &ps, P1 &p1, P2 &p2)
75{
76 ps >> p1 >> p2;
77}
78
79#define PARAMS2(type, p1, p2) \
80 void ToStream4##type(SNS::SParamStream &ps) \
81 { \
82 toParamStream(ps, p1, p2); \
83 } \
84 void FromStream4##type(SNS::SParamStream &ps) \
85 { \
86 fromParamStream(ps, p1, p2); \
87 }
88
89////////////////////////////////////////////////////////////////////
90template <typename P1, typename P2, typename P3>
91void toParamStream(SNS::SParamStream &ps, P1 &p1, P2 &p2, P3 &p3)
92{
93 ps << p1 << p2 << p3;
94}
95template <typename P1, typename P2, typename P3>
96void fromParamStream(SNS::SParamStream &ps, P1 &p1, P2 &p2, P3 &p3)
97{
98 ps >> p1 >> p2 >> p3;
99}
100
101#define PARAMS3(type, p1, p2, p3) \
102 void ToStream4##type(SNS::SParamStream &ps) \
103 { \
104 toParamStream(ps, p1, p2, p3); \
105 } \
106 void FromStream4##type(SNS::SParamStream &ps) \
107 { \
108 fromParamStream(ps, p1, p2, p3); \
109 }
110
111///////////////////////////////////////////////////////////////////
112template <typename P1, typename P2, typename P3, typename P4>
113void toParamStream(SNS::SParamStream &ps, P1 &p1, P2 &p2, P3 &p3, P4 &p4)
114{
115 ps << p1 << p2 << p3 << p4;
116}
117template <typename P1, typename P2, typename P3, typename P4>
118void fromParamStream(SNS::SParamStream &ps, P1 &p1, P2 &p2, P3 &p3, P4 &p4)
119{
120 ps >> p1 >> p2 >> p3 >> p4;
121}
122
123#define PARAMS4(type, p1, p2, p3, p4) \
124 void ToStream4##type(SNS::SParamStream &ps) \
125 { \
126 toParamStream(ps, p1, p2, p3, p4); \
127 } \
128 void FromStream4##type(SNS::SParamStream &ps) \
129 { \
130 fromParamStream(ps, p1, p2, p3, p4); \
131 }
132
133/////////////////////////////////////////////////////////////////////////
134template <typename P1, typename P2, typename P3, typename P4, typename P5>
135void toParamStream(SNS::SParamStream &ps, P1 &p1, P2 &p2, P3 &p3, P4 &p4, P5 &p5)
136{
137 ps << p1 << p2 << p3 << p4 << p5;
138}
139template <typename P1, typename P2, typename P3, typename P4, typename P5>
140void fromParamStream(SNS::SParamStream &ps, P1 &p1, P2 &p2, P3 &p3, P4 &p4, P5 &p5)
141{
142 ps >> p1 >> p2 >> p3 >> p4 >> p5;
143}
144
145#define PARAMS5(type, p1, p2, p3, p4, p5) \
146 void ToStream4##type(SNS::SParamStream &ps) \
147 { \
148 toParamStream(ps, p1, p2, p3, p4, p5); \
149 } \
150 void FromStream4##type(SNS::SParamStream &ps) \
151 { \
152 fromParamStream(ps, p1, p2, p3, p4, p5); \
153 }