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>WritablePropertyMap</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:WritablePropertyMap"></A> |
---|
24 | Writable Property Map |
---|
25 | </H2> |
---|
26 | |
---|
27 | A Writable Property Map has the capability of setting the value |
---|
28 | object associated with the given key object via the <tt>put()</tt> |
---|
29 | function. |
---|
30 | |
---|
31 | <h3>Refinement of</h3> |
---|
32 | |
---|
33 | <a href="../utility/CopyConstructible.html">Copy Constructible</a> |
---|
34 | |
---|
35 | |
---|
36 | <h3>Notation</h3> |
---|
37 | |
---|
38 | <Table> |
---|
39 | <TR> |
---|
40 | <TD><tt>PMap</tt></TD> |
---|
41 | <TD>A type that is a model of Writable Property Map.</TD> |
---|
42 | </TR> |
---|
43 | <TR> |
---|
44 | <TD><tt>pmap</tt></TD> |
---|
45 | <TD>An object of type <tt>PMap</tt>.</td> |
---|
46 | </TR> |
---|
47 | <TR> |
---|
48 | <TD><tt>key</tt></TD> |
---|
49 | <TD>An object of type <tt>boost::property_traits<PMap>::key_type</tt>.</td> |
---|
50 | </TR> |
---|
51 | <TR> |
---|
52 | <TD><tt>val</tt></TD> |
---|
53 | <TD>An object of type <tt>boost::property_traits<PMap>::value_type</tt>.</td> |
---|
54 | </TR> |
---|
55 | </table> |
---|
56 | |
---|
57 | <h3>Associated Types</h3> |
---|
58 | |
---|
59 | <table border> |
---|
60 | |
---|
61 | <tr> |
---|
62 | <td>Value Type</td> |
---|
63 | <td><TT>boost::property_traits<PMap>::value_type</TT></td> |
---|
64 | <td> |
---|
65 | The type of the property. |
---|
66 | </td> |
---|
67 | </tr> |
---|
68 | |
---|
69 | <tr> |
---|
70 | <td>Key Type</td> |
---|
71 | <td><TT>boost::property_traits<PMap>::key_type</TT></td> |
---|
72 | <td> |
---|
73 | The type of the key object used to look up the property. The property |
---|
74 | map may be templated on the key type, in which case this typedef |
---|
75 | can be <TT>void</TT>. |
---|
76 | </td> |
---|
77 | </tr> |
---|
78 | |
---|
79 | <tr> |
---|
80 | <td>Property Map Category </td> |
---|
81 | <td><TT>boost::property_traits<PMap>::category</TT></td> |
---|
82 | <td> |
---|
83 | The category of the property: a type convertible to |
---|
84 | <TT>writable_property_map_tag</TT>. |
---|
85 | </td> |
---|
86 | </tr> |
---|
87 | |
---|
88 | </table> |
---|
89 | |
---|
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>Put Property Value<a href="#1">[1]</a></td> |
---|
100 | <TD><TT>put(pmap, key, val)</TT></TD> |
---|
101 | <TD><TT>void</TT></TD> |
---|
102 | <TD> |
---|
103 | Assign <TT>val</TT> to the property associated with <TT>k</TT>. |
---|
104 | </TD> |
---|
105 | </TR> |
---|
106 | |
---|
107 | </TABLE> |
---|
108 | |
---|
109 | |
---|
110 | <h3>Notes</h3> |
---|
111 | |
---|
112 | <a name="1">[1]</a> The function <tt>put()</tt> was originally named |
---|
113 | <tt>set()</tt>, but was changed to avoid name conflicts with the |
---|
114 | <tt>std::set</tt> class when using a compiler (Microsoft Visual C++) |
---|
115 | with non-standard name lookup rules. The following example demonstrates |
---|
116 | the problem. |
---|
117 | <pre>#include <set> |
---|
118 | using namespace std; |
---|
119 | namespace boost { |
---|
120 | void set() { } |
---|
121 | }</pre> |
---|
122 | |
---|
123 | |
---|
124 | <h3>Concept Checking Class</h3> |
---|
125 | |
---|
126 | <pre> template <class PMap, class Key> |
---|
127 | struct WritablePropertyMapConcept |
---|
128 | { |
---|
129 | typedef typename property_traits<PMap>::key_type key_type; |
---|
130 | typedef typename property_traits<PMap>::category Category; |
---|
131 | typedef boost::writable_property_map_tag WritableTag; |
---|
132 | void constraints() { |
---|
133 | function_requires< ConvertibleConcept<Category, WritableTag> >(); |
---|
134 | put(pmap, k, val); |
---|
135 | } |
---|
136 | PMap pmap; |
---|
137 | Key k; |
---|
138 | typename property_traits<PMap>::value_type val; |
---|
139 | };</pre> |
---|
140 | |
---|
141 | <h3>See Also</h3> |
---|
142 | |
---|
143 | <a href="./property_map.html">Property map concepts</a> |
---|
144 | |
---|
145 | |
---|
146 | <br> |
---|
147 | <HR> |
---|
148 | <TABLE> |
---|
149 | <TR valign=top> |
---|
150 | <TD nowrap>Copyright © 2000</TD><TD> |
---|
151 | <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>) |
---|
152 | </TD></TR></TABLE> |
---|
153 | |
---|
154 | </BODY> |
---|
155 | </HTML> |
---|