Class StateWriter

Inheritance Relationships

Derived Types

Class Documentation

class flamegpu::io::StateWriter

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


XMLStateWriter The XML implementation of a StateWriter


JSONStateWriter The JSON implementation of a StateWriter

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

Public Functions

inline StateWriter(const std::string &_model_name, const unsigned int &_sim_instance_id, const util::StringPairUnorderedMap<std::shared_ptr<AgentVector>> &_model_state, const unsigned int &_iterations, const std::string &output_file, const Simulation *_sim_instance)

Returns a writer capable of writing model state to a specific format (this class is abstract) Environment properties from the Simulation instance pointed to by ‘sim_instance_id’ will be used Agent data will be read from ‘model_state’

  • _model_name – Name from the model description hierarchy of the model to be exported

  • _sim_instance_id – Instance is from the Simulation instance to export the environment properties fromo

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

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

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

  • _sim_instance – Instance of the simulation (for configuration data IO)

inline virtual ~StateWriter()

Virtual destructor for correct inheritance behaviour

virtual int writeStates(bool prettyPrint) = 0

Actually perform the file export


prettyPrint – Whether to include indentation and line breaks to aide human reading


Returns a return code

Protected Attributes

const util::StringPairUnorderedMap<std::shared_ptr<AgentVector>> model_state = {}
unsigned int iterations
std::string outputFile
const std::string model_name
const unsigned int sim_instance_id
const Simulation *sim_instance