⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eventmap_8cpp-source.html

📁 美国COPLEY驱动器,程序开发工具之一.
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<a name="l00125"></a>00125    m.<a class="code" href="classEventMap.html#a3">Remove</a>( <span class="keyword">this</span> );<a name="l00126"></a>00126    semPtr = 0;<a name="l00127"></a>00127    <span class="keywordflow">return</span> err;<a name="l00128"></a>00128 }<a name="l00129"></a>00129 <a name="l00130"></a>00130 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00131"></a>00131 <span class="comment">/**</span><a name="l00132"></a>00132 <span class="comment">Setup event chaining.  Each time the event is updated, it will either set</span><a name="l00133"></a>00133 <span class="comment">or clear the bits specified by mask in the referenced EventMap object.</span><a name="l00134"></a>00134 <span class="comment">The bits will be set if the update causes the event to be true, and cleared</span><a name="l00135"></a>00135 <span class="comment">otherwise.</span><a name="l00136"></a>00136 <span class="comment"></span><a name="l00137"></a>00137 <span class="comment">@param map  The map to chain.</span><a name="l00138"></a>00138 <span class="comment">@param mask The bit(s) to set/clear in the chained map based on the state </span><a name="l00139"></a>00139 <span class="comment">            of this event.</span><a name="l00140"></a>00140 <span class="comment">*/</span><a name="l00141"></a>00141 <span class="comment">/***************************************************************************/</span><a name="l00142"></a><a class="code" href="classEvent.html#a3">00142</a> <span class="keywordtype">void</span> <a class="code" href="classEvent.html#a3">Event::setChain</a>( <span class="keyword">class</span> <a class="code" href="classEventMap.html">EventMap</a> &amp;map, <a class="code" href="CML__Utils_8h.html#a10">uint32</a> mask )<a name="l00143"></a>00143 {<a name="l00144"></a>00144    chainMap = &amp;map;<a name="l00145"></a>00145    chainMask = mask;<a name="l00146"></a>00146 }<a name="l00147"></a>00147 <a name="l00148"></a>00148 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00149"></a>00149 <span class="comment">/**</span><a name="l00150"></a>00150 <span class="comment">Remove any pointer to a chained event map.  This undoes any chaining that was</span><a name="l00151"></a>00151 <span class="comment">setup using the Event::setChain method.</span><a name="l00152"></a>00152 <span class="comment">*/</span><a name="l00153"></a>00153 <span class="comment">/***************************************************************************/</span><a name="l00154"></a><a class="code" href="classEvent.html#a4">00154</a> <span class="keywordtype">void</span> <a class="code" href="classEvent.html#a4">Event::delChain</a>( <span class="keywordtype">void</span> )<a name="l00155"></a>00155 {<a name="l00156"></a>00156    chainMap = 0;<a name="l00157"></a>00157 }<a name="l00158"></a>00158 <a name="l00159"></a>00159 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00160"></a>00160 <span class="comment">/**</span><a name="l00161"></a>00161 <span class="comment">Event map destructor.  Removes any attached events</span><a name="l00162"></a>00162 <span class="comment">Note that it is an error to destroy an EventMap if it is currently pointed</span><a name="l00163"></a>00163 <span class="comment">to by any events using 'setChain'.  Make sure to remove any such chaining</span><a name="l00164"></a>00164 <span class="comment">before the event map is destroyed.</span><a name="l00165"></a>00165 <span class="comment">*/</span><a name="l00166"></a>00166 <span class="comment">/***************************************************************************/</span><a name="l00167"></a><a class="code" href="classEventMap.html#a1">00167</a> <a class="code" href="classEventMap.html#a1">EventMap::~EventMap</a>( <span class="keywordtype">void</span> )<a name="l00168"></a>00168 {<a name="l00169"></a>00169    <span class="keywordflow">while</span>( list ) <a class="code" href="classEventMap.html#a3">Remove</a>( list );<a name="l00170"></a>00170 }<a name="l00171"></a>00171 <a name="l00172"></a>00172 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00173"></a>00173 <span class="comment">/**</span><a name="l00174"></a>00174 <span class="comment">Add the passed event to the list of events pending on this map.</span><a name="l00175"></a>00175 <span class="comment">If the event is already mapped to a map (this one or another)</span><a name="l00176"></a>00176 <span class="comment">then this function will return &amp;EventError::AlreadyOwned.</span><a name="l00177"></a>00177 <span class="comment"></span><a name="l00178"></a>00178 <span class="comment">@param e Points to the event to add</span><a name="l00179"></a>00179 <span class="comment">@return A pointer to an error object on failure, or NULL on success.</span><a name="l00180"></a>00180 <span class="comment">*/</span><a name="l00181"></a>00181 <span class="comment">/***************************************************************************/</span><a name="l00182"></a><a class="code" href="classEventMap.html#a2">00182</a> <span class="keyword">const</span> <a class="code" href="classError.html">Error</a> *<a class="code" href="classEventMap.html#a2">EventMap::Add</a>( <a class="code" href="classEvent.html">Event</a> *e )<a name="l00183"></a>00183 {<a name="l00184"></a>00184    <span class="comment">// Make sure the event is available</span><a name="l00185"></a>00185    <span class="keywordflow">if</span>( e-&gt;<a class="code" href="classEvent.html#r0">map</a> ) <a name="l00186"></a>00186       <span class="keywordflow">return</span> &amp;<a class="code" href="classEventError.html#s0">EventError::AlreadyOwned</a>;<a name="l00187"></a>00187 <a name="l00188"></a>00188    <span class="comment">// Add it to my list</span><a name="l00189"></a>00189    e-&gt;<a class="code" href="classEvent.html#r0">map</a> = <span class="keyword">this</span>;<a name="l00190"></a>00190    e-&gt;<a class="code" href="classEvent.html#r1">prev</a> = 0;<a name="l00191"></a>00191 <a name="l00192"></a>00192    mutex.<a class="code" href="classMutex.html#a2">Lock</a>();<a name="l00193"></a>00193    e-&gt;<a class="code" href="classEvent.html#r2">next</a> = list;<a name="l00194"></a>00194    <span class="keywordflow">if</span>( list ) list-&gt;<a class="code" href="classEvent.html#r1">prev</a> = e;<a name="l00195"></a>00195    list = e;<a name="l00196"></a>00196 <a name="l00197"></a>00197    <span class="comment">// Update the event </span><a name="l00198"></a>00198    e-&gt;<a class="code" href="classEvent.html#d0">update</a>( mask );<a name="l00199"></a>00199    mutex.<a class="code" href="classMutex.html#a3">Unlock</a>();<a name="l00200"></a>00200 <a name="l00201"></a>00201    <span class="keywordflow">return</span> 0;<a name="l00202"></a>00202 }<a name="l00203"></a>00203 <a name="l00204"></a>00204 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00205"></a>00205 <span class="comment">/**</span><a name="l00206"></a>00206 <span class="comment">Remove the passed event from the list of events pending on this map.  If</span><a name="l00207"></a>00207 <span class="comment">the event is not presently attached to this map, then this function will</span><a name="l00208"></a>00208 <span class="comment">return &amp;EventError::NotMapped.</span><a name="l00209"></a>00209 <span class="comment"></span><a name="l00210"></a>00210 <span class="comment">@param e Points to the event to remove</span><a name="l00211"></a>00211 <span class="comment">@return A pointer to an error object on failure, or NULL on success.</span><a name="l00212"></a>00212 <span class="comment">*/</span><a name="l00213"></a>00213 <span class="comment">/***************************************************************************/</span><a name="l00214"></a><a class="code" href="classEventMap.html#a3">00214</a> <span class="keyword">const</span> <a class="code" href="classError.html">Error</a> *<a class="code" href="classEventMap.html#a3">EventMap::Remove</a>( <a class="code" href="classEvent.html">Event</a> *e )<a name="l00215"></a>00215 {<a name="l00216"></a>00216    <span class="comment">// Make sure I own it</span><a name="l00217"></a>00217    <span class="keywordflow">if</span>( e-&gt;<a class="code" href="classEvent.html#r0">map</a> != this ) <a name="l00218"></a>00218       <span class="keywordflow">return</span> &amp;<a class="code" href="classEventError.html#s1">EventError::NotMapped</a>;<a name="l00219"></a>00219 <a name="l00220"></a>00220    mutex.<a class="code" href="classMutex.html#a2">Lock</a>();<a name="l00221"></a>00221 <a name="l00222"></a>00222    <span class="comment">// Remove it from my list</span><a name="l00223"></a>00223    <span class="keywordflow">if</span>( e-&gt;<a class="code" href="classEvent.html#r2">next</a> ) e-&gt;<a class="code" href="classEvent.html#r2">next</a>-&gt;<a class="code" href="classEvent.html#r1">prev</a> = e-&gt;<a class="code" href="classEvent.html#r1">prev</a>;<a name="l00224"></a>00224    <span class="keywordflow">if</span>( e-&gt;<a class="code" href="classEvent.html#r1">prev</a> ) e-&gt;<a class="code" href="classEvent.html#r1">prev</a>-&gt;<a class="code" href="classEvent.html#r2">next</a> = e-&gt;<a class="code" href="classEvent.html#r2">next</a>;<a name="l00225"></a>00225    <span class="keywordflow">else</span> list = e-&gt;<a class="code" href="classEvent.html#r2">next</a>;<a name="l00226"></a>00226    mutex.<a class="code" href="classMutex.html#a3">Unlock</a>();<a name="l00227"></a>00227 <a name="l00228"></a>00228    e-&gt;<a class="code" href="classEvent.html#r0">map</a> = 0;<a name="l00229"></a>00229    <span class="keywordflow">return</span> 0;<a name="l00230"></a>00230 }<a name="l00231"></a>00231 <a name="l00232"></a>00232 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00233"></a>00233 <span class="comment">/**</span><a name="l00234"></a>00234 <span class="comment">Update the mask associated with this event map.</span><a name="l00235"></a>00235 <span class="comment">It is assumed that the mutex is already locked when this function is called.</span><a name="l00236"></a>00236 <span class="comment">*/</span><a name="l00237"></a>00237 <span class="comment">/***************************************************************************/</span><a name="l00238"></a>00238 <span class="keywordtype">void</span> EventMap::update( <a class="code" href="CML__Utils_8h.html#a10">uint32</a> newMask )<a name="l00239"></a>00239 {<a name="l00240"></a>00240    mask = newMask;<a name="l00241"></a>00241 <a name="l00242"></a>00242    <span class="keywordflow">for</span>( <a class="code" href="classEvent.html">Event</a> *e = list; e; e = e-&gt;<a class="code" href="classEvent.html#r2">next</a> )<a name="l00243"></a>00243       e-&gt;<a class="code" href="classEvent.html#d0">update</a>( mask );<a name="l00244"></a>00244 }<a name="l00245"></a>00245 </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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -