ReadablePropertyMap.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <HTML>
  2. <!--
  3. Copyright (c) Jeremy Siek 2000
  4. Distributed under the Boost Software License, Version 1.0.
  5. (See accompanying file LICENSE_1_0.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. -->
  8. <Head>
  9. <Title>Readable Property Map</Title>
  10. <BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
  11. ALINK="#ff0000">
  12. <IMG SRC="../../../boost.png"
  13. ALT="C++ Boost" width="277" height="86">
  14. <BR Clear>
  15. <H2><A NAME="concept:ReadablePropertyMap"></A>
  16. Readable Property Map
  17. </H2>
  18. A Readable Property Map provides read-access to the value associated with a given key via a call to the <tt>get()</tt> function.
  19. The return type of the <tt>get()</tt>function is either the <tt>value_type</tt> of the property map or a (const or non-const) reference to that type.
  20. <h3>Refinement of</h3>
  21. <a href="../../utility/CopyConstructible.html">Copy Constructible</a>
  22. <h3>Notation</h3>
  23. <Table>
  24. <TR>
  25. <TD><tt>PMap</tt></TD>
  26. <TD>A type that is a model of Readable Property Map.</TD>
  27. </TR>
  28. <TR>
  29. <TD><tt>pmap</tt></TD>
  30. <TD>An object of type <tt>PMap</tt>.</td>
  31. </TR>
  32. <TR>
  33. <TD><tt>key</tt></TD>
  34. <TD>An object of type <tt>boost::property_traits&lt;PMap&gt;::key_type</tt>.</td>
  35. </TR>
  36. </table>
  37. <h3>Associated Types</h3>
  38. <table border>
  39. <tr>
  40. <td>Value Type</td>
  41. <td><TT>boost::property_traits&lt;PMap&gt;::value_type</TT></td>
  42. <td>The type of the property.</td>
  43. </tr>
  44. <tr>
  45. <td>Reference Type</td>
  46. <td><TT>boost::property_traits&lt;PMap&gt;::reference</TT></td>
  47. <td>
  48. A type that is convertible to the value type.
  49. </td>
  50. </tr>
  51. <tr>
  52. <td>Key Type</td>
  53. <td><TT>boost::property_traits&lt;PMap&gt;::key_type</TT></td>
  54. <td>
  55. The type of the key object used to look up the property. The property
  56. map may be templated on the key type, in which case this
  57. typedef can be <TT>void</TT>.
  58. </td>
  59. </tr>
  60. <tr>
  61. <td>Property Map Category</td>
  62. <td><TT>boost::property_traits&lt;PMap&gt;::category</TT></td>
  63. <td>
  64. The category of the property: a type convertible to
  65. <TT>readable_property_map_tag</TT>.
  66. </td>
  67. </tr>
  68. </table>
  69. <h3>Valid Expressions</h3>
  70. <table border>
  71. <tr>
  72. <th>Name</th><th>Expression</th><th>Return Type</th><th>Description</th>
  73. </tr>
  74. <tr>
  75. <td>Get Property Value </td>
  76. <TD><TT>get(pmap, key)</TT></TD>
  77. <TD><TT>reference</TT></TD>
  78. <TD>Lookup the value associated with <TT>key</TT>.</TD>
  79. </TR>
  80. </TABLE>
  81. <h3>Concept Checking Class</h3>
  82. <pre> template &lt;class PMap, class Key&gt;
  83. struct ReadablePropertyMapConcept
  84. {
  85. typedef typename property_traits&lt;PMap&gt;::key_type key_type;
  86. typedef typename property_traits&lt;PMap&gt;::category Category;
  87. typedef boost::readable_property_map_tag ReadableTag;
  88. void constraints() {
  89. function_requires&lt; ConvertibleConcept&lt;Category, ReadableTag&gt; &gt;();
  90. val = get(pmap, k);
  91. }
  92. PMap pmap;
  93. Key k;
  94. typename property_traits&lt;PMap&gt;::value_type val;
  95. };</pre>
  96. <h3>See Also</h3>
  97. <a href="./property_map.html">Property map concepts</a>
  98. <h3>Design Notes</h3>
  99. At various times the name &quot;read-only&quot; was considered for
  100. this concept. However, that name is inappropriate because concepts are
  101. inherently positive, not negative. This becomes obvious when we define
  102. the Read Write Property Map, which refines both the Readable Property
  103. Map and the Writable Property Map concept. It would not make much
  104. sense to combine &quot;read-only&quot; and &quot;write-only&quot;
  105. concepts!
  106. <br>
  107. <HR>
  108. <TABLE>
  109. <TR valign=top>
  110. <TD nowrap>Copyright &copy 2000</TD><TD>
  111. <a HREF="http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek</a>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)
  112. </TD></TR></TABLE>
  113. </BODY>
  114. </HTML>