This file is indexed.

/usr/share/doc/libucommon-dev/a00185_source.html is in libucommon-doc 3.2.0-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>UCommon: ucommon/access.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.3 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="examples.html"><span>Examples</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
<h1>ucommon/access.h</h1><a href="a00185.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright (C) 2006-2010 David Sugar, Tycho Softworks.</span>
<a name="l00002"></a>00002 <span class="comment">//</span>
<a name="l00003"></a>00003 <span class="comment">// This file is part of GNU uCommon C++.</span>
<a name="l00004"></a>00004 <span class="comment">//</span>
<a name="l00005"></a>00005 <span class="comment">// GNU uCommon C++ is free software: you can redistribute it and/or modify</span>
<a name="l00006"></a>00006 <span class="comment">// it under the terms of the GNU Lesser General Public License as published </span>
<a name="l00007"></a>00007 <span class="comment">// by the Free Software Foundation, either version 3 of the License, or</span>
<a name="l00008"></a>00008 <span class="comment">// (at your option) any later version.</span>
<a name="l00009"></a>00009 <span class="comment">//</span>
<a name="l00010"></a>00010 <span class="comment">// GNU uCommon C++ is distributed in the hope that it will be useful,</span>
<a name="l00011"></a>00011 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00012"></a>00012 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<a name="l00013"></a>00013 <span class="comment">// GNU Lesser General Public License for more details.</span>
<a name="l00014"></a>00014 <span class="comment">//</span>
<a name="l00015"></a>00015 <span class="comment">// You should have received a copy of the GNU Lesser General Public License</span>
<a name="l00016"></a>00016 <span class="comment">// along with GNU uCommon C++.  If not, see &lt;http://www.gnu.org/licenses/&gt;.</span>
<a name="l00017"></a>00017 
<a name="l00031"></a>00031 <span class="comment">// we do this twice because of some bizzare issue in just this file that</span>
<a name="l00032"></a>00032 <span class="comment">// otherwise breaks doxygen and lists all items outside the namespace...</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include &lt;<a class="code" href="a00201.html" title="Various miscelanous platform specific headers and defines.">ucommon/platform.h</a>&gt;</span>
<a name="l00034"></a>00034 
<a name="l00035"></a>00035 <span class="preprocessor">#ifndef _UCOMMON_ACCESS_H_</span>
<a name="l00036"></a>00036 <span class="preprocessor"></span><span class="preprocessor">#define _UCOMMON_ACCESS_H_</span>
<a name="l00037"></a>00037 <span class="preprocessor"></span>
<a name="l00038"></a>00038 <span class="preprocessor">#ifndef _UCOMMON_CONFIG_H_</span>
<a name="l00039"></a>00039 <span class="preprocessor"></span><span class="preprocessor">#include &lt;<a class="code" href="a00201.html" title="Various miscelanous platform specific headers and defines.">ucommon/platform.h</a>&gt;</span>
<a name="l00040"></a>00040 <span class="preprocessor">#endif</span>
<a name="l00041"></a>00041 <span class="preprocessor"></span>
<a name="l00042"></a>00042 NAMESPACE_UCOMMON
<a name="l00043"></a>00043 
<a name="l00050"></a><a class="code" href="a00052.html">00050</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00052.html" title="An exclusive locking protocol interface base.">Exclusive</a>
<a name="l00051"></a>00051 {
<a name="l00052"></a>00052 <span class="keyword">protected</span>:
<a name="l00053"></a>00053     <span class="keyword">virtual</span> ~<a class="code" href="a00052.html" title="An exclusive locking protocol interface base.">Exclusive</a>();
<a name="l00054"></a>00054 
<a name="l00055"></a>00055 <span class="keyword">public</span>:
<a name="l00059"></a>00059     <span class="keyword">virtual</span> <span class="keywordtype">void</span> Exlock(<span class="keywordtype">void</span>) = 0;
<a name="l00060"></a>00060 
<a name="l00064"></a>00064     <span class="keyword">virtual</span> <span class="keywordtype">void</span> Unlock(<span class="keywordtype">void</span>) = 0;
<a name="l00065"></a>00065 
<a name="l00069"></a><a class="code" href="a00052.html#a1b7dc1c6fd6ff4d8c65d867c6b7c55d2">00069</a>     <span class="keyword">inline</span> <span class="keywordtype">void</span> Lock(<span class="keywordtype">void</span>)
<a name="l00070"></a>00070         {Exlock();};
<a name="l00071"></a>00071 };
<a name="l00072"></a>00072 
<a name="l00079"></a><a class="code" href="a00135.html">00079</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00135.html" title="An exclusive locking protocol interface base.">Shared</a>
<a name="l00080"></a>00080 {
<a name="l00081"></a>00081 <span class="keyword">protected</span>:
<a name="l00082"></a>00082     <span class="keyword">virtual</span> ~<a class="code" href="a00135.html" title="An exclusive locking protocol interface base.">Shared</a>();
<a name="l00083"></a>00083 
<a name="l00084"></a>00084 <span class="keyword">public</span>:
<a name="l00088"></a>00088     <span class="keyword">virtual</span> <span class="keywordtype">void</span> Shlock(<span class="keywordtype">void</span>) = 0;
<a name="l00089"></a>00089 
<a name="l00093"></a>00093     <span class="keyword">virtual</span> <span class="keywordtype">void</span> Unlock(<span class="keywordtype">void</span>) = 0;
<a name="l00094"></a>00094 
<a name="l00101"></a>00101     <span class="keyword">virtual</span> <span class="keywordtype">void</span> Share(<span class="keywordtype">void</span>);
<a name="l00102"></a>00102 
<a name="l00110"></a>00110     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00052.html" title="An exclusive locking protocol interface base.">Exclusive</a>(<span class="keywordtype">void</span>);
<a name="l00111"></a>00111 
<a name="l00115"></a><a class="code" href="a00135.html#a66bf8c2543d85811c0d10106dfe8fbf2">00115</a>     <span class="keyword">inline</span> <span class="keywordtype">void</span> Lock(<span class="keywordtype">void</span>)
<a name="l00116"></a>00116         {Shlock();};
<a name="l00117"></a>00117 };
<a name="l00118"></a>00118 
<a name="l00126"></a><a class="code" href="a00053.html">00126</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00053.html" title="A kind of smart pointer object to support exclusive locking protocol.">exclusive_lock</a>
<a name="l00127"></a>00127 {
<a name="l00128"></a>00128 <span class="keyword">private</span>:
<a name="l00129"></a>00129     <a class="code" href="a00052.html" title="An exclusive locking protocol interface base.">Exclusive</a> *<a class="code" href="a00214.html#a72818707e51af1a21b83b8ea39b95daa" title="Convenience function to exclusively lock an object through it&amp;#39;s protocol.">lock</a>;
<a name="l00130"></a>00130 
<a name="l00131"></a>00131 <span class="keyword">public</span>:
<a name="l00136"></a>00136     <a class="code" href="a00053.html" title="A kind of smart pointer object to support exclusive locking protocol.">exclusive_lock</a>(<a class="code" href="a00052.html" title="An exclusive locking protocol interface base.">Exclusive</a> *<span class="keywordtype">object</span>);
<a name="l00137"></a>00137 
<a name="l00141"></a>00141     ~<a class="code" href="a00053.html" title="A kind of smart pointer object to support exclusive locking protocol.">exclusive_lock</a>();
<a name="l00142"></a>00142 
<a name="l00147"></a><a class="code" href="a00053.html#abf39f84fc150ee84b9ee4cf936176838">00147</a>     <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator!()<span class="keyword"> const</span>
<a name="l00148"></a>00148 <span class="keyword">        </span>{<span class="keywordflow">return</span> <a class="code" href="a00214.html#a72818707e51af1a21b83b8ea39b95daa" title="Convenience function to exclusively lock an object through it&amp;#39;s protocol.">lock</a> == NULL;};
<a name="l00149"></a>00149 
<a name="l00154"></a><a class="code" href="a00053.html#a910272558439ec15734133585c9e4c6c">00154</a>     <span class="keyword">inline</span> operator bool()<span class="keyword"> const</span>
<a name="l00155"></a>00155 <span class="keyword">        </span>{<span class="keywordflow">return</span> <a class="code" href="a00214.html#a72818707e51af1a21b83b8ea39b95daa" title="Convenience function to exclusively lock an object through it&amp;#39;s protocol.">lock</a> != NULL;};
<a name="l00156"></a>00156     
<a name="l00162"></a>00162     <span class="keywordtype">void</span> <a class="code" href="a00214.html#ab7bef2898e731474a9c3dfa805a6f56d" title="Convenience function to unlock shared object through it&amp;#39;s protocol.">release</a>(<span class="keywordtype">void</span>);
<a name="l00163"></a>00163 };
<a name="l00164"></a>00164 
<a name="l00172"></a><a class="code" href="a00137.html">00172</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00137.html" title="A kind of smart pointer object to support shared locking protocol.">shared_lock</a>
<a name="l00173"></a>00173 {
<a name="l00174"></a>00174 <span class="keyword">private</span>:
<a name="l00175"></a>00175     <a class="code" href="a00135.html" title="An exclusive locking protocol interface base.">Shared</a> *<a class="code" href="a00214.html#a72818707e51af1a21b83b8ea39b95daa" title="Convenience function to exclusively lock an object through it&amp;#39;s protocol.">lock</a>;
<a name="l00176"></a>00176     <span class="keywordtype">int</span> state;
<a name="l00177"></a>00177     <span class="keywordtype">bool</span> <a class="code" href="a00214.html#afbca012752e5f641c92e06645f0c06dc" title="Convenience function to exclusively schedule conditional access.">modify</a>;
<a name="l00178"></a>00178 
<a name="l00179"></a>00179 <span class="keyword">public</span>:
<a name="l00184"></a>00184     <a class="code" href="a00137.html" title="A kind of smart pointer object to support shared locking protocol.">shared_lock</a>(<a class="code" href="a00135.html" title="An exclusive locking protocol interface base.">Shared</a> *<span class="keywordtype">object</span>);
<a name="l00185"></a>00185 
<a name="l00189"></a>00189     ~<a class="code" href="a00137.html" title="A kind of smart pointer object to support shared locking protocol.">shared_lock</a>();
<a name="l00190"></a>00190 
<a name="l00195"></a><a class="code" href="a00137.html#a418ab923593f604bef5defadbc65cc87">00195</a>     <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator!()<span class="keyword"> const</span>
<a name="l00196"></a>00196 <span class="keyword">        </span>{<span class="keywordflow">return</span> <a class="code" href="a00214.html#a72818707e51af1a21b83b8ea39b95daa" title="Convenience function to exclusively lock an object through it&amp;#39;s protocol.">lock</a> == NULL;};
<a name="l00197"></a>00197 
<a name="l00202"></a><a class="code" href="a00137.html#ad42365edeec55e751200a0929e0639b8">00202</a>     <span class="keyword">inline</span> operator bool()<span class="keyword"> const</span>
<a name="l00203"></a>00203 <span class="keyword">        </span>{<span class="keywordflow">return</span> <a class="code" href="a00214.html#a72818707e51af1a21b83b8ea39b95daa" title="Convenience function to exclusively lock an object through it&amp;#39;s protocol.">lock</a> != NULL;};
<a name="l00204"></a>00204 
<a name="l00210"></a>00210     <span class="keywordtype">void</span> <a class="code" href="a00214.html#ab7bef2898e731474a9c3dfa805a6f56d" title="Convenience function to unlock shared object through it&amp;#39;s protocol.">release</a>(<span class="keywordtype">void</span>);
<a name="l00211"></a>00211 
<a name="l00215"></a>00215     <span class="keywordtype">void</span> <a class="code" href="a00214.html#aeaed52a287086b5ba39effca9e7b037d" title="Convenience function to exclusive lock shared object through it&amp;#39;s protocol.">exclusive</a>(<span class="keywordtype">void</span>);
<a name="l00216"></a>00216 
<a name="l00220"></a>00220     <span class="keywordtype">void</span> <a class="code" href="a00214.html#a5ece1dc7970bcebf162c214d349292b2" title="Convenience function to restore shared locking for object through it&amp;#39;s protocol...">share</a>(<span class="keywordtype">void</span>);
<a name="l00221"></a>00221 };
<a name="l00222"></a>00222 
<a name="l00227"></a><a class="code" href="a00214.html#a72818707e51af1a21b83b8ea39b95daa">00227</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="a00214.html#a72818707e51af1a21b83b8ea39b95daa" title="Convenience function to exclusively lock an object through it&amp;#39;s protocol.">lock</a>(<a class="code" href="a00052.html" title="An exclusive locking protocol interface base.">Exclusive</a> *<span class="keywordtype">object</span>)
<a name="l00228"></a>00228     {<span class="keywordtype">object</span>-&gt;Exlock();}
<a name="l00229"></a>00229 
<a name="l00234"></a><a class="code" href="a00214.html#a140946704e1b4c4e9c3b14081c1d300d">00234</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="a00214.html#a140946704e1b4c4e9c3b14081c1d300d" title="Convenience function to unlock an exclusive object through it&amp;#39;s protocol.">unlock</a>(<a class="code" href="a00052.html" title="An exclusive locking protocol interface base.">Exclusive</a> *<span class="keywordtype">object</span>)
<a name="l00235"></a>00235     {<span class="keywordtype">object</span>-&gt;Unlock();}
<a name="l00236"></a>00236 
<a name="l00241"></a><a class="code" href="a00214.html#ad6378c2aa4e17197d8e936674e5b2687">00241</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="a00214.html#ad6378c2aa4e17197d8e936674e5b2687" title="Convenience function to access (lock) shared object through it&amp;#39;s protocol.">access</a>(<a class="code" href="a00135.html" title="An exclusive locking protocol interface base.">Shared</a> *<span class="keywordtype">object</span>)
<a name="l00242"></a>00242     {<span class="keywordtype">object</span>-&gt;Shlock();}
<a name="l00243"></a>00243 
<a name="l00248"></a><a class="code" href="a00214.html#ab7bef2898e731474a9c3dfa805a6f56d">00248</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="a00214.html#ab7bef2898e731474a9c3dfa805a6f56d" title="Convenience function to unlock shared object through it&amp;#39;s protocol.">release</a>(<a class="code" href="a00135.html" title="An exclusive locking protocol interface base.">Shared</a> *<span class="keywordtype">object</span>)
<a name="l00249"></a>00249     {<span class="keywordtype">object</span>-&gt;Unlock();}
<a name="l00250"></a>00250 
<a name="l00255"></a><a class="code" href="a00214.html#aeaed52a287086b5ba39effca9e7b037d">00255</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="a00214.html#aeaed52a287086b5ba39effca9e7b037d" title="Convenience function to exclusive lock shared object through it&amp;#39;s protocol.">exclusive</a>(<a class="code" href="a00135.html" title="An exclusive locking protocol interface base.">Shared</a> *<span class="keywordtype">object</span>)
<a name="l00256"></a>00256     {<span class="keywordtype">object</span>-&gt;Exclusive();}
<a name="l00257"></a>00257 
<a name="l00262"></a><a class="code" href="a00214.html#a5ece1dc7970bcebf162c214d349292b2">00262</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="a00214.html#a5ece1dc7970bcebf162c214d349292b2" title="Convenience function to restore shared locking for object through it&amp;#39;s protocol...">share</a>(<a class="code" href="a00135.html" title="An exclusive locking protocol interface base.">Shared</a> *<span class="keywordtype">object</span>)
<a name="l00263"></a>00263     {<span class="keywordtype">object</span>-&gt;Share();}
<a name="l00264"></a>00264 
<a name="l00268"></a><a class="code" href="a00214.html#a89b82ac3392a4ce37a59fd816977b312">00268</a> <span class="keyword">typedef</span> <a class="code" href="a00053.html" title="A kind of smart pointer object to support exclusive locking protocol.">exclusive_lock</a> <a class="code" href="a00053.html" title="A kind of smart pointer object to support exclusive locking protocol.">exlock_t</a>;
<a name="l00269"></a>00269 
<a name="l00273"></a><a class="code" href="a00214.html#a947ea3a9e507dbf59617dbf1d900b824">00273</a> <span class="keyword">typedef</span> <a class="code" href="a00137.html" title="A kind of smart pointer object to support shared locking protocol.">shared_lock</a> <a class="code" href="a00137.html" title="A kind of smart pointer object to support shared locking protocol.">shlock_t</a>;
<a name="l00274"></a>00274 
<a name="l00279"></a><a class="code" href="a00214.html#aa16279b91913c6501623301eb287cfed">00279</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="a00214.html#ab7bef2898e731474a9c3dfa805a6f56d" title="Convenience function to unlock shared object through it&amp;#39;s protocol.">release</a>(<a class="code" href="a00053.html" title="A kind of smart pointer object to support exclusive locking protocol.">exlock_t</a> &amp;reference)
<a name="l00280"></a>00280     {reference.<a class="code" href="a00053.html#a16e2d07f3551553eba0fbfa30c983a95" title="Release a held lock programatically.">release</a>();}
<a name="l00281"></a>00281 
<a name="l00286"></a><a class="code" href="a00214.html#a96aa4f7571c754153b37a31dda7faebe">00286</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="a00214.html#ab7bef2898e731474a9c3dfa805a6f56d" title="Convenience function to unlock shared object through it&amp;#39;s protocol.">release</a>(<a class="code" href="a00137.html" title="A kind of smart pointer object to support shared locking protocol.">shlock_t</a> &amp;reference)
<a name="l00287"></a>00287     {reference.<a class="code" href="a00137.html#a6e0e44ddc59639b9f3f37f3944accf34" title="Release a held lock programatically.">release</a>();}
<a name="l00288"></a>00288 
<a name="l00289"></a>00289 <span class="comment">// Special macros to allow member functions of an object with a protocol</span>
<a name="l00290"></a>00290 <span class="comment">// to create self locking states while the member functions are called by</span>
<a name="l00291"></a>00291 <span class="comment">// placing an exclusive_lock or shared_lock smart object on their stack</span>
<a name="l00292"></a>00292 <span class="comment">// frame to reference their self.</span>
<a name="l00293"></a>00293 
<a name="l00294"></a>00294 <span class="preprocessor">#define exclusive_object()  exlock_t __autolock__ = this</span>
<a name="l00295"></a>00295 <span class="preprocessor"></span><span class="preprocessor">#define protected_object()  shlock_t __autolock__ = this</span>
<a name="l00296"></a>00296 <span class="preprocessor"></span><span class="preprocessor">#define exclusive_access(x) exlock_t __autolock__ = &amp;x</span>
<a name="l00297"></a>00297 <span class="preprocessor"></span><span class="preprocessor">#define protected_access(x) shlock_t __autolock__ = &amp;x</span>
<a name="l00298"></a>00298 <span class="preprocessor"></span>
<a name="l00299"></a>00299 END_NAMESPACE
<a name="l00300"></a>00300 
<a name="l00301"></a>00301 <span class="preprocessor">#endif</span>
</pre></div></div>
<hr class="footer"/><address style="text-align: right;"><small>Generated on Tue Jul 6 08:22:01 2010 for UCommon by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>