MCPcopy Create free account
hub / github.com/chrxh/alien / serializeSimulationToFiles

Method serializeSimulationToFiles

source/PersisterInterface/SerializerService.cpp:850–884  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

848}
849
850bool 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
886bool SerializerService::deserializeSimulationFromFiles(DeserializedSimulation& data, std::filesystem::path const& filename)
887{

Callers 2

processRequestMethod · 0.80
mainFunction · 0.80

Calls 1

logFunction · 0.85

Tested by

no test coverage detected