Class StateWriter

Inheritance Relationships

Derived Types

Class Documentation

class StateWriter

Subclassed by jsonWriter, xmlWriter

Public Functions

inline StateWriter(const std::string &_model_name, const unsigned int &_sim_instance_id, const 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 ~StateWriter()
virtual int writeStates(bool prettyPrint) = 0

Actually perform the file export


: This should probably be the same return code between subclasses, and seems redundant with our exceptions as should never return fail.


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


Returns a return code

Protected Attributes

const 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