Struct LiveString
Defined in File GuiWidgetDescription.h
Struct Documentation
-
struct LiveString
A string value that can be written from any thread and read (polled) from the GUI thread without data races.
Usage (writer side, any thread): liveStr.set(mrpt::format(“ICP quality: %.1f%%”, q));
Usage (GUI thread, nanogui backend): std::string tmp; if (liveStr.poll(tmp)) label->setCaption(tmp);
Usage (GUI thread, ImGui backend - called every frame): ImGui::TextUnformatted(liveStr.display.c_str()); liveStr.pollIntoDisplay(); // updates display if dirty
Public Types
-
using Ptr = std::shared_ptr<LiveString>
Public Functions
-
inline LiveString()
-
inline explicit LiveString(std::string initial)
-
~LiveString() = default
-
inline uint64_t id() const
Globally unique ID for this instance (stable for its lifetime).
-
LiveString(const LiveString&) = delete
-
LiveString &operator=(const LiveString&) = delete
-
LiveString(LiveString&&) = delete
-
LiveString &operator=(LiveString&&) = delete
-
inline void set(std::string s)
Write from any thread.
-
inline bool poll(std::string &out)
Call from the GUI thread. Copies pending value into
outand clears the dirty flag. Returns true if the value changed.
-
inline void pollIntoDisplay()
Convenience variant for the ImGui backend: updates the public
displaymember in-place. Call this each frame; then readdisplaydirectly.
Public Members
-
std::string display
The current display value. Written only by the GUI thread (via pollIntoDisplay), so safe to read from the GUI thread without locking.
-
using Ptr = std::shared_ptr<LiveString>