| 848 | } |
| 849 | |
| 850 | bool SerializerService::serializeSimulationToFiles(std::filesystem::path const& filename, DeserializedSimulation const& data) |
| 851 | { |
| 852 | try { |
| 853 | log(Priority::Important, "save simulation to " + filename.string()); |
| 854 | std::filesystem::path settingsFilename(filename); |
| 855 | settingsFilename.replace_extension(std::filesystem::path(".settings.json")); |
| 856 | std::filesystem::path statisticsFilename(filename); |
| 857 | statisticsFilename.replace_extension(std::filesystem::path(".statistics.csv")); |
| 858 | |
| 859 | { |
| 860 | zstr::ofstream stream(filename.string(), std::ios::binary); |
| 861 | if (!stream) { |
| 862 | return false; |
| 863 | } |
| 864 | serializeDataDescription(data.mainData, stream); |
| 865 | } |
| 866 | { |
| 867 | std::ofstream stream(settingsFilename.string(), std::ios::binary); |
| 868 | if (!stream) { |
| 869 | return false; |
| 870 | } |
| 871 | serializeAuxiliaryData(data.auxiliaryData, stream); |
| 872 | } |
| 873 | { |
| 874 | std::ofstream stream(statisticsFilename.string(), std::ios::binary); |
| 875 | if (!stream) { |
| 876 | return false; |
| 877 | } |
| 878 | serializeStatistics(data.statistics, stream); |
| 879 | } |
| 880 | return true; |
| 881 | } catch (...) { |
| 882 | return false; |
| 883 | } |
| 884 | } |
| 885 | |
| 886 | bool SerializerService::deserializeSimulationFromFiles(DeserializedSimulation& data, std::filesystem::path const& filename) |
| 887 | { |
no test coverage detected