2017-06-23 16:37:00 +03:00
|
|
|
package inr.numass.viewer
|
|
|
|
|
|
|
|
import hep.dataforge.data.Data
|
|
|
|
import hep.dataforge.meta.Meta
|
|
|
|
import hep.dataforge.tables.Table
|
2017-07-17 17:04:39 +03:00
|
|
|
import inr.numass.data.api.NumassPoint
|
|
|
|
import inr.numass.data.api.NumassSet
|
2017-06-23 16:37:00 +03:00
|
|
|
import java.util.stream.Collectors
|
|
|
|
import java.util.stream.Stream
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Cached numass data
|
|
|
|
* Created by darksnake on 23-Jun-17.
|
|
|
|
*/
|
2017-07-17 17:04:39 +03:00
|
|
|
class NumassDataCache(val data: NumassSet): NumassSet {
|
2017-06-23 16:37:00 +03:00
|
|
|
private val cachedDescription: String by lazy { data.description }
|
|
|
|
private val cachedMeta: Meta by lazy { data.meta }
|
2017-07-17 17:04:39 +03:00
|
|
|
private val cachedPoints: List<NumassPoint> by lazy { data.points.collect(Collectors.toList()) }
|
2017-06-23 16:37:00 +03:00
|
|
|
private val hv: Table by lazy { data.hvData.get() }
|
|
|
|
|
|
|
|
|
2017-07-17 17:04:39 +03:00
|
|
|
override fun getPoints(): Stream<NumassPoint> {
|
2017-06-23 16:37:00 +03:00
|
|
|
return cachedPoints.stream();
|
|
|
|
}
|
|
|
|
|
2017-07-17 17:04:39 +03:00
|
|
|
override fun getDescription(): String {
|
|
|
|
return cachedDescription
|
2017-06-23 16:37:00 +03:00
|
|
|
}
|
|
|
|
|
2017-07-17 17:04:39 +03:00
|
|
|
override fun meta(): Meta {
|
|
|
|
return cachedMeta
|
2017-06-23 16:37:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun getName(): String {
|
|
|
|
return data.name;
|
|
|
|
}
|
|
|
|
|
2017-07-17 17:04:39 +03:00
|
|
|
override fun getHvData(): Data<Table> {
|
2017-06-23 16:37:00 +03:00
|
|
|
return Data.buildStatic(hv);
|
|
|
|
}
|
|
|
|
}
|