FLAMEGPU / FLAMEGPU2

FLAME GPU 2 is a GPU accelerated agent based modelling framework for CUDA C++ and Python
https://flamegpu.com
MIT License
106 stars 22 forks source link

JSON not formatted anymore #1205

Open Robadob opened 6 months ago

Robadob commented 6 months ago

Discussed in https://github.com/FLAMEGPU/FLAMEGPU2/discussions/1204

Originally posted by **bytetec** May 13, 2024 Hi everyone Since the update from FLAME GPU 2.0.0-rc to FLAME GPU 2.0.0-rc.1 the export of the logfile in JSON produces only a one liner. Does anybody else has this issue? Before: ![image](https://github.com/FLAMEGPU/FLAMEGPU2/assets/138150718/6118a5d0-d5d7-4746-921e-c0d4dc54f466) After: ![image](https://github.com/FLAMEGPU/FLAMEGPU2/assets/138150718/aa7ce8ba-f84d-40dd-8720-4edf7d40d745)

It appears the methods of RapidJSON's Writer are not virtual, hence when a pointer to the PrettyWriter subclass is cast to Writer, method calls are not forwarded to the sub class.

https://github.com/FLAMEGPU/FLAMEGPU2/blob/b5173e78765d03be8d1b393f8a037499b064b676/src/flamegpu/io/JSONStateWriter.cu#L33

This bug was introduced when the StateWriter interface was refactored to better enable partial state writes.

Solution would probably be to template JSONStateWriter so that the two different printers have distinct objects.