1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.0.1 Transitional//EN">
5 <meta http-equiv=
"Content-Type" content=
"text/html; charset=ISO-8859-1">
6 <title>Boost.Flyweight Documentation - Tracking policies reference
</title>
7 <link rel=
"stylesheet" href=
"../style.css" type=
"text/css">
8 <link rel=
"start" href=
"../index.html">
9 <link rel=
"prev" href=
"locking.html">
10 <link rel=
"up" href=
"index.html">
11 <link rel=
"next" href=
"../performance.html">
15 <h1><img src=
"../../../../boost.png" alt=
"Boost logo" align=
16 "middle" width=
"277" height=
"86">Boost.Flyweight
17 Tracking policies reference
</h1>
19 <div class=
"prev_link"><a href=
"locking.html"><img src=
"../prev.gif" alt=
"locking policies" border=
"0"><br>
22 <div class=
"up_link"><a href=
"index.html"><img src=
"../up.gif" alt=
"Boost.Flyweight reference" border=
"0"><br>
23 Boost.Flyweight reference
25 <div class=
"next_link"><a href=
"../performance.html"><img src=
"../next.gif" alt=
"performance" border=
"0"><br>
27 </a></div><br clear=
"all" style=
"clear: all;">
34 <li><a href=
"#preliminary">Preliminary concepts
</a></li>
35 <li><a href=
"#tracking">Tracking policies
</a></li>
36 <li><a href=
"#tracking_tag_synopsis">Header
37 <code>"boost/flyweight/tracking_tag.hpp"</code> synopsis
</a>
39 <li><a href=
"#is_tracking">Class template
<code>is_tracking
</code></a></li>
40 <li><a href=
"#tracking_construct">Class template
<code>tracking
</code></a></li>
43 <li><a href=
"#refcounted_fwd_synopsis">Header
44 <code>"boost/flyweight/refcounted_fwd.hpp"</code> synopsis
</a>
46 <li><a href=
"#refcounted_synopsis">Header
47 <code>"boost/flyweight/refcounted.hpp"</code> synopsis
</a>
49 <li><a href=
"#refcounted">Class
<code>refcounted
</code></a></li>
52 <li><a href=
"#no_tracking_fwd_synopsis">Header
53 <code>"boost/flyweight/no_tracking_fwd.hpp"</code> synopsis
</a>
55 <li><a href=
"#no_tracking_synopsis">Header
56 <code>"boost/flyweight/no_tracking.hpp"</code> synopsis
</a>
58 <li><a href=
"#no_tracking">Class
<code>no_tracking
</code></a></li>
63 <h2><a name=
"preliminary">Preliminary concepts
</a></h2>
66 A
<i>tracking policy helper
</i> provides access to some of the functionality
67 of a
<a href=
"factories.html#factory">factory
</a> so as to be used
68 in the implementation of an associated
<a href=
"#tracking"><code>Tracking Policy
</code></a>.
69 In the following table,
<code>TrackingHelper
</code> is a tracking policy
70 helper associated to a
<a href=
"factories.html#factory">factory
</a> type
71 <code>Factory
</code> of elements of type
<code>Entry
</code>,
<code>h
</code>
73 <code>Factory::handle_type
</code> associated to a
<code>Factory
</code> <code>f
</code>
74 and
<code>check
</code> is a value of
75 a
<a href=
"http://www.sgi.com/tech/stl/Predicate.html"><code>Predicate
</code></a>
76 type
<code>Checker
</code> with argument of type
<code>Factory::handle_type
</code>.
80 <table cellspacing=
"0">
81 <caption><b>Tracking Policy Helper requirements.
</b></caption>
83 <th align=
"center">expression
</th>
84 <th align=
"center">return type
</th>
85 <th align=
"center">assertion/note
<br>pre/post-condition
</th>
88 <td><code>TrackingHelper::entry(h);
</code></td>
89 <td><code>const Entry
&</code></td>
90 <td>Returns
<code>f.entry(h)
</code>.
</td>
93 <td><code>TrackingHelper::erase(h,check);
</code></td>
94 <td><code>void
</code></td>
95 <td>If
<code>check(h)
</code>, invokes
<code>f.erase(h)
</code>.
</td>
101 The execution of
<code>TrackingHelper::erase
</code> (including the
102 invocation of
<code>check(h)
</code>) is done in a
103 synchronized manner so as to prevent any other thread of execution from
104 simultaneously accessing the factory's insertion or deletion facilities.
107 <h2><a name=
"tracking">Tracking policies
</a></h2>
110 A
<i>tracking policy
</i> defines the strategy to be followed by a
111 <a href=
"flyweight.html#flyweight"><code>flyweight
</code></a> instantiation when
112 all the flyweight objects associated to a given value are destroyed.
113 The tracking policy contributes some type information necessary for the
114 definition of the
<code>flyweight
</code> internal
115 <a href=
"factories.html#factory">factory
</a>.
119 A type
<code>Tracking
</code> is a tracking policy if:
121 <li>One of the following conditions is satisfied:
123 <li><a href=
"#is_tracking"><code>is_tracking
<Tracking
>::type
</code></a> is
124 <a href=
"../../../mpl/doc/refmanual/bool.html"><code>boost::mpl::true_
</code></a>,
</li>
125 <li><code>Tracking
</code> is of the form
126 <a href=
"#tracking_construct"><code>tracking
<Tracking'
></code></a>.
</li>
129 <li>The expression
<code>Tracking::entry_type
</code> (or
130 <code>Tracking'::entry_type
</code> if (b) applies) is an
131 <a href=
"../../../mpl/doc/refmanual/lambda-expression.html"><code>MPL Lambda
132 Expression
</code></a> that resolves, when invoked with different types
133 (
<code>Value
</code>,
<code>Key
</code>) such that
<code>Value
</code> is
134 <a href=
"http://www.sgi.com/tech/stl/Assignable.html"><code>Assignable
</code></a>
135 and implicitly convertible to
<code>const Key
&</code>, to an
136 <a href=
"http://www.sgi.com/tech/stl/Assignable.html"><code>Assignable
</code></a>
137 type
<code>Entry
</code> implicitly convertible to both
<code>const Value
&</code>
138 and
<code>const Key
&</code>.
140 <li>The expression
<code>Tracking::handle_type
</code> (or
141 <code>Tracking'::handle_type
</code> if (b) applies) is an
142 <a href=
"../../../mpl/doc/refmanual/lambda-expression.html"><code>MPL Lambda
143 Expression
</code></a>; this expression, when invoked with types
144 (
<code>InternalHandle
</code>,
<a href=
"#preliminary"><code>TrackingHelper
</code></a>),
145 with
<code>InternalHandle
</code> being
146 <a href=
"http://www.sgi.com/tech/stl/Assignable.html"><code>Assignable
</code></a>
147 and providing the nothrow guarantee for copy and assignment,
149 <a href=
"http://www.sgi.com/tech/stl/Assignable.html"><code>Assignable
</code></a>
150 type
<code>Handle
</code> which also provides the nothrow guarantee for
151 copy and assignment and is constructible from and implicitly
152 convertible to
<code>InternalHandle
</code>.
153 <code>TrackingHelper
</code> is an incomplete type at the time of
154 invocation of
<code>Tracking::handle_type
</code>.
157 <code>Tracking::handle_type
</code> is parameterized by a helper that provides
158 access to some of the functionality of the factory associated to the
159 tracking policy. This factory's associated entry and handle types are the types
160 <code>Entry
</code> and
<code>Handle
</code> defined above, respectively.
163 <h2><a name=
"tracking_tag_synopsis">Header
164 <a href=
"../../../../boost/flyweight/tracking_tag.hpp"><code>"boost/flyweight/tracking_tag.hpp"</code></a> synopsis
</a></h2>
167 <span class=keyword
>namespace
</span> <span class=identifier
>boost
</span><span class=special
>{
</span>
169 <span class=keyword
>namespace
</span> <span class=identifier
>flyweights
</span><span class=special
>{
</span>
171 <span class=keyword
>struct
</span> <span class=identifier
>tracking_marker
</span><span class=special
>;
</span>
173 <span class=keyword
>template
</span><span class=special
><</span><span class=keyword
>typename
</span> <span class=identifier
>T
</span><span class=special
>></span>
174 <span class=keyword
>struct
</span> <span class=identifier
>is_tracking
</span>
176 <span class=keyword
>template
</span><span class=special
><</span><span class=keyword
>typename
</span> <span class=identifier
>T
</span><span class=special
>></span>
177 <span class=keyword
>struct
</span> <span class=identifier
>tracking
</span><span class=special
>;
</span>
179 <span class=special
>}
</span> <span class=comment
>// namespace boost::flyweights
</span>
181 <span class=special
>}
</span> <span class=comment
>// namespace boost
</span>
184 <h3><a name=
"is_tracking">Class template
<code>is_tracking
</code></a></h3>
187 Unless specialized by the user,
<code>is_tracking
<T
>::type
</code> is
188 <a href=
"../../../mpl/doc/refmanual/bool.html"><code>boost::mpl::true_
</code></a>
189 if
<code>T
</code> is derived from
<code>tracking_marker
</code>, and it is
190 <a href=
"../../../mpl/doc/refmanual/bool.html"><code>boost::mpl::false_
</code></a>
194 <h3><a name=
"tracking_construct">Class template
<code>tracking
</code></a></h3>
197 <code>tracking
<T
></code> is a syntactic construct meant to indicate
198 that
<code>T
</code> is a tracking policy without resorting to the
199 mechanisms provided by the
<code>is_tracking
</code> class template.
202 <h2><a name=
"refcounted_fwd_synopsis">Header
203 <a href=
"../../../../boost/flyweight/refcounted_fwd.hpp"><code>"boost/flyweight/refcounted_fwd.hpp"</code></a> synopsis
</a></h2>
206 <span class=keyword
>namespace
</span> <span class=identifier
>boost
</span><span class=special
>{
</span>
208 <span class=keyword
>namespace
</span> <span class=identifier
>flyweights
</span><span class=special
>{
</span>
210 <span class=keyword
>struct
</span> <span class=identifier
>refcounted
</span><span class=special
>;
</span>
212 <span class=special
>}
</span> <span class=comment
>// namespace boost::flyweights
</span>
214 <span class=special
>}
</span> <span class=comment
>// namespace boost
</span>
218 <code>refcounted_fwd.hpp
</code> forward declares the class
219 <a href=
"#refcounted"><code>refcounted
</code></a>.
222 <h2><a name=
"refcounted_synopsis">Header
223 <a href=
"../../../../boost/flyweight/refcounted.hpp"><code>"boost/flyweight/refcounted.hpp"</code></a> synopsis
</a></h2>
225 <h3><a name=
"refcounted">Class
<code>refcounted
</code></a></h3>
228 <a href=
"#tracking"><code>Tracking Policy
</code></a> providing
229 <a href=
"flyweight.html#flyweight"><code>flyweight
</code></a>
230 instantiations with reference counting semantics: when all the flyweight objects
231 associated to a given value are destroyed, the corresponding entry is
232 erased from
<code>flyweight
</code>'s internal
233 <a href=
"factories.html#factory">factory
</a>.
236 <h2><a name=
"no_tracking_fwd_synopsis">Header
237 <a href=
"../../../../boost/flyweight/no_tracking_fwd.hpp"><code>"boost/flyweight/no_tracking_fwd.hpp"</code></a> synopsis
</a></h2>
240 <span class=keyword
>namespace
</span> <span class=identifier
>boost
</span><span class=special
>{
</span>
242 <span class=keyword
>namespace
</span> <span class=identifier
>flyweights
</span><span class=special
>{
</span>
244 <span class=keyword
>struct
</span> <span class=identifier
>no_tracking
</span><span class=special
>;
</span>
246 <span class=special
>}
</span> <span class=comment
>// namespace boost::flyweights
</span>
248 <span class=special
>}
</span> <span class=comment
>// namespace boost
</span>
252 <code>no_tracking_fwd.hpp
</code> forward declares the class
253 <a href=
"#no_tracking"><code>no_tracking
</code></a>.
256 <h2><a name=
"no_tracking_synopsis">Header
257 <a href=
"../../../../boost/flyweight/no_tracking.hpp"><code>"boost/flyweight/no_tracking.hpp"</code></a> synopsis
</a></h2>
259 <h3><a name=
"no_tracking">Class
<code>no_tracking
</code></a></h3>
262 Null
<a href=
"#tracking"><code>Tracking Policy
</code></a>: elements inserted
263 into
<code>flyweight
</code>'s internal
<a href=
"factories.html#factory">factory
</a>
264 are not erased until program termination.
269 <div class=
"prev_link"><a href=
"locking.html"><img src=
"../prev.gif" alt=
"locking policies" border=
"0"><br>
272 <div class=
"up_link"><a href=
"index.html"><img src=
"../up.gif" alt=
"Boost.Flyweight reference" border=
"0"><br>
273 Boost.Flyweight reference
275 <div class=
"next_link"><a href=
"../performance.html"><img src=
"../next.gif" alt=
"performance" border=
"0"><br>
277 </a></div><br clear=
"all" style=
"clear: all;">
281 <p>Revised August
18th
2008</p>
283 <p>© Copyright
2006-
2008 Joaqu
ín M L
ópez Mu
ñoz.
284 Distributed under the Boost Software
285 License, Version
1.0. (See accompanying file
<a href=
"../../../../LICENSE_1_0.txt">
286 LICENSE_1_0.txt
</a> or copy at
<a href=
"http://www.boost.org/LICENSE_1_0.txt">
287 http://www.boost.org/LICENSE_1_0.txt
</a>)