2009-08-16 20:29:08 +02:00
|
|
|
package xsbt
|
|
|
|
|
|
|
|
|
|
import java.io.{InputStream,OutputStream}
|
|
|
|
|
|
2009-12-12 00:56:09 +01:00
|
|
|
import HLists._
|
2009-08-16 20:29:08 +02:00
|
|
|
class HNilInputCache extends NoInputCache[HNil]
|
|
|
|
|
class HConsInputCache[H,T <: HList](val headCache: InputCache[H], val tailCache: InputCache[T]) extends InputCache[HCons[H,T]]
|
|
|
|
|
{
|
|
|
|
|
def uptodate(in: HCons[H,T])(cacheStream: InputStream) =
|
|
|
|
|
{
|
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)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
def force(in: HCons[H,T])(cacheStream: OutputStream) =
|
|
|
|
|
{
|
|
|
|
|
headCache.force(in.head)(cacheStream)
|
|
|
|
|
tailCache.force(in.tail)(cacheStream)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class HNilOutputCache extends NoOutputCache[HNil](HNil)
|
|
|
|
|
class HConsOutputCache[H,T <: HList](val headCache: OutputCache[H], val tailCache: OutputCache[T]) extends OutputCache[HCons[H,T]]
|
|
|
|
|
{
|
|
|
|
|
def loadCached(cacheStream: InputStream) =
|
|
|
|
|
{
|
|
|
|
|
val head = headCache.loadCached(cacheStream)
|
|
|
|
|
val tail = tailCache.loadCached(cacheStream)
|
|
|
|
|
HCons(head, tail)
|
|
|
|
|
}
|
|
|
|
|
def update(out: HCons[H,T])(cacheStream: OutputStream)
|
|
|
|
|
{
|
|
|
|
|
headCache.update(out.head)(cacheStream)
|
|
|
|
|
tailCache.update(out.tail)(cacheStream)
|
|
|
|
|
}
|
|
|
|
|
}
|