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