File: a00134.html

package info (click to toggle)
libloki 0.1.7-5
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 6,600 kB
  • sloc: cpp: 30,475; ansic: 1,974; makefile: 365; php: 316; perl: 108
file content (184 lines) | stat: -rwxr-xr-x 10,902 bytes parent folder | download | duplicates (5)
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
180
181
182
183
184
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Loki: Loki::StaticChecker&lt; ExceptionPolicy &gt; Class Template Reference</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.5.8 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    <li>
      <form action="search.php" method="get">
        <table cellspacing="0" cellpadding="0" border="0">
          <tr>
            <td><label>&nbsp;<u>S</u>earch&nbsp;for&nbsp;</label></td>
            <td><input type="text" name="query" value="" size="20" accesskey="s"/></td>
          </tr>
        </table>
      </form>
    </li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="annotated.html"><span>Class&nbsp;List</span></a></li>
      <li><a href="classes.html"><span>Class&nbsp;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&nbsp;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&nbsp;Members</span></a></li>
    </ul>
  </div>
  <div class="navpath"><a class="el" href="a00192.html">Loki</a>::<a class="el" href="a00134.html">StaticChecker</a>
  </div>
</div>
<div class="contents">
<h1>Loki::StaticChecker&lt; ExceptionPolicy &gt; Class Template Reference</h1><!-- doxytag: class="Loki::StaticChecker" --><code>#include &lt;Checker.h&gt;</code>
<p>

<p>
<a href="a00304.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Types</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="8aff7228f0f19f32c9d0efeb36fea643"></a><!-- doxytag: member="Loki::StaticChecker::Validator" ref="8aff7228f0f19f32c9d0efeb36fea643" args=")(void)" -->
typedef bool(*&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00134.html#8aff7228f0f19f32c9d0efeb36fea643">Validator</a> )(void)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Signature for the validation function. <br></td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00134.html#03eca9af5c834a019115f519994d84d7">StaticChecker</a> (<a class="el" href="a00134.html#8aff7228f0f19f32c9d0efeb36fea643">Validator</a> validator, <a class="el" href="a00134.html#8aff7228f0f19f32c9d0efeb36fea643">Validator</a> pre=0, <a class="el" href="a00134.html#8aff7228f0f19f32c9d0efeb36fea643">Validator</a> post=0)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00134.html#c34b548bb197793f0e393e0448b07b6f">~StaticChecker</a> (void)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00134.html#d8e80dcf79a603395ecc9d5b2fe91491">Check</a> (void) const </td></tr>

</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
<h3>template&lt;class ExceptionPolicy&gt;<br>
 class Loki::StaticChecker&lt; ExceptionPolicy &gt;</h3>

This class checks if a function provides the no-throw exception safety level and if the function violated any invariants. Invariants for stand-alone and static functions act as pre-conditions and post-conditions.<p>
<dl class="user" compact><dt><b>Usage</b></dt><dd><ol type=1>
<li>Implement a function that checks the invariants associated with a function, or with the static data for a class. The function must have the signature similar to the Validator type. Something like: "static bool Host::StaticIsValid( void );" or "bool IsOkay( void );"<ul>
<li>The function should return true if everything is okay, but false if something is wrong.</li><li>Or it could assert if anything is wrong.</li></ul>
</li><li>If the checker is for static functions within a class, declare typedef's inside the class declaration like these. Make one typedef for each policy you use. I typedef'ed the <a class="el" href="a00020.html">CheckForNothing</a> policy as CheckInvariants because even if a function can't provide the no-throw guarantee, it should still make sure that static data remains in a valid state.<ul>
<li>typedef Loki::StaticChecker&lt; ::Loki::CheckForNoThrow &gt; <a class="el" href="a00024.html">CheckStaticForNoThrow</a>;</li><li>typedef Loki::StaticChecker&lt; ::Loki::CheckForNothing &gt; CheckStaticInvariants;</li></ul>
</li><li>Construct a checker near the top of each member function - except in the validator member function. Pass the address of your validator function into the checker's constructor.<ul>
<li>If the function never throws, then use the <a class="el" href="a00021.html">CheckForNoThrow</a> policy.</li><li>Otherwise use the CheckInvariants policy.</li></ul>
</li><li>Recompile a debug version of your program, run it, and see if an assertion fails. </li></ol>
</dd></dl>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="03eca9af5c834a019115f519994d84d7"></a><!-- doxytag: member="Loki::StaticChecker::StaticChecker" ref="03eca9af5c834a019115f519994d84d7" args="(Validator validator, Validator pre=0, Validator post=0)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class ExceptionPolicy &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="a00134.html">Loki::StaticChecker</a>&lt; ExceptionPolicy &gt;::<a class="el" href="a00134.html">StaticChecker</a>           </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="a00134.html#8aff7228f0f19f32c9d0efeb36fea643">Validator</a>&nbsp;</td>
          <td class="paramname"> <em>validator</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="a00134.html#8aff7228f0f19f32c9d0efeb36fea643">Validator</a>&nbsp;</td>
          <td class="paramname"> <em>pre</em> = <code>0</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="a00134.html#8aff7228f0f19f32c9d0efeb36fea643">Validator</a>&nbsp;</td>
          <td class="paramname"> <em>post</em> = <code>0</code></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td><code> [inline, explicit]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
The constructor makes sure the host is valid at the time the checker was created, thus insuring the host object was not corrupt from the start. <dl class="user" compact><dt><b>validator Pointer to function that checks class invariants.</b></dt><dd></dd></dl>
<dl class="user" compact><dt><b>pre Optional pointer to function that checks pre-conditions.</b></dt><dd></dd></dl>
<dl class="user" compact><dt><b>post Optional pointer to function that checks post-conditions.</b></dt><dd></dd></dl>

<p>References <a class="el" href="a00232.html#l00481">Loki::StaticChecker&lt; ExceptionPolicy &gt;::Check()</a>.</p>

<p>
<div class="dynheader">
Here is the call graph for this function:</div>
<div class="dynsection">
</div>

</div>
</div><p>
<a class="anchor" name="c34b548bb197793f0e393e0448b07b6f"></a><!-- doxytag: member="Loki::StaticChecker::~StaticChecker" ref="c34b548bb197793f0e393e0448b07b6f" args="(void)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class ExceptionPolicy &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="a00134.html">Loki::StaticChecker</a>&lt; ExceptionPolicy &gt;::~<a class="el" href="a00134.html">StaticChecker</a>           </td>
          <td>(</td>
          <td class="paramtype">void&nbsp;</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
The destructor checks if any Host invariants failed, and then calls the ExceptionPolicy's Check function to determine what to do in case of an exception. 
<p>References <a class="el" href="a00232.html#l00481">Loki::StaticChecker&lt; ExceptionPolicy &gt;::Check()</a>.</p>

<p>
<div class="dynheader">
Here is the call graph for this function:</div>
<div class="dynsection">
</div>

</div>
</div><p>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="d8e80dcf79a603395ecc9d5b2fe91491"></a><!-- doxytag: member="Loki::StaticChecker::Check" ref="d8e80dcf79a603395ecc9d5b2fe91491" args="(void) const " -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class ExceptionPolicy &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">bool <a class="el" href="a00134.html">Loki::StaticChecker</a>&lt; ExceptionPolicy &gt;::Check           </td>
          <td>(</td>
          <td class="paramtype">void&nbsp;</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td> const<code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This first checks its own invariants, and then calls the validator function to make sure no invariants were broken by the function which created this checker. That function can call Check directly to verify the data remains valid at any time. This does not care if the pre- and post- condition validator pointers are null since a host class may pass in NULL pointers for either to indicate the pre-conditions or post-conditions are the same as the overall class invariants. 
<p>Referenced by <a class="el" href="a00232.html#l00449">Loki::StaticChecker&lt; ExceptionPolicy &gt;::StaticChecker()</a>, and <a class="el" href="a00232.html#l00465">Loki::StaticChecker&lt; ExceptionPolicy &gt;::~StaticChecker()</a>.</p>

</div>
</div><p>
<hr>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="a00147.html">Checker.h</a></ul>
</div>
<hr size="1"><address style="text-align: right;"><small>Generated on Thu Jan 29 18:51:42 2009 for Loki by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
</body>
</html>