Class WriterFactory

Class Documentation

class WriterFactory

Public Static Functions

static inline StateWriter *createWriter(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 ‘output_file’ Environment properties from the Simulation instance pointed to by ‘sim_instance_id’ will be used Agent data will be read from ‘model_state’

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

  • 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 object (This is used for setting/getting config)

Throws

UnsupportedFileType – If the file extension does not match an appropriate reader

static inline std::string detectSupportedFileExt(const std::string &user_file_ext)

Return a clean file extension from the provided string If the file extension is not supported empty string is returned instead

static inline std::unique_ptr<Logger> createLogger(const std::string &output_path, bool prettyPrint, bool truncateFile = true)
Parameters
  • output_path – File for the log to be output to, this will be used to determine the logger type

  • prettyPrint – If false, the output data will be in a compact/minified format which may not be very readable

  • truncateFile – If true and output file already exists, it will be truncated