← back to roto on ba3a.dev

ModelRepository

class ModelRepository(profileFolder: ProfileFolder)

The models of one profile, under its models/ folder: one <action>_<facing>/ folder each, holding model.json and the frames 000.png, 001.png, and so on. A folder that cannot be read fails with a ModelException naming the file.

Constructors

Link copied to clipboard
constructor(profileFolder: ProfileFolder)

Functions

Link copied to clipboard

The content hash of the model called key: SHA-256, in hex, of model.json and then every frame file in order. Any changed pixel or duration changes it; it is the cache-key input for everything derived from the model.

Link copied to clipboard
fun exists(key: String): Boolean

Whether a model called key exists.

Link copied to clipboard
fun keys(): List<String>

The keys of every model that has a model.json, in sorted order.

Link copied to clipboard
fun keysFor(action: String): List<String>

The keys of the models of action that can be read, in sorted order; an unreadable model is left out.

Link copied to clipboard
fun load(key: String): ModelClip

Loads the model called key; a missing or unreadable file fails with a ModelException naming it.

Link copied to clipboard
fun remove(key: String)

Deletes the model called key, folder and all; does nothing when there is none.

Link copied to clipboard
fun save(model: ModelClip, writer: ModelFileWriter = DirectWriter)

Writes model under its key: the frames first, model.json last, so a folder with a model.json is always complete. Replaces a model of the same key, then removes frames left over from it. Each file write goes through writer.