Program Listing for File StateReader.h

Return to documentation for file (include/flamegpu/io/StateReader.h)

#ifndef INCLUDE_FLAMEGPU_IO_STATEREADER_H_
#define INCLUDE_FLAMEGPU_IO_STATEREADER_H_

#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
#include <any>

#include "flamegpu/util/StringPair.h"
#include "flamegpu/simulation/Simulation.h"
#include "flamegpu/simulation/CUDASimulation.h"

namespace flamegpu {

class AgentVector;

namespace io {

class StateReader {
 public:
    virtual ~StateReader() {}

    virtual void parse(const std::string &input_file, const std::shared_ptr<const ModelData> &model, Verbosity verbosity) = 0;

    // -----------------------------------------------------------------------
    //  The Easy Interface
    // -----------------------------------------------------------------------
    void getFullModelState(
        Simulation::Config &s_cfg,
        std::unordered_map<std::string, detail::Any> &environment_init,
        std::unordered_map<std::string, std::vector<char>> &macro_environment_init,
        util::StringPairUnorderedMap<std::shared_ptr<AgentVector>> &agents_init);

    // -----------------------------------------------------------------------
    //  The Advanced Interface
    // -----------------------------------------------------------------------
    void getSimulationConfig(Simulation::Config &cfg);
    void getCUDAConfig(CUDASimulation::Config &cfg);
    void getEnvironment(std::unordered_map<std::string, detail::Any> &environment_init);
    void getMacroEnvironment(std::unordered_map<std::string, std::vector<char>> &macro_environment_init);
    void getAgents(util::StringPairUnorderedMap<std::shared_ptr<AgentVector>> &agents_init);

 protected:
    std::string input_filepath;

    void resetCache();

    std::unordered_map<std::string, std::any> simulation_config;
    std::unordered_map<std::string, std::any> cuda_config;
    std::unordered_map<std::string, detail::Any> env_init;
    std::unordered_map<std::string, std::vector<char>> macro_env_init;
    util::StringPairUnorderedMap<std::shared_ptr<AgentVector>> agents_map;
};
}  // namespace io
}  // namespace flamegpu

#endif  // INCLUDE_FLAMEGPU_IO_STATEREADER_H_