view trunk/src/docgen/graphutils/writers.d @ 459:1b5f1ce09f38

Fix to the image cache, cleaned stuff.
author Jari-Matti M?kel? <jmjm@iki.fi>
date Tue, 30 Oct 2007 16:58:17 +0200
parents 33a4cb255fcc
children db7e27b5c180
line wrap: on
line source

/**
 * Author: Jari-Matti Mäkelä
 * License: GPL3
 */
module docgen.graphutils.writers;

public import docgen.graphutils.writer;
import docgen.graphutils.dotwriter;
import docgen.graphutils.modulepathwriter;
import docgen.graphutils.modulenamewriter;

class DefaultGraphWriterFactory : AbstractWriterFactory, GraphWriterFactory {
  this(DocGenerator generator) {
    super(generator);
  }

  GraphWriter createGraphWriter(PageWriter writer, GraphFormat outputFormat) {
    switch (outputFormat) {
      case GraphFormat.Dot:
        return new DotWriter(this, writer);
      case GraphFormat.ModuleNames:
        return new ModuleNameWriter(this, writer);
      case GraphFormat.ModulePaths:
        return new ModulePathWriter(this, writer);
      default:
        throw new Exception("Graph writer type does not exist!");
    }
  }
}

class DefaultCachingGraphWriterFactory : AbstractWriterFactory, CachingGraphWriterFactory {
  CachingDocGenerator generator;

  this(CachingDocGenerator generator) {
    super(generator);
    this.generator = generator;
  }

  GraphCache graphCache() {
    return generator.graphCache;
  }

  GraphWriter createGraphWriter(PageWriter writer, GraphFormat outputFormat) {
    switch (outputFormat) {
      case GraphFormat.Dot:
        return new CachingDotWriter(this, writer);
      case GraphFormat.ModuleNames:
        return new ModuleNameWriter(this, writer);
      case GraphFormat.ModulePaths:
        return new ModulePathWriter(this, writer);
      default:
        throw new Exception("Graph writer type does not exist!");
    }
  }
}