1<HTML> 2<!-- 3 Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 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>Boost Graph Library: property_writer</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<H1> 19<pre> 20property_writer<PropertyMap, OutputIterator, EventTag> 21</pre> 22</H1> 23 24This is an <a href="./EventVisitor.html">EventVisitor</a> that can be 25used to output the property of a vertex or edge at some event-point 26within an algorithm. 27 28<p> 29<tt>property_writer</tt> can be used with graph algorithms by 30wrapping it with the algorithm-specific adaptor, such as <a 31href="./bfs_visitor.html"><tt>bfs_visitor</tt></a> and <a 32href="./dfs_visitor.html"><tt>dfs_visitor</tt></a>. Also, this event 33visitor can be combined with other event visitors using 34<tt>std::pair</tt> to form an EventVisitorList. 35 36<h3>Example</h3> 37 38The following is an excerpt from <a 39href="../example/dave.cpp"><tt>examples/dave.cpp</tt></a>. 40 41<pre> 42 std::ostream_iterator<int> cout_int(std::cout, " "); 43 std::ostream_iterator<char> cout_char(std::cout, " "); 44 45 boost::breadth_first_search 46 (G, vertex(a, G), make_bfs_visitor( 47 std::make_pair(write_property(name, cout_char, on_discover_vertex()), 48 std::make_pair(write_property(distance.begin(), cout_int, 49 on_discover_vertex()), 50 std::make_pair(print_edge(name, std::cout, on_examine_edge()), 51 print_endl(std::cout, on_finish_vertex() 52 )))))); 53</pre> 54 55<h3>Model of</h3> 56 57<a href="./EventVisitor.html">EventVisitor</a> 58 59 60<H3>Where Defined</H3> 61 62<P> 63<a href="../../../boost/graph/visitors.hpp"> 64<TT>boost/graph/visitors.hpp</TT></a> 65 66<H3>Template Parameters</H3> 67 68<P> 69<TABLE border> 70<TR> 71<th>Parameter</th><th>Description</th><th>Default</th> 72</tr> 73 74<TR><TD><TT>PropertyMap</TT></TD> 75<TD> 76A <a 77href="../../property_map/doc/ReadablePropertyMap.html">ReadablePropertyMap</a> 78where the <tt>key_type</tt> is the vertex descriptor type or edge 79descriptor of the graph (depending on the kind of event tag) and 80the <tt>value_type</tt> of the property is convertible 81to the <tt>value_type</tt> of the <tt>OutputIterator</tt>. 82</TD> 83<TD> </TD> 84</TR> 85 86<TR><TD><TT>OutputIterator</TT></TD> 87<TD> 88The iterator type used to write out the property values, which must be 89a model of <a 90href="http://www.boost.org/sgi/stl/OutputIterator.html">OutputIterator</a>. 91</TD> 92<TD> </TD> 93</TR> 94 95 96<TR><TD><TT>EventTag</TT></TD> 97<TD> 98The tag to specify when the <tt>property_writer</tt> should be 99applied during the graph algorithm. 100</TD> 101<TD> </TD> 102</TR> 103 104</table> 105 106<H2>Associated Types</H2> 107 108<table border> 109 110<tr> 111<th>Type</th><th>Description</th> 112</tr> 113 114<tr> 115<td><tt>property_writer::event_filter</tt></td> 116<td> 117This will be the same type as the template parameter <tt>EventTag</tt>. 118</td> 119</tr> 120 121</table> 122 123<h3>Member Functions</h3> 124 125<p> 126 127<table border> 128<tr> 129<th>Member</th><th>Description</th> 130</tr> 131 132<tr> 133<td><tt> 134property_writer(PropertyMap pa, OutputIterator out); 135</tt></td> 136<td> 137Construct a property writer object with the property map 138<tt>pa</tt> and output iterator <tt>out</tt>. 139</td> 140</tr> 141 142<tr> 143<td><tt> 144template <class X, class Graph><br> 145void operator()(X x, const Graph& g); 146</tt></td> 147<td> 148This writes the property value for <tt>x</tt> to the output iterator.<br> 149<tt>*out++ = get(pa, x);</tt> 150</td> 151</tr> 152 153</table> 154 155<h3>Non-Member Functions</h3> 156 157<table border> 158<tr> 159<th>Function</th><th>Description</th> 160</tr> 161 162<tr><td><tt> 163template <class PropertyMap, class OutputIterator, class Tag><br> 164property_writer<PropertyMap, OutputIterator, Tag><br> 165write_property(PropertyMap pa, OutputIterator out, Tag); 166</tt></td><td> 167A convenient way to create a <tt>property_writer</tt>. 168</td></tr> 169 170</table> 171 172<h3>See Also</h3> 173 174<a href="./visitor_concepts.html">Visitor concepts</a> 175<p> 176The following are other event visitors: <a 177<a href="./distance_recorder.html"><tt>distance_recorder</tt></a>, 178<a href="./predecessor_recorder.html"><tt>predecessor_recorder</tt></a>, 179and <a href="./time_stamper.html"><tt>time_stamper</tt></a>. 180 181 182<br> 183<HR> 184<TABLE> 185<TR valign=top> 186<TD nowrap>Copyright © 2000-2001</TD><TD> 187<A HREF="http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek</A>, 188Indiana University (<A 189HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br> 190<A HREF="http://www.boost.org/people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)<br> 191<A HREF="https://homes.cs.washington.edu/~al75">Andrew Lumsdaine</A>, 192Indiana University (<A 193HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>) 194</TD></TR></TABLE> 195 196</BODY> 197</HTML> 198<!-- LocalWords: PropertyMap OutputIterator EventTag EventVisitor bfs dfs EventVisitorList 199 --> 200<!-- LocalWords: cpp num dtime ftime int WritablePropertyMap map 201 --> 202<!-- LocalWords: const Siek Univ Quan Lumsdaine 203 --> 204