---
title: "ClikaRT::runtime::ModelState"
sidebar_label: "ModelState"
description: "Base for a model's per-session state. Subclass it to hold whatever a session needs across phases/steps; override as_batchable() if the state is batchable."
---

<!-- Generated by tools/doxygen2mdx from Doxygen XML. Do not edit. -->

<span class="api-kind api-kind--class">class</span>

**Header:** `ClikaRT/runtime/state.h`  
**Inherited by:** `ClikaRT::runtime::detail::FromGraphSessionState`

Base for a model's per-session state. Subclass it to hold whatever a session needs across phases/steps; override [`as_batchable()`](./ModelState.md#as_batchable) if the state is batchable. The runtime owns the lifetime: [`Model::make_state`](./Model.md#make_state) returns one, the runtime threads it into `Phase_RunOnce`/`Phase_Iterate`, then calls [`Model::evict`](./Model.md#evict) and destroys it.

## Member functions

### \~ModelState() {#ModelState}

<div class="api-signature">

`virtual` **`~ModelState`**()

</div>

Virtual; state is deletable through the interface.

<div class="api-declared">

Declared in `ClikaRT/runtime/state.h`, line 28

</div>

### as\_batchable() {#as_batchable}

<div class="api-signature">

`virtual` [`BatchableState`](./BatchableState.md)`*` **`as_batchable`**() `noexcept`

</div>

Return `this` (as a [`BatchableState`](./BatchableState.md)) iff this state participates in continuous batching; the default is "not batchable" (`nullptr`). A batchable state overrides BOTH to return `this`.

<div class="api-declared">

Declared in `ClikaRT/runtime/state.h`, line 33

</div>

### as\_batchable() {#as_batchable-2}

<div class="api-signature">

`virtual` `const` [`BatchableState`](./BatchableState.md)`*` **`as_batchable`**() `const noexcept`

</div>

Const twin of [`as_batchable()`](./ModelState.md#as_batchable); nullptr when the state is not batchable.

<div class="api-declared">

Declared in `ClikaRT/runtime/state.h`, line 35

</div>
