Program Listing for File StateWriter.h

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

#ifndef INCLUDE_FLAMEGPU_IO_STATEWRITER_H_
#define INCLUDE_FLAMEGPU_IO_STATEWRITER_H_

#include <memory>
#include <string>
#include <unordered_map>
#include <utility>

#include "flamegpu/exception/FLAMEGPUException.h"
#include "flamegpu/model/ModelDescription.h"
#include "flamegpu/util/StringPair.h"

namespace flamegpu {
namespace detail {
class EnvironmentManager;
class CUDAMacroEnvironment;
}  // namespace detail
class AgentVector;
class Simulation;

namespace io {

class StateWriter {
 public:
    virtual ~StateWriter() {}
    virtual bool isWriting() = 0;
    virtual void beginWrite(const std::string &output_file, bool pretty_print) = 0;
    virtual void endWrite() = 0;

    // -----------------------------------------------------------------------
    //  The Easy Interface
    // -----------------------------------------------------------------------
    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) {
        writeConfig(sim_instance);
        writeStats(iterations);
        writeEnvironment(env_manager);
        writeMacroEnvironment(macro_env);
        writeAgents(agents_map);
    }
    // -----------------------------------------------------------------------
    //  The Advanced Interface
    // -----------------------------------------------------------------------
    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;
    virtual void writeAgents(const util::StringPairUnorderedMap<std::shared_ptr<const AgentVector>>& agents_map) = 0;
};
}  // namespace io
}  // namespace flamegpu

#endif  // INCLUDE_FLAMEGPU_IO_STATEWRITER_H_