Dynamic Neural Field Composer 0.0.0
A C++20 library and interactive application for building and simulating Dynamic Neural Field (DNF) architectures.
Loading...
Searching...
No Matches
Public Member Functions | List of all members
dnf_composer::SimulationFileManager Class Reference

Serializes and deserializes a Simulation to / from a JSON file. More...

#include <simulation_file_manager.h>

Collaboration diagram for dnf_composer::SimulationFileManager:

Public Member Functions

void loadElementsFromJson () const
 Deserialize elements and connections from a JSON file into the simulation. After loading, FieldCoupling elements have their weight directory set to the parent directory of the JSON file and their weights are re-read from there.
 
void saveElementsToJson () const
 Serialize all elements and their connections to a JSON file. When filePath is empty the output directory is data/<identifier>/ and FieldCoupling weight matrices are written into the same directory before the JSON is saved.
 
 SimulationFileManager (const std::shared_ptr< Simulation > &simulation, const std::string &filePath={})
 Construct a SimulationFileManager.
 

Detailed Description

Serializes and deserializes a Simulation to / from a JSON file.

SimulationFileManager reads and writes every element in the simulation (including parameters and inter-element connections) as a JSON document. This allows pre-designed or evolved architectures to be saved and replayed without re-implementing them in code.

Default output layout when filePath is empty:

data/<identifier>/
<identifier>.dnf ← element graph
<coupling_name>_weights.txt ← one file per FieldCoupling element

When loading, FieldCoupling weight files are resolved relative to the directory that contains the .dnf file (i.e. parent_path(filePath)).

The optional path supplied to this manager has different behavior depending on the operation:

Constructor & Destructor Documentation

◆ SimulationFileManager()

dnf_composer::SimulationFileManager::SimulationFileManager ( const std::shared_ptr< Simulation > &  simulation,
const std::string &  filePath = {} 
)

Construct a SimulationFileManager.

Parameters
simulationThe simulation instance to read into or write from.
filePathOptional .dnf file path. When non-empty, it is the file used for both save and load operations. When empty, saveElementsToJson() writes to the default output location using a generated <identifier>.dnf file name, while loadElementsFromJson() expects a concrete .dnf file path to be available at the resolved path.
Here is the call graph for this function:

Member Function Documentation

◆ loadElementsFromJson()

void dnf_composer::SimulationFileManager::loadElementsFromJson ( ) const

Deserialize elements and connections from a JSON file into the simulation. After loading, FieldCoupling elements have their weight directory set to the parent directory of the JSON file and their weights are re-read from there.

Here is the caller graph for this function:

◆ saveElementsToJson()

void dnf_composer::SimulationFileManager::saveElementsToJson ( ) const

Serialize all elements and their connections to a JSON file. When filePath is empty the output directory is data/<identifier>/ and FieldCoupling weight matrices are written into the same directory before the JSON is saved.

Here is the caller graph for this function:

The documentation for this class was generated from the following files: