comparison trunk/src/docgen/graphutils/writer.d @ 729:ec8dd7b8bf0c

Updated graph type.
author Jari-Matti M?kel? <jmjm@iki.fi>
date Sun, 03 Feb 2008 19:43:53 +0200
parents db7e27b5c180
children
comparison
equal deleted inserted replaced
728:41cad5ca4863 729:ec8dd7b8bf0c
8 public import docgen.graphutils.primitives; 8 public import docgen.graphutils.primitives;
9 public import docgen.page.writer; 9 public import docgen.page.writer;
10 debug import tango.io.Stdout; 10 debug import tango.io.Stdout;
11 11
12 interface GraphWriter { 12 interface GraphWriter {
13 void generateDepGraph(Vertex[] vertices, Edge[] edges, OutputStream imageFile); 13 void generateDepGraph(DepGraph depGraph, OutputStream imageFile);
14 } 14 }
15 15
16 interface GraphWriterFactory : WriterFactory { 16 interface GraphWriterFactory : WriterFactory {
17 GraphWriter createGraphWriter(PageWriter writer, GraphFormat outputFormat); 17 GraphWriter createGraphWriter(PageWriter writer, GraphFormat outputFormat);
18 } 18 }
19 19
20 interface CachingGraphWriterFactory : GraphWriterFactory { 20 interface CachingGraphWriterFactory : GraphWriterFactory {
21 GraphCache graphCache(); 21 GraphCache graphCache();
22 } 22 }
23 23 /+
24 /** 24 /**
25 * Marks all cycles in the graph. 25 * Marks all cycles in the graph.
26 * 26 *
27 * May have bugs, but is a bit simpler than the previous version. 27 * May have bugs, but is a bit simpler than the previous version.
28 */ 28 */
65 if (edge.cycleType == CycleType.Unspecified) { 65 if (edge.cycleType == CycleType.Unspecified) {
66 visit(edge); 66 visit(edge);
67 debug Stderr("*\n"); 67 debug Stderr("*\n");
68 } 68 }
69 } 69 }
70 +/
70 71
71 abstract class AbstractGraphWriter : AbstractWriter!(GraphWriterFactory), GraphWriter { 72 abstract class AbstractGraphWriter : AbstractWriter!(GraphWriterFactory), GraphWriter {
72 protected: 73 protected:
73 74
74 PageWriter writer; 75 PageWriter writer;
82 } 83 }
83 84
84 class DefaultGraphCache : GraphCache { 85 class DefaultGraphCache : GraphCache {
85 private: 86 private:
86 87
87 char[][Object[]][Object[]][GraphFormat] m_graphCache; 88 char[][Object][GraphFormat] m_graphCache;
88 89
89 public: 90 public:
90 91
91 char[] getCachedGraph(Object[] vertices, Object[] edges, GraphFormat format) { 92 char[] getCachedGraph(Object graph, GraphFormat format) {
92 debug Stdout("Starting graph lookup\n"); 93 debug Stdout("Starting graph lookup\n");
93 debug Stdout(&vertices, &edges, format).newline; 94 debug Stdout(&graph, format).newline;
94 debug Stdout(&m_graphCache).newline; 95 debug Stdout(&m_graphCache).newline;
95 96
96 auto lookup1 = format in m_graphCache; 97 auto lookup1 = format in m_graphCache;
97 if (lookup1) { 98 if (lookup1) {
98 auto lookup2 = edges in *lookup1; 99 auto lookup2 = graph in *lookup1;
99 if (lookup2) { 100 if (lookup2) {
100 auto lookup3 = vertices in *lookup2; 101 return *lookup2;
101 if (lookup3)
102 return *lookup3;
103 } 102 }
104 } 103 }
105 debug Stdout("Graph cache miss!\n"); 104 debug Stdout("Graph cache miss!\n");
106 return null; 105 return null;
107 } 106 }
108 107
109 void setCachedGraph(Object[] vertices, Object[] edges, GraphFormat format, char[] 108 void setCachedGraph(Object graph, GraphFormat format, char[]
110 contents) { 109 contents) {
111 m_graphCache[format][edges][vertices] = contents; 110 m_graphCache[format][graph] = contents;
112 debug Stdout("Graph cache updated!\n"); 111 debug Stdout("Graph cache updated!\n");
113 } 112 }
114 } 113 }