Metadata-Version: 2.1
Name: mihosoft-vmf-runtime
Version: 0.5.0a1
Summary: Runtime library for Python models generated by VMF (Visual Modeling Framework).
Home-page: https://github.com/miho/VMF
Author: Michael Hoffer
Author-email: info@michaelhoffer.de
License: Apache-2.0
Keywords: vmf,modeling,code-generation
Project-URL: Homepage, https://github.com/miho/VMF
Project-URL: Repository, https://github.com/miho/VMF.git
Project-URL: Issues, https://github.com/miho/VMF/issues
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# `mihosoft-vmf-runtime`

Runtime library for Python models generated by [VMF (Visual Modeling Framework)](https://github.com/miho/VMF).

## Installation

```bash
pip install mihosoft-vmf-runtime
```

> **Version lockstep:** Generated Python models (`model.py`) and `mihosoft-vmf-runtime` belong to the same VMF version. When upgrading VMF, regenerate your models and update `mihosoft-vmf-runtime` to the matching version.

## What's included

- Pure Python 3.10+ package (`vmf_runtime`) with full PEP 561 type annotations (`py.typed`) and zero external dependencies.
- Runtime enforcement of declared scalar types, numeric widths (`int8`/`int16`/`int32`/`int64`, `float32`/`float64`, `char`), enum literals, UUIDs, and model types.
- Managed containment, bidirectional opposite references, cycle checks, and `with vmf.edit(origin):` atomic rollback blocks.
- Managed Pythonic collections (`ScalarList`, `ScalarSet`, `ScalarMap`, `ContainmentList`, `ContainmentSet`, `ReferenceList`, `ReferenceSet`) and keyed lookups.
- Live read-only views (`as_read_only()`) and frozen `@Immutable` value objects.
- Equality modes (`INSTANCE`, `CONTAINMENT_AND_EXTERNAL`, `ALL`) wired to `__eq__` / `__hash__`, plus `content_equals()` / `content_hash_code()` and `deep_copy()`.
- Local and recursive change listeners, recording, and undo/redo history.
- Reflection metadata (`vmf_type`), including uniform `vmf:*` annotations.
- Constraint validation (`@Multiplicity`, `@Range`, `@Length`, `@Pattern`).
- Reference-aware and plain JSON snapshots (`ModelSnapshot.write` / `read` / `write_plain` / `read_plain`), including `@Id` stable references and exact arbitrary-precision integers.
- Depth-first graph traversal, enter/exit visitors, and writable graph cursors (`ModelGraphCursor`).

## Usage

Generate Python models from your VMF Java model interfaces (`vmf { targets = ['python'] }` in Gradle or `<targets><target>python</target></targets>` in Maven), then import the generated `model.py`:

```python
from com.example.plant.model import ModelSnapshot, Plant, Vessel

plant = Plant(id="plant-1")
vessel = Vessel(id="vessel-1")
plant.vessels.add(vessel)
plant.primary_vessel = vessel

payload = ModelSnapshot.write(plant)
restored = ModelSnapshot.read(payload, Plant)
```

## Documentation

- [Python language mapping](https://github.com/miho/VMF/blob/main/docs/targets/python.md)
- [Portable VMF contract](https://github.com/miho/VMF/blob/main/conformance/portable/CONTRACT.md)
- [Stable IDs (`@Id`) and `vmf:*` reflection](https://github.com/miho/VMF/blob/main/docs/stable-ids-and-reflection.md)
