2010-06-14 04:59:29 +02:00
|
|
|
/* sbt -- Simple Build Tool
|
|
|
|
|
* Copyright 2009 Mark Harrah
|
|
|
|
|
*/
|
|
|
|
|
package sbt
|
2009-08-16 20:29:08 +02:00
|
|
|
|
|
|
|
|
import java.io.{InputStream,OutputStream}
|
|
|
|
|
|
2010-06-14 04:59:29 +02:00
|
|
|
import Types._
|
2009-08-16 20:29:08 +02:00
|
|
|
class HNilInputCache extends NoInputCache[HNil]
|
2010-06-14 04:59:29 +02:00
|
|
|
class HConsInputCache[H,T <: HList](val headCache: InputCache[H], val tailCache: InputCache[T]) extends InputCache[H :+: T]
|
2009-08-16 20:29:08 +02:00
|
|
|
{
|
2010-06-14 04:59:29 +02:00
|
|
|
def uptodate(in: H :+: T)(cacheStream: InputStream) =
|
2009-08-16 20:29:08 +02:00
|
|
|
{
|
2009-12-12 00:56:09 +01:00
|
|
|
val headResult = headCache.uptodate(in.head)(cacheStream)
|
|
|
|
|
val tailResult = tailCache.uptodate(in.tail)(cacheStream)
|
2009-08-16 20:29:08 +02:00
|
|
|
new CacheResult
|
|
|
|
|
{
|
2009-12-12 00:56:09 +01:00
|
|
|
val uptodate = headResult.uptodate && tailResult.uptodate
|
2009-08-16 20:29:08 +02:00
|
|
|
def update(outputStream: OutputStream) =
|
|
|
|
|
{
|
|
|
|
|
headResult.update(outputStream)
|
|
|
|
|
tailResult.update(outputStream)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-06-14 04:59:29 +02:00
|
|
|
def force(in: H :+: T)(cacheStream: OutputStream) =
|
2009-08-16 20:29:08 +02:00
|
|
|
{
|
|
|
|
|
headCache.force(in.head)(cacheStream)
|
|
|
|
|
tailCache.force(in.tail)(cacheStream)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class HNilOutputCache extends NoOutputCache[HNil](HNil)
|
2010-06-14 04:59:29 +02:00
|
|
|
class HConsOutputCache[H,T <: HList](val headCache: OutputCache[H], val tailCache: OutputCache[T]) extends OutputCache[H :+: T]
|
2009-08-16 20:29:08 +02:00
|
|
|
{
|
|
|
|
|
def loadCached(cacheStream: InputStream) =
|
|
|
|
|
{
|
|
|
|
|
val head = headCache.loadCached(cacheStream)
|
|
|
|
|
val tail = tailCache.loadCached(cacheStream)
|
|
|
|
|
HCons(head, tail)
|
|
|
|
|
}
|
2010-06-14 04:59:29 +02:00
|
|
|
def update(out: H :+: T)(cacheStream: OutputStream)
|
2009-08-16 20:29:08 +02:00
|
|
|
{
|
|
|
|
|
headCache.update(out.head)(cacheStream)
|
|
|
|
|
tailCache.update(out.tail)(cacheStream)
|
|
|
|
|
}
|
|
|
|
|
}
|