MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
StateEncoder.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "Fabric.hpp"
4
5namespace MayaFlux::Nexus {
6
7/**
8 * @class StateEncoder
9 * @brief Serializes Fabric state to an EXR texture and JSON schema.
10 *
11 * v1 scope: encodes all three Kinds (Emitter, Sensor, Agent) that have a
12 * position set. Output:
13 * {base}.exr RGBA32F, width=N entities, height=3 rows:
14 * row 0: position.xyz, intensity
15 * row 1: color.rgb, size
16 * row 2: radius, query_radius, 0, 0
17 * {base}.json Schema v2 with per-entity records (id, kind, fields) and
18 * per-channel ranges for denormalization.
19 *
20 * Entities without a position are skipped. Unnamed callables emit a warning
21 * but are still encoded. Optional fields (color, size) are written as null
22 * in the schema; the EXR channels are zeroed but the decoder ignores them.
23 */
24class MAYAFLUX_API StateEncoder {
25public:
26 StateEncoder() = default;
27 ~StateEncoder() = default;
28
29 StateEncoder(const StateEncoder&) = delete;
33
34 /**
35 * @brief Encode the given Fabric to {base_path}.exr and {base_path}.json.
36 * @param fabric Source of entity state. Only Emitters with a position
37 * are encoded in v0.
38 * @param base_path Path stem without extension.
39 * @return True on success. On failure call last_error().
40 */
41 [[nodiscard]] bool encode(const Fabric& fabric, const std::string& base_path);
42
43 /**
44 * @brief Last error message, empty if no error.
45 */
46 [[nodiscard]] const std::string& last_error() const { return m_last_error; }
47
48private:
49 std::string m_last_error;
50};
51
52} // namespace MayaFlux::Nexus
Orchestrates spatial indexing and scheduling for Nexus objects.
Definition Fabric.hpp:37
StateEncoder & operator=(const StateEncoder &)=delete
const std::string & last_error() const
Last error message, empty if no error.
StateEncoder & operator=(StateEncoder &&)=default
StateEncoder(const StateEncoder &)=delete
StateEncoder(StateEncoder &&)=default
Serializes Fabric state to an EXR texture and JSON schema.