source: anotherchoice/tags/jsp-1.4.4-full-UTF8/windev/devicemanager/devicemanagerCP.h@ 26

Last change on this file since 26 was 26, checked in by ykominami, 10 years ago

initial

File size: 8.9 KB
Line 
1/*
2 * TOPPERS/JSP Kernel
3 * Toyohashi Open Platform for Embedded Real-Time Systems/
4 * Just Standard Profile Kernel
5 *
6 * Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
7 * Toyohashi Univ. of Technology, JAPAN
8 *
9 * 上記著作権者
10は,以下の (1)〜(4) の条件か,Free Software Foundation
11 * によってå…
12¬è¡¨ã•ã‚Œã¦ã„ã‚‹ GNU General Public License の Version 2 に記
13 * 述されている条件を満たす場合に限り,本ソフトウェア(本ソフトウェア
14 * を改変したものを含む.以下同じ)を使用・複製・改変・再é…
15å¸ƒï¼ˆä»¥ä¸‹ï¼Œ
16 * 利用と呼ぶ)することを無償で許諾する.
17 * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
18 * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
19 * スコード中に含まれていること.
20 * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
21 * 用できる形で再é…
22å¸ƒã™ã‚‹å ´åˆã«ã¯ï¼Œå†é…
23å¸ƒã«ä¼´ã†ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆï¼ˆåˆ©ç”¨
24 * 者
25マニュアルなど)に,上記の著作権表示,この利用条件および下記
26 * の無保証規定を掲載すること.
27 * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
28 * 用できない形で再é…
29å¸ƒã™ã‚‹å ´åˆã«ã¯ï¼Œæ¬¡ã®ã„ずれかの条件を満たすこ
30 * と.
31 * (a) 再é…
32å¸ƒã«ä¼´ã†ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆï¼ˆåˆ©ç”¨è€…
33マニュアルなど)に,上記の著
34 * 作権表示,この利用条件および下記の無保証規定を掲載すること.
35 * (b) 再é…
36å¸ƒã®å½¢æ…
37‹ã‚’,別に定める方法によって,TOPPERSプロジェクトに
38 * 報告すること.
39 * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
40 * 害からも,上記著作権者
41およびTOPPERSプロジェクトをå…
42è²¬ã™ã‚‹ã“と.
43 *
44 * 本ソフトウェアは,無保証で提供されているものである.上記著作権者
45お
46 * よびTOPPERSプロジェクトは,本ソフトウェアに関して,その適用可能性も
47 * 含めて,いかなる保証も行わない.また,本ソフトウェアの利用により直
48 * 接的または間接的に生じたいかなる損害に関しても,その責任を負わない.
49 *
50 * @(#) $Id: devicemanagerCP.h,v 1.5 2003/12/24 07:40:42 takayuki Exp $
51 */
52
53#ifndef _ATLDEVICEMANAGERCP_H_
54#define _ATLDEVICEMANAGERCP_H_
55
56template <class T>
57class CProxy_IKernelEvents : public IConnectionPointImpl<T, &IID__IKernelEvents, CComDynamicUnkArray>
58{
59 //Warning this class may be recreated by the wizard.
60public:
61 HRESULT Fire_OnInterruptRequest(ULONG inhno)
62 {
63 HRESULT ret;
64 T* pT = static_cast<T*>(this);
65 int nConnectionIndex;
66 int nConnections = m_vec.GetSize();
67
68 for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
69 {
70 pT->Lock();
71 CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
72 pT->Unlock();
73 _IKernelEvents* p_IKernelEvents = reinterpret_cast<_IKernelEvents*>(sp.p);
74 if (p_IKernelEvents != NULL)
75 ret = p_IKernelEvents->OnInterruptRequest(inhno);
76 } return ret;
77
78 }
79};
80
81
82
83
84template <class T>
85class CProxy_IDeviceEvents : public IConnectionPointImpl<T, &IID__IDeviceEvents, CComDynamicUnkArray>
86{
87 //Warning this class may be recreated by the wizard.
88public:
89 HRESULT Fire_OnRead(LONG address, LONG sz, unsigned char * data)
90 {
91 HRESULT ret;
92 T* pT = static_cast<T*>(this);
93 int nConnectionIndex;
94 int nConnections = m_vec.GetSize();
95
96 for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
97 {
98 pT->Lock();
99 CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
100 pT->Unlock();
101 _IDeviceEvents* p_IDeviceEvents = reinterpret_cast<_IDeviceEvents*>(sp.p);
102 if (p_IDeviceEvents != NULL)
103 ret = p_IDeviceEvents->OnRead(address, sz, data);
104 } return ret;
105
106 }
107 HRESULT Fire_OnWrite(LONG address, LONG sz, unsigned char * data)
108 {
109 HRESULT ret;
110 T* pT = static_cast<T*>(this);
111 int nConnectionIndex;
112 int nConnections = m_vec.GetSize();
113
114 for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
115 {
116 pT->Lock();
117 CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
118 pT->Unlock();
119 _IDeviceEvents* p_IDeviceEvents = reinterpret_cast<_IDeviceEvents*>(sp.p);
120 if (p_IDeviceEvents != NULL)
121 ret = p_IDeviceEvents->OnWrite(address, sz,data);
122 } return ret;
123
124 }
125 HRESULT Fire_OnKernelStart()
126 {
127 HRESULT ret;
128 T* pT = static_cast<T*>(this);
129 int nConnectionIndex;
130 int nConnections = m_vec.GetSize();
131
132 for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
133 {
134 pT->Lock();
135 CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
136 pT->Unlock();
137 _IDeviceEvents* p_IDeviceEvents = reinterpret_cast<_IDeviceEvents*>(sp.p);
138 if (p_IDeviceEvents != NULL)
139 ret = p_IDeviceEvents->OnKernelStart();
140 } return ret;
141
142 }
143 HRESULT Fire_OnKernelExit()
144 {
145 HRESULT ret;
146 T* pT = static_cast<T*>(this);
147 int nConnectionIndex;
148 int nConnections = m_vec.GetSize();
149
150 for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
151 {
152 pT->Lock();
153 CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
154 pT->Unlock();
155 _IDeviceEvents* p_IDeviceEvents = reinterpret_cast<_IDeviceEvents*>(sp.p);
156 if (p_IDeviceEvents != NULL)
157 ret = p_IDeviceEvents->OnKernelExit();
158 } return ret;
159
160 }
161};
162
163
164
165
166template <class T>
167class CProxy_IInformationEvents : public IConnectionPointImpl<T, &IID__IInformationEvents, CComDynamicUnkArray>
168{
169 //Warning this class may be recreated by the wizard.
170public:
171 HRESULT Fire_OnDeviceChanged(SHORT reason, LONG devid, LONG extra = 0)
172 {
173 HRESULT ret;
174 T* pT = static_cast<T*>(this);
175 int nConnectionIndex;
176 int nConnections = m_vec.GetSize();
177
178 for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
179 {
180 pT->Lock();
181 CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
182 pT->Unlock();
183 _IInformationEvents* p_IInformationEvents = reinterpret_cast<_IInformationEvents*>(sp.p);
184 if (p_IInformationEvents != NULL)
185 ret = p_IInformationEvents->OnDeviceChanged(reason, devid, extra);
186 } return ret;
187
188 }
189 HRESULT Fire_OnKernelChanged(SHORT reason)
190 {
191 HRESULT ret;
192 T* pT = static_cast<T*>(this);
193 int nConnectionIndex;
194 int nConnections = m_vec.GetSize();
195
196 for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
197 {
198 pT->Lock();
199 CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
200 pT->Unlock();
201 _IInformationEvents* p_IInformationEvents = reinterpret_cast<_IInformationEvents*>(sp.p);
202 if (p_IInformationEvents != NULL)
203 ret = p_IInformationEvents->OnKernelChanged(reason);
204 } return ret;
205
206 }
207};
208
209
210template <class T>
211class CProxy_IKernelLogEvents : public IConnectionPointImpl<T, &IID__IKernelLogEvents, CComDynamicUnkArray>
212{
213public:
214 bool onKernelStart_Performed;
215
216 CProxy_IKernelLogEvents(void) : onKernelStart_Performed(false) {};
217
218 //Warning this class may be recreated by the wizard.
219public:
220 HRESULT Fire_OnKernelStart()
221 {
222 HRESULT ret;
223 T* pT = static_cast<T*>(this);
224 int nConnectionIndex;
225 int nConnections = m_vec.GetSize();
226
227 for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
228 {
229 pT->Lock();
230 CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
231 pT->Unlock();
232 _IKernelLogEvents* p_IKernelLogEvents = reinterpret_cast<_IKernelLogEvents*>(sp.p);
233 if (p_IKernelLogEvents != NULL)
234 {
235 if((ret = p_IKernelLogEvents->OnKernelStart()) == S_OK)
236 onKernelStart_Performed = true;
237 }
238 }
239 return ret;
240 }
241
242 HRESULT Fire_OnKernelExit()
243 {
244 HRESULT ret;
245 T* pT = static_cast<T*>(this);
246 int nConnectionIndex;
247 int nConnections = m_vec.GetSize();
248
249 for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
250 {
251 pT->Lock();
252 CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
253 pT->Unlock();
254 _IKernelLogEvents* p_IKernelLogEvents = reinterpret_cast<_IKernelLogEvents*>(sp.p);
255 if (p_IKernelLogEvents != NULL)
256 ret = p_IKernelLogEvents->OnKernelExit();
257 }
258 onKernelStart_Performed = false;
259 return ret;
260 }
261
262 HRESULT Fire_OnLogEvent(LONG sz, unsigned char * data)
263 {
264 HRESULT ret;
265 T* pT = static_cast<T*>(this);
266 int nConnectionIndex;
267 int nConnections = m_vec.GetSize();
268
269 for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
270 {
271 pT->Lock();
272 CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
273 pT->Unlock();
274 _IKernelLogEvents* p_IKernelLogEvents = reinterpret_cast<_IKernelLogEvents*>(sp.p);
275 if (p_IKernelLogEvents != NULL)
276 {
277 if(!onKernelStart_Performed)
278 p_IKernelLogEvents->OnKernelStart();
279 ret = p_IKernelLogEvents->OnLogEvent(sz, data);
280 }
281 }
282 if(nConnectionIndex != 0)
283 onKernelStart_Performed = true;
284 return ret;
285 }
286};
287#endif
Note: See TracBrowser for help on using the repository browser.