equal
deleted
inserted
replaced
152 return; |
152 return; |
153 } |
153 } |
154 } |
154 } |
155 private: |
155 private: |
156 bool escaped; |
156 bool escaped; |
|
157 }; |
|
158 |
|
159 class GUIWriter { |
|
160 public: |
|
161 virtual void write(std::ostream& os) = 0; |
157 }; |
162 }; |
158 |
163 |
159 |
164 |
160 /// \brief The graph writer class. |
165 /// \brief The graph writer class. |
161 /// |
166 /// |
236 /// |
241 /// |
237 /// Construct a new GraphWriter. It writes from the given map, |
242 /// Construct a new GraphWriter. It writes from the given map, |
238 /// it constructs the given map and it use the given writer as the |
243 /// it constructs the given map and it use the given writer as the |
239 /// default skipper. |
244 /// default skipper. |
240 GraphWriter(std::ostream& _os, const Graph& _graph) |
245 GraphWriter(std::ostream& _os, const Graph& _graph) |
241 : os(_os), graph(_graph) {} |
246 : gui_writer(0), os(_os), graph(_graph){} |
242 |
247 |
243 |
248 |
244 /// \brief Destruct the graph writer. |
249 /// \brief Destruct the graph writer. |
245 /// |
250 /// |
246 /// Destruct the graph writer. |
251 /// Destruct the graph writer. |
314 /// |
319 /// |
315 /// Add a new labeled edge writer for the writer. |
320 /// Add a new labeled edge writer for the writer. |
316 GraphWriter& writeEdge(std::string name, const Edge& edge) { |
321 GraphWriter& writeEdge(std::string name, const Edge& edge) { |
317 edge_writers.push_back(make_pair(name, edge)); |
322 edge_writers.push_back(make_pair(name, edge)); |
318 return *this; |
323 return *this; |
|
324 } |
|
325 |
|
326 GraphWriter& writeGUI(const GUIWriter& writer) { |
|
327 gui_writer = &writer; |
319 } |
328 } |
320 |
329 |
321 /// \brief Executes the writer commands. |
330 /// \brief Executes the writer commands. |
322 /// |
331 /// |
323 /// Executes the writer commands. |
332 /// Executes the writer commands. |
326 WriterBase<Edge>* edgeWriter = 0; |
335 WriterBase<Edge>* edgeWriter = 0; |
327 writeNodeSet(nodeWriter); |
336 writeNodeSet(nodeWriter); |
328 writeEdgeSet(nodeWriter, edgeWriter); |
337 writeEdgeSet(nodeWriter, edgeWriter); |
329 writeNodes(nodeWriter); |
338 writeNodes(nodeWriter); |
330 writeEdges(edgeWriter); |
339 writeEdges(edgeWriter); |
|
340 writeGUI(); |
331 os << "@end" << std::endl; |
341 os << "@end" << std::endl; |
332 } |
342 } |
333 |
343 |
334 private: |
344 private: |
335 |
345 |
431 edgeWriter->write(os, edge_writers[i].second); |
441 edgeWriter->write(os, edge_writers[i].second); |
432 os << std::endl; |
442 os << std::endl; |
433 } |
443 } |
434 } |
444 } |
435 |
445 |
|
446 void writeGUI() { |
|
447 if (gui_writer) { |
|
448 os << "@gui" << std::endl; |
|
449 gui_writer->write(os); |
|
450 } |
|
451 } |
436 |
452 |
437 |
453 |
438 |
454 |
439 typedef std::vector< std::pair<std::string, WriterBase<Node>*> > |
455 typedef std::vector< std::pair<std::string, WriterBase<Node>*> > |
440 NodeMapWriters; |
456 NodeMapWriters; |
447 typedef std::vector<std::pair<std::string, Node> > NodeWriters; |
463 typedef std::vector<std::pair<std::string, Node> > NodeWriters; |
448 NodeWriters node_writers; |
464 NodeWriters node_writers; |
449 |
465 |
450 typedef std::vector<std::pair<std::string, Edge> > EdgeWriters; |
466 typedef std::vector<std::pair<std::string, Edge> > EdgeWriters; |
451 EdgeWriters edge_writers; |
467 EdgeWriters edge_writers; |
|
468 |
|
469 GUIWriter* gui_writer; |
452 |
470 |
453 std::ostream& os; |
471 std::ostream& os; |
454 const Graph& graph; |
472 const Graph& graph; |
455 |
473 |
456 }; |
474 }; |