Skip to content

Streams Overview

The Streams module provides a flexible serialization framework for data persistence. It abstracts data sources and formats, enabling save/load of configurations, scenes, and game data.

Architecture

Context Pattern

Streams uses a single SerializationContext class to manage both serialization and deserialization state. Access to fields is done through ContextProxy objects returned by operator[].

Data Flow

Format Support

The currently implemented data format is JSON. Binary and XML formats are not implemented.

Type Safety

The API provides type-safe serialization through ContextProxy. Supported scalar value types are int, float, std::string, and bool. Arrays are supported via std::vector<std::any>. There is no built-in support for glm::vec3 or other compound types.

cpp
// Writing - use operator[] to navigate, operator= to assign
auto ctx = SerializationContext::create(SerializationFormat::Json);
ctx->operator[]("health") = SerializableValue(100);               // int
ctx->operator[]("name")   = SerializableValue(std::string("Player")); // string

// Reading - use as<T>() on the ContextProxy
int health       = ctx->operator[]("health").as<int>();
std::string name = ctx->operator[]("name").as<std::string>();
float speed      = ctx->operator[]("speed").as<float>();
bool active      = ctx->operator[]("active").as<bool>();
std::vector<std::any> items = ctx->operator[]("inventory").as<std::vector<std::any>>();

Hierarchical Data

Supports nested objects and arrays through chained operator[] calls on ContextProxy:

Integration Points

Streams is used throughout Astra:

  • Project - Configuration files (.aproject)
  • Scenes - Scene serialization (.ascene)
  • Prefabs - Entity templates
  • Editor - Preferences and layouts

For detailed implementation, see Streams.