Class StateWriter

Inheritance Relationships

Derived Types

Class Documentation

class StateWriter

Abstract representation of a class for exporting model data (agent population data, environment properties, run configuration) to file

See also

XMLStateWriter The XML implementation of a StateWriter

See also

JSONStateWriter The JSON implementation of a StateWriter

Subclassed by flamegpu::io::JSONStateWriter, flamegpu::io::XMLStateWriter

Public Functions

inline virtual ~StateWriter()

Virtual destructor for correct inheritance behaviour

virtual bool isWriting() = 0

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

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

Starts writing to the specified file in the specified mode

See also

endWrite()

Parameters:
  • 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:

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

virtual void endWrite() = 0

Saves the current file and ends the writing state

Throws:
  • Throws – exception if file IO fails

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

inline void writeFullModelState(const Simulation *sim_instance, unsigned int iterations, const std::shared_ptr<const detail::EnvironmentManager> &env_manager, const std::shared_ptr<const detail::CUDAMacroEnvironment> &macro_env, const util::StringPairUnorderedMap<std::shared_ptr<const AgentVector>> &agents_map)

Export the full simulation state

Parameters:
  • sim_instance – Instance of the Simulation object (This is used for setting/getting config)

  • iterations – The value from the step counter at the time of export.

  • env_manager – Environment manager containing env property data for this sim instance

  • macro_env – Macro environment of the model

  • agents_map – Map of AgentVector to read the agent data from per agent, key should be agent name

Throws:

Exceptions – will be thrown on failure, specific to the subclass/problem

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

Write the macro environment block

Parameters:
  • 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) = 0