.. _program_listing_file_include_flamegpu_io_StateReaderFactory.h: Program Listing for File StateReaderFactory.h ============================================= |exhale_lsh| :ref:`Return to documentation for file ` (``include/flamegpu/io/StateReaderFactory.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #ifndef INCLUDE_FLAMEGPU_IO_STATEREADERFACTORY_H_ #define INCLUDE_FLAMEGPU_IO_STATEREADERFACTORY_H_ #include #include #include #include #include #include #include #include "flamegpu/io/StateReader.h" #include "flamegpu/io/XMLStateReader.h" #include "flamegpu/io/JSONStateReader.h" #include "flamegpu/util/StringPair.h" namespace flamegpu { class AgentVector; namespace io { class StateReaderFactory { public: static StateReader* createReader( const std::string& input) { const std::string extension = std::filesystem::path(input).extension().string(); if (extension == ".xml") { return new XMLStateReader(); } else if (extension == ".json") { return new JSONStateReader(); } THROW exception::UnsupportedFileType("File '%s' is not a type which can be read " "by StateReaderFactory::createReader().", input.c_str()); } }; } // namespace io } // namespace flamegpu #endif // INCLUDE_FLAMEGPU_IO_STATEREADERFACTORY_H_