com.github.charleslzq.facestore.FaceStore.kt Maven / Gradle / Ivy
Show all versions of face-store Show documentation
package com.github.charleslzq.facestore
import org.joda.time.LocalDateTime
/**
* Created by charleslzq on 18-2-28.
*/
interface Meta {
val id: String
val createTime: LocalDateTime
val updateTime: LocalDateTime
}
data class FaceData(val person: P, val faces: List = emptyList())
interface FaceDataType {
val personClass: Class
val faceClass: Class
}
interface ReadOnlyFaceStore {
val dataType: FaceDataType
fun getPersonIds(): List = emptyList()
fun getFaceData(personId: String): FaceData? = null
fun getPerson(personId: String): P? = null
fun getFaceIdList(personId: String): List = emptyList()
fun getFace(personId: String, faceId: String): F? = null
}
interface ReadWriteFaceStore : ReadOnlyFaceStore
{
fun savePerson(person: P) {}
fun saveFace(personId: String, face: F) {}
fun saveFaceData(faceData: FaceData
) {}
fun deleteFaceData(personId: String) {}
fun deleteFace(personId: String, faceId: String) {}
fun clearFace(personId: String) {}
}
interface FaceStoreChangeListener {
fun onPersonUpdate(person: P) {}
fun onFaceUpdate(personId: String, face: F) {}
fun onFaceDataDelete(personId: String) {}
fun onFaceDelete(personId: String, faceId: String) {}
fun onPersonFaceClear(personId: String) {}
}
abstract class CompositeReadWriteFaceStore(
protected val readOnlyStore: ReadOnlyFaceStore
): ReadWriteFaceStore
{
final override val dataType: FaceDataType
= readOnlyStore.dataType
final override fun getPersonIds() = readOnlyStore.getPersonIds()
final override fun getPerson(personId: String) = readOnlyStore.getPerson(personId)
final override fun getFaceData(personId: String) = readOnlyStore.getFaceData(personId)
final override fun getFaceIdList(personId: String) = readOnlyStore.getFaceIdList(personId)
final override fun getFace(personId: String, faceId: String) = readOnlyStore.getFace(personId, faceId)
}