This GitLab instance reached the end of its service life. It won't be possible to create new users or projects.

Please read the deprecation notice for more information concerning the deprecation timeline

Visit migration.git.tu-berlin.de (internal network only) to import your old projects to the new GitLab platform 📥

AlgorithmLogging.scala 871 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
package de.bbisping.coupledsim.algo

import de.bbisping.coupledsim.util.Relation
import scala.collection.mutable.ListBuffer
import de.bbisping.coupledsim.util.Coloring

trait AlgorithmLogging[S, A, L] {
  
  private val log = ListBuffer[() => AlgorithmLogging.LogEntry[S, A, L]]()
  
  def logRelation(rel: Relation[S], comment: String) = {
    if (AlgorithmLogging.loggingActive && log.size < AlgorithmLogging.maxLogLength) {
      log += (() => AlgorithmLogging.LogRelation[S, A, L](rel, comment))
    }
  }
  
  def getReplay() = log toList
}

object AlgorithmLogging {
  
  abstract class LogEntry[S, A, L]
  
  case class LogRelation[S, A, L](rel: Relation[S], comment: String) extends LogEntry[S, A, L]
  //case class LogColoring[S, A, L](colors: Coloring[S], comment: String) extends LogEntry[S, A, L]
  
  var loggingActive = true
  
  var maxLogLength = 100
  
}