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