PropertyWriter problem - how to handle a boost::shared_ptr type
I have the following graph:
typedef property< vertex_index_t, uint32_t,
property< vertex_name_t, boost::shared_ptr<Component> > >
VertexProperty;
typedef adjacency_list &, void*
const&)'
graph_test2.cpp:49: error: candidates are: void
Component_Writer::operator()(std::ostream&, const
boost::shared_ptr<Component>&) const Compilation exited abnormally with code 1 at Mon Nov 8 00:15:3
Stephen
--
Email: storri@torri.org
On Nov 8, 2004, at 12:16 AM, Stephen torri wrote:
I have the following graph:
typedef property< vertex_index_t, uint32_t, property< vertex_name_t, boost::shared_ptr<Component> > > VertexProperty;
typedef adjacency_list
// VertexProperties Graph_Type; When I looked at the documentation I did not see an example which used a boost::shared_ptr to store information at the vertex. Here is my attempt at writing a PropertyWriter. I cannot figure out how to write the 2nd function argument type:
class Component_Writer { public: void operator()(std::ostream& out, const boost::shared_ptr<Component> obj) const { out << "[label=\"" << obj_ptr->get_Name() << "\n" << obj_ptr->get_ID() << "\"]"; } };
A property writer is passed the output stream and the descriptor, so
you want to write Component_Writer like so:
class Component_Writer {
public:
typedef boost::graph_traits
On Mon, 2004-11-08 at 11:32, Doug Gregor wrote:
A property writer is passed the output stream and the descriptor, so you want to write Component_Writer like so:
class Component_Writer { public: typedef boost::graph_traits
::vertex_descriptor Vertex_Type; Component_Writer(const Graph_Type& g) : g(g) {}
void operator()(std::ostream& out, Vertex_Type v) { boost::shared_ptr<Component> obj_ptr = get(vertex_name, g, v); // code from before... } };
Doug
So if I store the Component in the Vertex by value instead of within a
boost::shared_ptr then I would write the Component_Writer as:
class Component_Writer {
public:
typedef boost::graph_traits
On Mon, 2004-11-08 at 11:32, Doug Gregor wrote:
A property writer is passed the output stream and the descriptor, so you want to write Component_Writer like so:
class Component_Writer { public: typedef boost::graph_traits
::vertex_descriptor Vertex_Type; Component_Writer(const Graph_Type& g) : g(g) {}
void operator()(std::ostream& out, Vertex_Type v) { boost::shared_ptr<Component> obj_ptr = get(vertex_name, g, v); // code from before... } };
Ignore previous email. My graph stores the parent type, Component, while
the actual type is either A or B. So my ability to store them by the
Component type alone will not work since the class contains a pure
virtual function.
Its still balking at compile time. I have changed the Component_Writer
but I get the following compile error. The file is attached.
Stephen
------------------
g++ -g -Wall -o graph_test2 graph_test2.cpp
/usr/include/boost/graph/graphviz.hpp: In function `void
boost::write_graphviz(std::ostream&, const Graph&,
VertexPropertiesWriter,
EdgePropertiesWriter, GraphPropertiesWriter) [with Graph =
boost::adjacency_list &, void*
const&)'
graph_test2.cpp:260: error: candidates are: void
Component_Writer::operator()(std::ostream&, void*&) const --
Email: storri@torri.org
On Nov 8, 2004, at 1:10 PM, Stephen torri wrote:
Its still balking at compile time. I have changed the Component_Writer but I get the following compile error. The file is attached.
You changed the "Vertex_Type v" to "Vertex_Type& v". You need to use either the former (copying vertex descriptors is cheap) or make that a reference to const Vertex_Type. Doug
participants (2)
-
Doug Gregor
-
Stephen torri