blob: 8de3d0373c94893ae22bb098a54f587b6b405173 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>oscl_error.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.2.18 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="modules.html">Modules</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="annotated.html">Data Structures</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Data Fields</a> &nbsp; <a class="qindex" href="globals.html">Globals</a> &nbsp; </center>
<hr><h1>oscl_error.h</h1><a href="oscl__error_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">// -*- c++ -*-</span>
00002 <span class="comment">// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =</span>
00003
00004 <span class="comment">// O S C L _ E R R O R</span>
00005
00006 <span class="comment">// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =</span>
00007
00018 <span class="preprocessor">#ifndef OSCL_ERROR_H_INCLUDED</span>
00019 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_ERROR_H_INCLUDED</span>
00020 <span class="preprocessor"></span>
00021 <span class="preprocessor">#ifndef OSCL_HEAPBASE_H_INCLUDED</span>
00022 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__heapbase_8h.html">oscl_heapbase.h</a>"</span>
00023 <span class="preprocessor">#endif</span>
00024 <span class="preprocessor"></span>
00025 <span class="preprocessor">#ifndef OSCL_DEFALLOC_H_INCLUDED</span>
00026 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__defalloc_8h.html">oscl_defalloc.h</a>"</span>
00027 <span class="preprocessor">#endif</span>
00028 <span class="preprocessor"></span>
00029 <span class="preprocessor">#ifndef OSCL_ERROR_CODES_H_INCLUDED</span>
00030 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__error__codes_8h.html">oscl_error_codes.h</a>"</span>
00031 <span class="preprocessor">#endif</span>
00032 <span class="preprocessor"></span>
00036 <span class="keyword">class </span><a class="code" href="classOsclErrorTrapImp.html">OsclErrorTrapImp</a>;
<a name="l00037"></a><a class="code" href="classOsclErrorTrap.html">00037</a> <span class="keyword">class </span><a class="code" href="classOsclErrorTrap.html">OsclErrorTrap</a>
00038 {
00039 <span class="keyword">public</span>:
00047 OSCL_IMPORT_REF <span class="keyword">static</span> int32 <a class="code" href="classOsclErrorTrap.html#d0">Init</a>(<a class="code" href="classOscl__DefAlloc.html">Oscl_DefAlloc</a> *aAlloc = <a class="code" href="group__osclbase.html#a81">NULL</a>);
00053 OSCL_IMPORT_REF <span class="keyword">static</span> int32 <a class="code" href="classOsclErrorTrap.html#d1">Cleanup</a>();
00058 OSCL_IMPORT_REF <span class="keyword">static</span> <a class="code" href="classOsclErrorTrapImp.html">OsclErrorTrapImp</a>* <a class="code" href="classOsclErrorTrap.html#d2">GetErrorTrapImp</a>();
00059 };
00060
00061
<a name="l00065"></a><a class="code" href="classOsclError.html">00065</a> <span class="keyword">class </span><a class="code" href="classOsclError.html">OsclError</a>
00066 {
00067 <span class="keyword">public</span>:
00074 OSCL_IMPORT_REF <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classOsclError.html#d0">PushL</a>(<a class="code" href="class__OsclHeapBase.html">_OsclHeapBase</a> * aPtr);
00075
00078 OSCL_IMPORT_REF <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classOsclError.html#d0">PushL</a>(<a class="code" href="group__osclbase.html#a25">OsclAny</a>* aPtr);
00079
00082 OSCL_IMPORT_REF <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classOsclError.html#d0">PushL</a>(<a class="code" href="classOsclTrapItem.html">OsclTrapItem</a> anItem);
00083
00086 OSCL_IMPORT_REF <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classOsclError.html#d3">Pop</a>();
00087
00090 OSCL_IMPORT_REF <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classOsclError.html#d3">Pop</a>(int32 aCount);
00091
00095 OSCL_IMPORT_REF <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classOsclError.html#d5">PopDealloc</a>();
00096
00099 OSCL_IMPORT_REF <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classOsclError.html#d5">PopDealloc</a>(int32 aCount);
00100
00106 OSCL_IMPORT_REF <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classOsclError.html#d7">Leave</a>(int32 aReason);
00107
00111 OSCL_IMPORT_REF <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classOsclError.html#d8">LeaveIfNull</a>(<a class="code" href="group__osclbase.html#a25">OsclAny</a> *a);
00112
00117 OSCL_IMPORT_REF <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classOsclError.html#d9">LeaveIfError</a>(int32 aReason);
00118
00119 };
00120
<a name="l00123"></a><a class="code" href="group__osclerror.html#a8">00123</a> <span class="preprocessor">#define OSCL_TRAPSTACK_PUSH(a) OsclError::PushL(a)</span>
<a name="l00124"></a><a class="code" href="group__osclerror.html#a9">00124</a> <span class="preprocessor"></span><span class="preprocessor">#define OSCL_TRAPSTACK_POP() OsclError::Pop()</span>
<a name="l00125"></a><a class="code" href="group__osclerror.html#a10">00125</a> <span class="preprocessor"></span><span class="preprocessor">#define OSCL_TRAPSTACK_POPDEALLOC() OsclError::PopDealloc()</span>
00126 <span class="preprocessor"></span>
00131 <span class="comment">//Map TPVBaseErrorEnum return codes to Oscl Error leave codes</span>
00132 <span class="comment">//Some of these codes indicate failure to init Oscl layer, in</span>
00133 <span class="comment">//that case they map to zero and assert.</span>
00134 <span class="keyword">static</span> <span class="keyword">const</span> int32 _OsclBaseToErrorMap[] =
00135 {
00136 <span class="comment">/*0*/</span><a class="code" href="group__osclerror.html#a12">OsclErrGeneral</a>
00137 ,<span class="comment">/*EPVErrorBaseNotInstalled=1*/</span>0
00138 ,<span class="comment">/*EPVErrorBaseAlreadyInstalled=2*/</span><a class="code" href="group__osclerror.html#a28">OsclErrAlreadyInstalled</a>
00139 ,<span class="comment">/*EPVErrorBaseOutOfMemory=3*/</span><a class="code" href="group__osclerror.html#a13">OsclErrNoMemory</a>
00140 ,<span class="comment">/*EPVErrorBaseSystemCallFailed=4*/</span><a class="code" href="group__osclerror.html#a29">OsclErrSystemCallFailed</a>
00141 ,<span class="comment">/*EPVErrorBaseTooManyThreads=5*/</span>0
00142 ,<span class="comment">/*EPVErrorBaseNotSupported=6*/</span><a class="code" href="group__osclerror.html#a15">OsclErrNotSupported</a>
00143 ,<span class="comment">/*EPVErrorBaseNotReady=7*/</span><a class="code" href="group__osclerror.html#a20">OsclErrNotReady</a>
00144 };
00145
00146 <span class="preprocessor">#include "<a class="code" href="oscl__singleton_8h.html">oscl_singleton.h</a>"</span>
00147 <span class="preprocessor">#include "<a class="code" href="oscl__assert_8h.html">oscl_assert.h</a>"</span>
00148 <span class="preprocessor">#if(OSCL_HAS_SINGLETON_SUPPORT)</span>
00149 <span class="preprocessor"></span><span class="keyword">class </span>OsclSingletonRegistryEx
00150 {
00151 <span class="keyword">public</span>:
00152 <span class="comment">/*</span>
00153 <span class="comment"> ** Get an entry</span>
00154 <span class="comment"> ** @param ID: identifier</span>
00155 <span class="comment"> ** @returns: the entry value</span>
00156 <span class="comment"> ** @exception: leaves on error.</span>
00157 <span class="comment"> */</span>
00158 <span class="keyword">static</span> <a class="code" href="group__osclbase.html#a25">OsclAny</a>* getInstance(uint32 ID)
00159 {
00160 int32 error;
00161 <a class="code" href="group__osclbase.html#a25">OsclAny</a>* val = <a class="code" href="classOsclSingletonRegistry.html#d0">OsclSingletonRegistry::getInstance</a>(ID, error);
00162 <span class="keywordflow">if</span> (error)
00163 {
00164 <a class="code" href="group__osclbase.html#a78">OSCL_ASSERT</a>(_OsclBaseToErrorMap[error]);
00165 <a class="code" href="classOsclError.html#d7">OsclError::Leave</a>(_OsclBaseToErrorMap[error]);
00166 }
00167 <span class="keywordflow">return</span> val;
00168 }
00169
00170 <span class="comment">/*</span>
00171 <span class="comment"> ** Set an entry</span>
00172 <span class="comment"> ** @param ID: identifier</span>
00173 <span class="comment"> ** @returns: the entry value</span>
00174 <span class="comment"> ** @exception: leaves on error.</span>
00175 <span class="comment"> */</span>
00176 <span class="keyword">static</span> <span class="keywordtype">void</span> registerInstance(<a class="code" href="group__osclbase.html#a25">OsclAny</a>* ptr, uint32 ID)
00177 {
00178 int32 error;
00179 <a class="code" href="classOsclSingletonRegistry.html#d1">OsclSingletonRegistry::registerInstance</a>(ptr, ID, error);
00180 <span class="keywordflow">if</span> (error)
00181 {
00182 <a class="code" href="group__osclbase.html#a78">OSCL_ASSERT</a>(_OsclBaseToErrorMap[error]);
00183 <a class="code" href="classOsclError.html#d7">OsclError::Leave</a>(_OsclBaseToErrorMap[error]);
00184 }
00185 }
00186
00187 <span class="comment">/*</span>
00188 <span class="comment"> //These two APIs can be used to do "test and set" operations on a singleton.</span>
00189 <span class="comment"> //Be sure to always call both APIs to avoid deadlock.</span>
00190 <span class="comment"> */</span>
00191
00192 <span class="comment">/*</span>
00193 <span class="comment"> * Return the current value of the singleton and leave the singleton table locked</span>
00194 <span class="comment"> * on return.</span>
00195 <span class="comment"> * @param ID the singleton ID</span>
00196 <span class="comment"> * @returns the singleton value.</span>
00197 <span class="comment"> ** @exception: leaves on error.</span>
00198 <span class="comment"> */</span>
00199 <span class="keyword">static</span> <a class="code" href="group__osclbase.html#a25">OsclAny</a>* lockAndGetInstance(uint32 ID)
00200 {
00201 int32 error;
00202 <a class="code" href="group__osclbase.html#a25">OsclAny</a>* val = <a class="code" href="classOsclSingletonRegistry.html#d2">OsclSingletonRegistry::lockAndGetInstance</a>(ID, error);
00203 <span class="keywordflow">if</span> (error)
00204 {
00205 <a class="code" href="group__osclbase.html#a78">OSCL_ASSERT</a>(_OsclBaseToErrorMap[error]);
00206 <a class="code" href="classOsclError.html#d7">OsclError::Leave</a>(_OsclBaseToErrorMap[error]);
00207 }
00208 <span class="keywordflow">return</span> val;
00209 }
00210
00211 <span class="comment">/*</span>
00212 <span class="comment"> * Set the value of the singleton. Assume the singleton table is locked on entry.</span>
00213 <span class="comment"> * @param ptr the singleton value</span>
00214 <span class="comment"> * @param ID the singleton ID</span>
00215 <span class="comment"> ** @exception: leaves on error.</span>
00216 <span class="comment"> */</span>
00217 <span class="keyword">static</span> <span class="keywordtype">void</span> registerInstanceAndUnlock(<a class="code" href="group__osclbase.html#a25">OsclAny</a>* ptr, uint32 ID)
00218 {
00219 int32 error;
00220 <a class="code" href="classOsclSingletonRegistry.html#d3">OsclSingletonRegistry::registerInstanceAndUnlock</a>(ptr, ID, error);
00221 <span class="keywordflow">if</span> (error)
00222 {
00223 <a class="code" href="group__osclbase.html#a78">OSCL_ASSERT</a>(_OsclBaseToErrorMap[error]);
00224 <a class="code" href="classOsclError.html#d7">OsclError::Leave</a>(_OsclBaseToErrorMap[error]);
00225 }
00226 }
00227 };
00228
00229 <span class="keyword">template</span> &lt; <span class="keyword">class</span> T, u<span class="keywordtype">int</span>32 ID, <span class="keyword">class</span> Registry = OsclSingletonRegistryEx &gt; <span class="keyword">class </span>OsclSingletonEx
00230 {
00231 <span class="keyword">private</span>:
00232 <span class="comment">// make the copy constructor and assignment operator private</span>
00233 OsclSingletonEx&amp; operator=(OsclSingletonEx&amp; _Y)
00234 {
00235 <span class="keywordflow">return</span>(*this);
00236 }
00237
00238 <span class="keyword">protected</span>:
00239 T* _Ptr;
00240
00241 <span class="keyword">public</span>:
00242 OsclSingletonEx(): _Ptr(<a class="code" href="group__osclbase.html#a86">OSCL_STATIC_CAST</a>(T*, Registry::getInstance(ID))) {};
00243
00244 ~OsclSingletonEx() {};
00245
00253 T&amp; operator*()<span class="keyword"> const</span>
00254 <span class="keyword"> </span>{
00255 <span class="keywordflow">return</span>(*_Ptr);
00256 }
00257
00265 T *operator-&gt;()<span class="keyword"> const</span>
00266 <span class="keyword"> </span>{
00267 <span class="keywordflow">return</span>(_Ptr);
00268 }
00269
00270
00277 <span class="keywordtype">bool</span> set()
00278 {
00279 _Ptr = <a class="code" href="group__osclbase.html#a86">OSCL_STATIC_CAST</a>(T*, Registry::getInstance(ID));
00280 <span class="keywordflow">return</span> (_Ptr ? <span class="keyword">true</span> : <span class="keyword">false</span>);
00281 }
00282
00283 };
00284 <span class="preprocessor">#endif //OSCL_HAS_SINGLETON_SUPPORT</span>
00285 <span class="preprocessor"></span>
00286 <span class="preprocessor">#include "<a class="code" href="oscl__tls_8h.html">oscl_tls.h</a>"</span>
00287 <span class="preprocessor">#include "<a class="code" href="oscl__assert_8h.html">oscl_assert.h</a>"</span>
<a name="l00288"></a><a class="code" href="classOsclTLSRegistryEx.html">00288</a> <span class="keyword">class </span><a class="code" href="classOsclTLSRegistryEx.html">OsclTLSRegistryEx</a>
00289 {
00290 <span class="keyword">public</span>:
00291 <span class="comment">/*</span>
00292 <span class="comment"> ** Get an entry</span>
00293 <span class="comment"> ** @param ID: identifier</span>
00294 <span class="comment"> ** @returns: the entry value</span>
00295 <span class="comment"> ** @exception: leaves on error.</span>
00296 <span class="comment"> */</span>
<a name="l00297"></a><a class="code" href="classOsclTLSRegistryEx.html#d0">00297</a> <span class="keyword">static</span> <a class="code" href="group__osclbase.html#a25">OsclAny</a>* <a class="code" href="classOsclTLSRegistryEx.html#d0">getInstance</a>(uint32 ID)
00298 {
00299 int32 error;
00300 <a class="code" href="group__osclbase.html#a25">OsclAny</a>* val = <a class="code" href="classOsclTLSRegistry.html#d0">OsclTLSRegistry::getInstance</a>(ID, error);
00301 <span class="keywordflow">if</span> (error)
00302 {
00303 <a class="code" href="group__osclbase.html#a78">OSCL_ASSERT</a>(_OsclBaseToErrorMap[error]);
00304 <a class="code" href="classOsclError.html#d7">OsclError::Leave</a>(_OsclBaseToErrorMap[error]);
00305 }
00306 <span class="keywordflow">return</span> val;
00307 }
00308 <span class="comment">/*</span>
00309 <span class="comment"> ** Set an entry</span>
00310 <span class="comment"> ** @param ID: identifier</span>
00311 <span class="comment"> ** @returns: the entry value</span>
00312 <span class="comment"> ** @exception: leaves on error.</span>
00313 <span class="comment"> */</span>
<a name="l00314"></a><a class="code" href="classOsclTLSRegistryEx.html#d1">00314</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classOsclTLSRegistryEx.html#d1">registerInstance</a>(<a class="code" href="group__osclbase.html#a25">OsclAny</a>* ptr, uint32 ID)
00315 {
00316 int32 error;
00317 <a class="code" href="classOsclTLSRegistry.html#d1">OsclTLSRegistry::registerInstance</a>(ptr, ID, error);
00318 <span class="keywordflow">if</span> (error)
00319 {
00320 <a class="code" href="group__osclbase.html#a78">OSCL_ASSERT</a>(_OsclBaseToErrorMap[error]);
00321 <a class="code" href="classOsclError.html#d7">OsclError::Leave</a>(_OsclBaseToErrorMap[error]);
00322 }
00323 }
00324 };
00325
<a name="l00326"></a><a class="code" href="classOsclTLSEx.html">00326</a> <span class="keyword">template</span> &lt; <span class="keyword">class</span> T, u<span class="keywordtype">int</span>32 ID, <span class="keyword">class</span> Registry = OsclTLSRegistryEx &gt; <span class="keyword">class </span><a class="code" href="classOsclTLSEx.html">OsclTLSEx</a>
00327 {
00328 <span class="keyword">private</span>:
00329 <span class="comment">// make the copy constructor and assignment operator private</span>
00330 <a class="code" href="classOsclTLSEx.html">OsclTLSEx</a>&amp; operator=(<a class="code" href="classOsclTLSEx.html">OsclTLSEx</a>&amp; _Y)
00331 {
00332 <span class="keywordflow">return</span>(*this);
00333 }
00334
00335 <span class="keyword">protected</span>:
<a name="l00336"></a><a class="code" href="classOsclTLSEx.html#n0">00336</a> T* <a class="code" href="classOsclTLSEx.html#n0">_Ptr</a>;
00337
00338 <span class="keyword">public</span>:
<a name="l00339"></a><a class="code" href="classOsclTLSEx.html#a0">00339</a> <a class="code" href="classOsclTLSEx.html#a0">OsclTLSEx</a>(): <a class="code" href="classOsclTLSEx.html#n0">_Ptr</a>(<a class="code" href="group__osclbase.html#a86">OSCL_STATIC_CAST</a>(T*, Registry::getInstance(ID))) {};
00340
<a name="l00341"></a><a class="code" href="classOsclTLSEx.html#a1">00341</a> <a class="code" href="classOsclTLSEx.html#a1">~OsclTLSEx</a>() {};
00342
<a name="l00350"></a><a class="code" href="classOsclTLSEx.html#a2">00350</a> T&amp; <a class="code" href="classOsclTLSEx.html#a2">operator*</a>()<span class="keyword"> const</span>
00351 <span class="keyword"> </span>{
00352 <span class="keywordflow">return</span>(*_Ptr);
00353 }
00354
<a name="l00362"></a><a class="code" href="classOsclTLSEx.html#a3">00362</a> T *<a class="code" href="classOsclTLSEx.html#a3">operator-&gt;</a>()<span class="keyword"> const</span>
00363 <span class="keyword"> </span>{
00364 <span class="keywordflow">return</span>(_Ptr);
00365 }
00366
00367
<a name="l00374"></a><a class="code" href="classOsclTLSEx.html#a4">00374</a> <span class="keywordtype">bool</span> <a class="code" href="classOsclTLSEx.html#a4">set</a>()
00375 {
00376 <a class="code" href="classOsclTLSEx.html#n0">_Ptr</a> = <a class="code" href="group__osclbase.html#a86">OSCL_STATIC_CAST</a>(T*, Registry::getInstance(ID));
00377 <span class="keywordflow">return</span> (<a class="code" href="classOsclTLSEx.html#n0">_Ptr</a> ? <span class="keyword">true</span> : <span class="keyword">false</span>);
00378 }
00379
00380 };
00381
00382 <span class="preprocessor">#endif</span>
00383 <span class="preprocessor"></span>
</pre></div><hr size="1"><img src="pvlogo_small.jpg"><address style="align: right;"><small>OSCL API</small>
<address style="align: left;"><small>Posting Version: OPENCORE_20090310 </small>
</small></address>
</body>
</html>