diff --git a/src/StringRepresentation.cpp b/src/StringRepresentation.cpp index 89def44..f3bf6f2 100644 --- a/src/StringRepresentation.cpp +++ b/src/StringRepresentation.cpp @@ -24,19 +24,21 @@ using namespace std; namespace libforefire { -// static variables initialization -size_t StringRepresentation::currentLevel = 0; -ostringstream StringRepresentation::outputstr(""); +// The output buffer, the nesting level and the GeoJSON aggregation state used +// to be statics and file globals here, so two simulations printing at the same +// time wrote into one buffer. They are members now. +// +// For GEOJSON mode we aggregate rings per top-level front. Each top-level +// feature (currentLevel==1) is a vector of rings, where each ring is a vector +// of coordinate strings. +// +// writedOnce is deliberately left shared for now. Unlike the rest, making it +// per-instance is an observable change: output() skips a representation whose +// domain has no front once anything has been written, so a second +// representation in the same session would gain a first output file it does +// not produce today. That is a behaviour question for the coupled runs, not a +// mechanical one, and it belongs with the state work in #175. bool writedOnce = false; -string outPattern; -FireDomain* domain = 0; - -// --- GEOJSON Aggregation Variables --- -// For GEOJSON mode we aggregate rings per top-level front. -// Each top-level feature (currentLevel==1) will be represented as a vector of rings, -// where each ring is a vector of coordinate strings. -static bool firstGeoFeature = true; // used when outputting the feature list -static std::vector< std::vector > geojson_current_feature; StringRepresentation::StringRepresentation(FireDomain* fdom) : Visitor() { lastLevel = -1; diff --git a/src/StringRepresentation.h b/src/StringRepresentation.h index 761f5c4..8fbad99 100644 --- a/src/StringRepresentation.h +++ b/src/StringRepresentation.h @@ -18,13 +18,22 @@ namespace libforefire { class StringRepresentation: public Visitor { FireDomain* domain; - static size_t currentLevel; + + /* These were statics, shared by every simulation in the process: two + * concurrent print[] calls interleaved into one buffer. */ + size_t currentLevel = 0; + bool firstGeoFeature = true; /*!< first feature of the GeoJSON list */ + std::vector< std::vector > geojson_current_feature; double updateStep; public: - static ostringstream outputstr; + /*! \brief buffer the representation is built into + * + * Was static, so two simulations printing at once interleaved into one + * buffer. Command::dumpString reads it, hence public. */ + ostringstream outputstr; /* StringRepresentation();*/ StringRepresentation(FireDomain*);