Class JSONStateWriter

Inheritance Relationships

Base Type

Class Documentation

class JSONStateWriter : public flamegpu::io::StateWriter

JSON format StateWriter

Public Functions


Constructs a writer capable of writing model state to an JSON file

inline virtual bool isWriting() override

Returns true if beginWrite() has been called and writing is active

virtual void beginWrite(const std::string &output_file, bool pretty_print) override

Starts writing to the specified file in the specified mode

See also


  • output_file – Filename of the input file (This will be used to determine which reader to return)

  • pretty_print – Whether the output file should be “pretty” or minified.


Throws – exception if beginWrite() is called a second time before endWrite() has been called

virtual void endWrite() override

Saves the current file and ends the writing state

  • Throws – exception if file IO fails

  • Throws – exception if beginWrite() has not been called so writing is not active

virtual void writeConfig(const Simulation *sim_instance) override
virtual void writeStats(unsigned int iterations) override
virtual void writeEnvironment(const std::shared_ptr<const detail::EnvironmentManager> &env_manager) override
virtual void writeMacroEnvironment(const std::shared_ptr<const detail::CUDAMacroEnvironment> &macro_env, std::initializer_list<std::string> filter = {}) override

Write the macro environment block

  • macro_env – The macro environment to pull properties from

  • filter – If provided, only named properties will be written. Note, if filter contains missing properties it will fail

virtual void writeAgents(const util::StringPairUnorderedMap<std::shared_ptr<const AgentVector>> &agents_map) override