tracking.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0.1 Transitional//EN">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  5. <title>Boost.Flyweight Documentation - Tracking policies reference</title>
  6. <link rel="stylesheet" href="../style.css" type="text/css">
  7. <link rel="start" href="../index.html">
  8. <link rel="prev" href="locking.html">
  9. <link rel="up" href="index.html">
  10. <link rel="next" href="../performance.html">
  11. </head>
  12. <body>
  13. <h1><img src="../../../../boost.png" alt="Boost logo" align=
  14. "middle" width="277" height="86">Boost.Flyweight
  15. Tracking policies reference</h1>
  16. <div class="prev_link"><a href="locking.html"><img src="../prev.gif" alt="locking policies" border="0"><br>
  17. Locking policies
  18. </a></div>
  19. <div class="up_link"><a href="index.html"><img src="../up.gif" alt="Boost.Flyweight reference" border="0"><br>
  20. Boost.Flyweight reference
  21. </a></div>
  22. <div class="next_link"><a href="../performance.html"><img src="../next.gif" alt="performance" border="0"><br>
  23. Performance
  24. </a></div><br clear="all" style="clear: all;">
  25. <hr>
  26. <h2>Contents</h2>
  27. <ul>
  28. <li><a href="#preliminary">Preliminary concepts</a></li>
  29. <li><a href="#tracking">Tracking policies</a></li>
  30. <li><a href="#tracking_tag_synopsis">Header
  31. <code>"boost/flyweight/tracking_tag.hpp"</code> synopsis</a>
  32. <ul>
  33. <li><a href="#is_tracking">Class template <code>is_tracking</code></a></li>
  34. <li><a href="#tracking_construct">Class template <code>tracking</code></a></li>
  35. </ul>
  36. </li>
  37. <li><a href="#refcounted_fwd_synopsis">Header
  38. <code>"boost/flyweight/refcounted_fwd.hpp"</code> synopsis</a>
  39. </li>
  40. <li><a href="#refcounted_synopsis">Header
  41. <code>"boost/flyweight/refcounted.hpp"</code> synopsis</a>
  42. <ul>
  43. <li><a href="#refcounted">Class <code>refcounted</code></a></li>
  44. </ul>
  45. </li>
  46. <li><a href="#no_tracking_fwd_synopsis">Header
  47. <code>"boost/flyweight/no_tracking_fwd.hpp"</code> synopsis</a>
  48. </li>
  49. <li><a href="#no_tracking_synopsis">Header
  50. <code>"boost/flyweight/no_tracking.hpp"</code> synopsis</a>
  51. <ul>
  52. <li><a href="#no_tracking">Class <code>no_tracking</code></a></li>
  53. </ul>
  54. </li>
  55. </ul>
  56. <h2><a name="preliminary">Preliminary concepts</a></h2>
  57. <p>
  58. A <i>tracking policy helper</i> provides access to some of the functionality
  59. of a <a href="factories.html#factory">factory</a> so as to be used
  60. in the implementation of an associated <a href="#tracking"><code>Tracking Policy</code></a>.
  61. In the following table, <code>TrackingHelper</code> is a tracking policy
  62. helper associated to a <a href="factories.html#factory">factory</a> type
  63. <code>Factory</code> of elements of type <code>Entry</code>, <code>h</code>
  64. is a value of
  65. <code>Factory::handle_type</code> associated to a <code>Factory</code> <code>f</code>
  66. and <code>check</code> is a value of
  67. a <a href="https://boost.org/sgi/stl/Predicate.html"><code>Predicate</code></a>
  68. type <code>Checker</code> with argument of type <code>Factory::handle_type</code>.
  69. </p>
  70. <p align="center">
  71. <table cellspacing="0">
  72. <caption><b>Tracking Policy Helper requirements.</b></caption>
  73. <tr>
  74. <th align="center">expression</th>
  75. <th align="center">return type</th>
  76. <th align="center">assertion/note<br>pre/post-condition</th>
  77. </tr>
  78. <tr>
  79. <td><code>TrackingHelper::entry(h);</code></td>
  80. <td><code>const Entry&amp;</code></td>
  81. <td>Returns <code>f.entry(h)</code>.</td>
  82. </tr>
  83. <tr class="odd_tr">
  84. <td><code>TrackingHelper::erase(h,check);</code></td>
  85. <td><code>void</code></td>
  86. <td>If <code>check(h)</code>, invokes <code>f.erase(h)</code>.</td>
  87. </tr>
  88. </table>
  89. </p>
  90. <p>
  91. The execution of <code>TrackingHelper::erase</code> (including the
  92. invocation of <code>check(h)</code>) is done in a
  93. synchronized manner so as to prevent any other thread of execution from
  94. simultaneously accessing the factory's insertion or deletion facilities.
  95. </p>
  96. <h2><a name="tracking">Tracking policies</a></h2>
  97. <p>
  98. A <i>tracking policy</i> defines the strategy to be followed by a
  99. <a href="flyweight.html#flyweight"><code>flyweight</code></a> instantiation when
  100. all the flyweight objects associated to a given value are destroyed.
  101. The tracking policy contributes some type information necessary for the
  102. definition of the <code>flyweight</code> internal
  103. <a href="factories.html#factory">factory</a>.
  104. </p>
  105. <p>
  106. A type <code>Tracking</code> is a tracking policy if:
  107. <ul>
  108. <li>One of the following conditions is satisfied:
  109. <ol type="a">
  110. <li><a href="#is_tracking"><code>is_tracking&lt;Tracking&gt;::type</code></a> is
  111. <a href="../../../mpl/doc/refmanual/bool.html"><code>boost::mpl::true_</code></a>,</li>
  112. <li><code>Tracking</code> is of the form
  113. <a href="#tracking_construct"><code>tracking&lt;Tracking'&gt;</code></a>.</li>
  114. </ol>
  115. </li>
  116. <li>The expression <code>Tracking::entry_type</code> (or
  117. <code>Tracking'::entry_type</code> if (b) applies) is an
  118. <a href="../../../mpl/doc/refmanual/lambda-expression.html"><code>MPL Lambda
  119. Expression</code></a> that resolves, when invoked with different types
  120. (<code>Value</code>,<code>Key</code>) such that <code>Value</code> is
  121. <a href="https://boost.org/sgi/stl/Assignable.html"><code>Assignable</code></a>
  122. and implicitly convertible to <code>const Key&amp;</code>, to an
  123. <a href="https://boost.org/sgi/stl/Assignable.html"><code>Assignable</code></a>
  124. type <code>Entry</code> implicitly convertible to both <code>const Value&amp;</code>
  125. and <code>const Key&amp;</code>.
  126. </li>
  127. <li>The expression <code>Tracking::handle_type</code> (or
  128. <code>Tracking'::handle_type</code> if (b) applies) is an
  129. <a href="../../../mpl/doc/refmanual/lambda-expression.html"><code>MPL Lambda
  130. Expression</code></a>; this expression, when invoked with types
  131. (<code>InternalHandle</code>,<a href="#preliminary"><code>TrackingHelper</code></a>),
  132. with <code>InternalHandle</code> being
  133. <a href="https://boost.org/sgi/stl/Assignable.html"><code>Assignable</code></a>
  134. and providing the nothrow guarantee for copy and assignment,
  135. resolves to an
  136. <a href="https://boost.org/sgi/stl/Assignable.html"><code>Assignable</code></a>
  137. type <code>Handle</code> which also provides the nothrow guarantee for
  138. copy and assignment and is constructible from and implicitly
  139. convertible to <code>InternalHandle</code>.
  140. <code>TrackingHelper</code> is an incomplete type at the time of
  141. invocation of <code>Tracking::handle_type</code>.
  142. </li>
  143. </ul>
  144. <code>Tracking::handle_type</code> is parameterized by a helper that provides
  145. access to some of the functionality of the factory associated to the
  146. tracking policy. This factory's associated entry and handle types are the types
  147. <code>Entry</code> and <code>Handle</code> defined above, respectively.
  148. </p>
  149. <h2><a name="tracking_tag_synopsis">Header
  150. <a href="../../../../boost/flyweight/tracking_tag.hpp"><code>"boost/flyweight/tracking_tag.hpp"</code></a> synopsis</a></h2>
  151. <blockquote><pre>
  152. <span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
  153. <span class=keyword>namespace</span> <span class=identifier>flyweights</span><span class=special>{</span>
  154. <span class=keyword>struct</span> <span class=identifier>tracking_marker</span><span class=special>;</span>
  155. <span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>T</span><span class=special>&gt;</span>
  156. <span class=keyword>struct</span> <span class=identifier>is_tracking</span>
  157. <span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>T</span><span class=special>&gt;</span>
  158. <span class=keyword>struct</span> <span class=identifier>tracking</span><span class=special>;</span>
  159. <span class=special>}</span> <span class=comment>// namespace boost::flyweights</span>
  160. <span class=special>}</span> <span class=comment>// namespace boost</span>
  161. </pre></blockquote>
  162. <h3><a name="is_tracking">Class template <code>is_tracking</code></a></h3>
  163. <p>
  164. Unless specialized by the user, <code>is_tracking&lt;T&gt;::type</code> is
  165. <a href="../../../mpl/doc/refmanual/bool.html"><code>boost::mpl::true_</code></a>
  166. if <code>T</code> is derived from <code>tracking_marker</code>, and it is
  167. <a href="../../../mpl/doc/refmanual/bool.html"><code>boost::mpl::false_</code></a>
  168. otherwise.
  169. </p>
  170. <h3><a name="tracking_construct">Class template <code>tracking</code></a></h3>
  171. <p>
  172. <code>tracking&lt;T&gt;</code> is a syntactic construct meant to indicate
  173. that <code>T</code> is a tracking policy without resorting to the
  174. mechanisms provided by the <code>is_tracking</code> class template.
  175. </p>
  176. <h2><a name="refcounted_fwd_synopsis">Header
  177. <a href="../../../../boost/flyweight/refcounted_fwd.hpp"><code>"boost/flyweight/refcounted_fwd.hpp"</code></a> synopsis</a></h2>
  178. <blockquote><pre>
  179. <span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
  180. <span class=keyword>namespace</span> <span class=identifier>flyweights</span><span class=special>{</span>
  181. <span class=keyword>struct</span> <span class=identifier>refcounted</span><span class=special>;</span>
  182. <span class=special>}</span> <span class=comment>// namespace boost::flyweights</span>
  183. <span class=special>}</span> <span class=comment>// namespace boost</span>
  184. </pre></blockquote>
  185. <p>
  186. <code>refcounted_fwd.hpp</code> forward declares the class
  187. <a href="#refcounted"><code>refcounted</code></a>.
  188. </p>
  189. <h2><a name="refcounted_synopsis">Header
  190. <a href="../../../../boost/flyweight/refcounted.hpp"><code>"boost/flyweight/refcounted.hpp"</code></a> synopsis</a></h2>
  191. <h3><a name="refcounted">Class <code>refcounted</code></a></h3>
  192. <p>
  193. <a href="#tracking"><code>Tracking Policy</code></a> providing
  194. <a href="flyweight.html#flyweight"><code>flyweight</code></a>
  195. instantiations with reference counting semantics: when all the flyweight objects
  196. associated to a given value are destroyed, the corresponding entry is
  197. erased from <code>flyweight</code>'s internal
  198. <a href="factories.html#factory">factory</a>.
  199. </p>
  200. <h2><a name="no_tracking_fwd_synopsis">Header
  201. <a href="../../../../boost/flyweight/no_tracking_fwd.hpp"><code>"boost/flyweight/no_tracking_fwd.hpp"</code></a> synopsis</a></h2>
  202. <blockquote><pre>
  203. <span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
  204. <span class=keyword>namespace</span> <span class=identifier>flyweights</span><span class=special>{</span>
  205. <span class=keyword>struct</span> <span class=identifier>no_tracking</span><span class=special>;</span>
  206. <span class=special>}</span> <span class=comment>// namespace boost::flyweights</span>
  207. <span class=special>}</span> <span class=comment>// namespace boost</span>
  208. </pre></blockquote>
  209. <p>
  210. <code>no_tracking_fwd.hpp</code> forward declares the class
  211. <a href="#no_tracking"><code>no_tracking</code></a>.
  212. </p>
  213. <h2><a name="no_tracking_synopsis">Header
  214. <a href="../../../../boost/flyweight/no_tracking.hpp"><code>"boost/flyweight/no_tracking.hpp"</code></a> synopsis</a></h2>
  215. <h3><a name="no_tracking">Class <code>no_tracking</code></a></h3>
  216. <p>
  217. Null <a href="#tracking"><code>Tracking Policy</code></a>: elements inserted
  218. into <code>flyweight</code>'s internal <a href="factories.html#factory">factory</a>
  219. are not erased until program termination.
  220. </p>
  221. <hr>
  222. <div class="prev_link"><a href="locking.html"><img src="../prev.gif" alt="locking policies" border="0"><br>
  223. Locking policies
  224. </a></div>
  225. <div class="up_link"><a href="index.html"><img src="../up.gif" alt="Boost.Flyweight reference" border="0"><br>
  226. Boost.Flyweight reference
  227. </a></div>
  228. <div class="next_link"><a href="../performance.html"><img src="../next.gif" alt="performance" border="0"><br>
  229. Performance
  230. </a></div><br clear="all" style="clear: all;">
  231. <br>
  232. <p>Revised April 24th 2019</p>
  233. <p>&copy; Copyright 2006-2019 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;oz.
  234. Distributed under the Boost Software
  235. License, Version 1.0. (See accompanying file <a href="../../../../LICENSE_1_0.txt">
  236. LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
  237. http://www.boost.org/LICENSE_1_0.txt</a>)
  238. </p>
  239. </body>
  240. </html>