cml__eventmap_8h-source.html
来自「美国COPLEY驱动器,程序开发工具之一.」· HTML 代码 · 共 379 行 · 第 1/3 页
HTML
379 行
<a name="l00246"></a>00246 <span class="comment"> Check the event against the passed mask. If none of the selected bits are set</span><a name="l00247"></a>00247 <span class="comment"> in the mask, then the event is satisfied.</span><a name="l00248"></a>00248 <span class="comment"> @param mask The mask to test against</span><a name="l00249"></a>00249 <span class="comment"> @return true if none bits of interest are set in the mask.</span><a name="l00250"></a>00250 <span class="comment"> */</span><a name="l00251"></a>00251 <span class="comment">/***************************************************************************/</span><a name="l00252"></a><a class="code" href="classEventNone.html#a1">00252</a> <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classEventNone.html#a1">isTrue</a>( <a class="code" href="CML__Utils_8h.html#a10">uint32</a> mask )<a name="l00253"></a>00253 {<a name="l00254"></a>00254 <span class="keywordflow">return</span> (mask & <a class="code" href="classEvent.html#p0">value</a>) == 0;<a name="l00255"></a>00255 }<a name="l00256"></a>00256 };<a name="l00257"></a>00257 <a name="l00258"></a>00258 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00259"></a>00259 <span class="comment">/**</span><a name="l00260"></a>00260 <span class="comment">An event map is a mechanism that allows one or more threads to wait on some</span><a name="l00261"></a>00261 <span class="comment">pre-defined event, or group of events.</span><a name="l00262"></a>00262 <span class="comment"></span><a name="l00263"></a>00263 <span class="comment">For a particular event map, there are one or more events that are grouped </span><a name="l00264"></a>00264 <span class="comment">with that map. Any number of threads may pend on the state of these events.</span><a name="l00265"></a>00265 <span class="comment">*/</span><a name="l00266"></a>00266 <span class="comment">/***************************************************************************/</span><a name="l00267"></a><a class="code" href="classEventMap.html">00267</a> <span class="keyword">class </span><a class="code" href="classEventMap.html">EventMap</a><a name="l00268"></a>00268 {<a name="l00269"></a>00269 <span class="keyword">public</span>:<a name="l00270"></a><a class="code" href="classEventMap.html#a0">00270</a> <a class="code" href="classEventMap.html#a0">EventMap</a>()<a name="l00271"></a>00271 {<a name="l00272"></a>00272 mask = 0;<a name="l00273"></a>00273 list = 0;<a name="l00274"></a>00274 }<a name="l00275"></a>00275 <a name="l00276"></a>00276 <a class="code" href="classEventMap.html#a1">~EventMap</a>( <span class="keywordtype">void</span> );<a name="l00277"></a>00277 <span class="keyword">const</span> <a class="code" href="classError.html">Error</a> *<a class="code" href="classEventMap.html#a2">Add</a>( <a class="code" href="classEvent.html">Event</a> *e );<a name="l00278"></a>00278 <span class="keyword">const</span> <a class="code" href="classError.html">Error</a> *<a class="code" href="classEventMap.html#a3">Remove</a>( <a class="code" href="classEvent.html">Event</a> *e );<a name="l00279"></a>00279 <a name="l00280"></a>00280 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00281"></a>00281 <span class="comment"> /**</span><a name="l00282"></a>00282 <span class="comment"> Get the current value of the mask for this event map.</span><a name="l00283"></a>00283 <span class="comment"> @return The 32-bit mask value.</span><a name="l00284"></a>00284 <span class="comment"> */</span><a name="l00285"></a>00285 <span class="comment">/***************************************************************************/</span><a name="l00286"></a><a class="code" href="classEventMap.html#a4">00286</a> <a class="code" href="CML__Utils_8h.html#a10">uint32</a> <a class="code" href="classEventMap.html#a4">getMask</a>( <span class="keywordtype">void</span> ){ <span class="keywordflow">return</span> mask; }<a name="l00287"></a>00287 <a name="l00288"></a>00288 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00289"></a>00289 <span class="comment"> /**</span><a name="l00290"></a>00290 <span class="comment"> Update the event mask. The new mask value will equal the passed parameter.</span><a name="l00291"></a>00291 <span class="comment"> @param mask The new mask value.</span><a name="l00292"></a>00292 <span class="comment"> */</span><a name="l00293"></a>00293 <span class="comment">/***************************************************************************/</span><a name="l00294"></a><a class="code" href="classEventMap.html#a5">00294</a> <span class="keywordtype">void</span> <a class="code" href="classEventMap.html#a5">setMask</a>( <a class="code" href="CML__Utils_8h.html#a10">uint32</a> mask )<a name="l00295"></a>00295 {<a name="l00296"></a>00296 mutex.<a class="code" href="classMutex.html#a2">Lock</a>();<a name="l00297"></a>00297 update( mask );<a name="l00298"></a>00298 mutex.<a class="code" href="classMutex.html#a3">Unlock</a>();<a name="l00299"></a>00299 }<a name="l00300"></a>00300 <a name="l00301"></a>00301 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00302"></a>00302 <span class="comment"> /**</span><a name="l00303"></a>00303 <span class="comment"> Set bits in the event mask. </span><a name="l00304"></a>00304 <span class="comment"> @param bits Any bit set in this parameter will be set in the event mask.</span><a name="l00305"></a>00305 <span class="comment"> */</span><a name="l00306"></a>00306 <span class="comment">/***************************************************************************/</span><a name="l00307"></a><a class="code" href="classEventMap.html#a6">00307</a> <span class="keywordtype">void</span> <a class="code" href="classEventMap.html#a6">setBits</a>( <a class="code" href="CML__Utils_8h.html#a10">uint32</a> bits )<a name="l00308"></a>00308 {<a name="l00309"></a>00309 mutex.<a class="code" href="classMutex.html#a2">Lock</a>();<a name="l00310"></a>00310 update( mask | bits );<a name="l00311"></a>00311 mutex.<a class="code" href="classMutex.html#a3">Unlock</a>();<a name="l00312"></a>00312 }<a name="l00313"></a>00313 <a name="l00314"></a>00314 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00315"></a>00315 <span class="comment"> /**</span><a name="l00316"></a>00316 <span class="comment"> Clear bits in the event mask. </span><a name="l00317"></a>00317 <span class="comment"> @param bits Any bit set in this parameter will be cleared in the event mask.</span><a name="l00318"></a>00318 <span class="comment"> */</span><a name="l00319"></a>00319 <span class="comment">/***************************************************************************/</span><a name="l00320"></a><a class="code" href="classEventMap.html#a7">00320</a> <span class="keywordtype">void</span> <a class="code" href="classEventMap.html#a7">clrBits</a>( <a class="code" href="CML__Utils_8h.html#a10">uint32</a> bits )<a name="l00321"></a>00321 {<a name="l00322"></a>00322 mutex.<a class="code" href="classMutex.html#a2">Lock</a>();<a name="l00323"></a>00323 update( mask & ~bits );<a name="l00324"></a>00324 mutex.<a class="code" href="classMutex.html#a3">Unlock</a>();<a name="l00325"></a>00325 }<a name="l00326"></a>00326 <a name="l00327"></a>00327 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00328"></a>00328 <span class="comment"> /**</span><a name="l00329"></a>00329 <span class="comment"> Change the value of specified bits in the mask for this event. The bits to</span><a name="l00330"></a>00330 <span class="comment"> change are identified by one parameter, and the new value for these bits</span><a name="l00331"></a>00331 <span class="comment"> is specified in the other parameter.</span><a name="l00332"></a>00332 <span class="comment"> @param bits Identifies which bits in the mask to change. Only those bits</span><a name="l00333"></a>00333 <span class="comment"> which are set in this parameter will be effected in the event mask.</span><a name="l00334"></a>00334 <span class="comment"> @param value The new value for the bits identified in the first parameter.</span><a name="l00335"></a>00335 <span class="comment"> */</span><a name="l00336"></a>00336 <span class="comment">/***************************************************************************/</span><a name="l00337"></a><a class="code" href="classEventMap.html#a8">00337</a> <span class="keywordtype">void</span> <a class="code" href="classEventMap.html#a8">changeBits</a>( <a class="code" href="CML__Utils_8h.html#a10">uint32</a> bits, <a class="code" href="CML__Utils_8h.html#a10">uint32</a> value )<a name="l00338"></a>00338 {<a name="l00339"></a>00339 value &= bits;<a name="l00340"></a>00340 <a name="l00341"></a>00341 mutex.<a class="code" href="classMutex.html#a2">Lock</a>();<a name="l00342"></a>00342 update( (mask & ~bits) | value );<a name="l00343"></a>00343 mutex.<a class="code" href="classMutex.html#a3">Unlock</a>();<a name="l00344"></a>00344 }<a name="l00345"></a>00345 <a name="l00346"></a>00346 <span class="keyword">private</span>:<a name="l00347"></a>00347 <a class="code" href="classMutex.html">Mutex</a> mutex;<a name="l00348"></a>00348 <a class="code" href="CML__Utils_8h.html#a10">uint32</a> mask;<a name="l00349"></a>00349 <a class="code" href="classEvent.html">Event</a> *list;<a name="l00350"></a>00350 <a name="l00351"></a>00351 <span class="keywordtype">void</span> update( <a class="code" href="CML__Utils_8h.html#a10">uint32</a> newMask );<a name="l00352"></a>00352 <a name="l00353"></a><a class="code" href="classEventMap.html#n0">00353</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classEvent.html">Event</a>;<a name="l00354"></a>00354 };<a name="l00355"></a>00355 <a name="l00356"></a>00356 <a class="code" href="CML__Settings_8h.html#a12">CML_NAMESPACE_END</a>()<a name="l00357"></a>00357 <a name="l00358"></a>00358 #endif<a name="l00359"></a>00359 </pre></div><hr><address style="align: right;"><small>Copley Motion Library, Copyright (c) 2002-2003<a href="http://www.copleycontrols.com"><img src="CCC_logo.gif" alt="Copley Controls Corp." align="middle" border=0 ></a></small></address></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?