[12] | 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>LvaluePropertyMap</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 | <H2><A NAME="concept:LvaluePropertyMap"></A> |
---|
| 23 | LvaluePropertyMap |
---|
| 24 | </H2> |
---|
| 25 | |
---|
| 26 | The LvaluePropertyMap provides an interface for accessing a |
---|
| 27 | reference to a property object (instead of a copy of the object as in |
---|
| 28 | the <TT>get()</TT> function required by <a |
---|
| 29 | href="./ReadablePropertyMap.html">ReadablePropertyMap</a>). An |
---|
| 30 | LvaluePropertyMap can be <I>mutable</I> or |
---|
| 31 | <I>non-mutable</I>. The mutable LvaluePropertyMap returns a |
---|
| 32 | reference whereas the non-mutable returns a const reference. |
---|
| 33 | |
---|
| 34 | <H3>Refinement of</H3> |
---|
| 35 | |
---|
| 36 | <a href="./ReadablePropertyMap.html">ReadablePropertyMap</a> |
---|
| 37 | for non-mutable or <a href="./ReadWritePropertyMap.html">ReadWritePropertyMap</a> for mutable property map. |
---|
| 38 | |
---|
| 39 | <h3>Notation</h3> |
---|
| 40 | |
---|
| 41 | <Table> |
---|
| 42 | <TR> |
---|
| 43 | <TD><tt>PMap</tt></TD> |
---|
| 44 | <TD>A type that is a model of LvaluePropertyMap.</TD> |
---|
| 45 | </TR> |
---|
| 46 | <TR> |
---|
| 47 | <TD><tt>pmap</tt></TD> |
---|
| 48 | <TD>An object of type <tt>PMap</tt>.</td> |
---|
| 49 | </TR> |
---|
| 50 | <TR> |
---|
| 51 | <TD><tt>key</tt></TD> |
---|
| 52 | <TD>An object of type <tt>boost::property_traits<PMap>::key_type</tt>.</td> |
---|
| 53 | </TR> |
---|
| 54 | |
---|
| 55 | </table> |
---|
| 56 | |
---|
| 57 | |
---|
| 58 | <h3>Associated Types</h3> |
---|
| 59 | |
---|
| 60 | <table border> |
---|
| 61 | |
---|
| 62 | <tr> |
---|
| 63 | <td>Reference Type</td> |
---|
| 64 | <td><TT>boost::property_traits<PMap>::reference</TT></td> |
---|
| 65 | <td> |
---|
| 66 | The reference type, which must be a reference or const reference to |
---|
| 67 | the value typeof the property map. |
---|
| 68 | </td> |
---|
| 69 | </tr> |
---|
| 70 | |
---|
| 71 | <tr> |
---|
| 72 | <td>Property Map Category |
---|
| 73 | <td><TT>boost::property_traits<PMap>::category</TT></td> |
---|
| 74 | <td> |
---|
| 75 | The category of the property: a type convertible to |
---|
| 76 | <TT>boost::lvalue_property_map_tag</TT>. |
---|
| 77 | </td> |
---|
| 78 | </tr> |
---|
| 79 | |
---|
| 80 | </table> |
---|
| 81 | |
---|
| 82 | <h3>Valid Expressions</h3> |
---|
| 83 | |
---|
| 84 | <table border> |
---|
| 85 | <tr> |
---|
| 86 | <th>Name</th><th>Expression</th><th>Return Type</th><th>Description</th> |
---|
| 87 | </tr> |
---|
| 88 | |
---|
| 89 | |
---|
| 90 | <tr> |
---|
| 91 | <td>Access Property Value </td> |
---|
| 92 | <TD><TT>pmap[key]</TT></TD> |
---|
| 93 | <TD> |
---|
| 94 | <TT>value_type&</TT> for mutable, <TT>const value_type&</TT> |
---|
| 95 | otherwise. |
---|
| 96 | </TD> |
---|
| 97 | <TD>Obtain a reference to the property identified by <TT>key</TT>.</TD> |
---|
| 98 | </TR> |
---|
| 99 | </TABLE> |
---|
| 100 | |
---|
| 101 | <h3>Concept Checking Class</h3> |
---|
| 102 | |
---|
| 103 | <pre> template <class PMap, class Key> |
---|
| 104 | struct LvaluePropertyMapConcept |
---|
| 105 | { |
---|
| 106 | typedef typename property_traits<PMap>::category Category; |
---|
| 107 | typedef boost::lvalue_property_map_tag LvalueTag; |
---|
| 108 | typedef const typename property_traits<PMap>::value_type& const_reference; |
---|
| 109 | void constraints() { |
---|
| 110 | function_requires< ReadWritePropertyMapConcept<PMap, Key> >(); |
---|
| 111 | function_requires< ConvertibleConcept<Category, LvalueTag> >(); |
---|
| 112 | |
---|
| 113 | const_reference ref = pmap[k]; |
---|
| 114 | } |
---|
| 115 | PMap pmap; |
---|
| 116 | Key k; |
---|
| 117 | }; |
---|
| 118 | |
---|
| 119 | template <class PMap, class Key> |
---|
| 120 | struct Mutable_LvaluePropertyMapConcept |
---|
| 121 | { |
---|
| 122 | typedef typename property_traits<PMap>::category Category; |
---|
| 123 | typedef boost::lvalue_property_map_tag LvalueTag; |
---|
| 124 | typedef typename property_traits<PMap>::value_type& reference; |
---|
| 125 | void constraints() { |
---|
| 126 | function_requires< ReadWritePropertyMapConcept<PMap, Key> >(); |
---|
| 127 | function_requires<ConvertibleConcept<Category, LvalueTag> >(); |
---|
| 128 | |
---|
| 129 | reference ref = pmap[k]; |
---|
| 130 | } |
---|
| 131 | PMap pmap; |
---|
| 132 | Key k; |
---|
| 133 | };</pre> |
---|
| 134 | |
---|
| 135 | <h3>See Also</h3> |
---|
| 136 | |
---|
| 137 | <a href="./property_map.html">Property map concepts</a> |
---|
| 138 | |
---|
| 139 | |
---|
| 140 | <br> |
---|
| 141 | <HR> |
---|
| 142 | <TABLE> |
---|
| 143 | <TR valign=top> |
---|
| 144 | <TD nowrap>Copyright © 2000</TD><TD> |
---|
| 145 | <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>) |
---|
| 146 | </TD></TR></TABLE> |
---|
| 147 | |
---|
| 148 | </BODY> |
---|
| 149 | </HTML> |
---|