#pragma once #include "hot_reload/SymbolEvent.hpp" #include #include /** * @file SymbolEventInfo.hpp * @brief hot_reload::SymbolEventInfo -- the argument Options::onSymbolEvent is called with. */ namespace hot_reload { /** * @brief One symbol's outcome during a Context::reload() call. * * Carries the same fields as hot_reload.h's `HotReloadSymbolEventInfo`; see Status.hpp's * file comment for how the C and C++ APIs relate. * * @note Valid only for the duration of the Options::onSymbolEvent call it was passed to -- * in particular, @ref name points into storage Context owns, not this struct's own. * Copy out whatever you need (summary() is one convenient way to) before returning. */ struct SymbolEventInfo { /// The symbol's real (possibly mangled) name. See hot_reload::demangle() for a /// human-readable form. std::string_view name; /// What happened to it. SymbolEvent::Removed is not a privileged "zero value" for this /// type the way, say, Status::Ok is for Status -- this default exists purely so a /// default-constructed SymbolEventInfo is well-defined rather than full of /// indeterminate values; every real one is fully populated by Context before use. SymbolEvent kind = SymbolEvent::Removed; /// The symbol's address in the previous build, or null if not applicable (kind is /// SymbolEvent::Added). void* oldAddress = nullptr; /// The symbol's address in the new build, or null if not applicable (kind is /// SymbolEvent::Removed). void* newAddress = nullptr; /** * @brief A one-line, human-readable summary of this event -- e.g. for a log line. * @return Something like `"patched 'tick' (0x1234 -> 0x5678)"`; addresses are included * only where this event's kind() makes them meaningful. */ [[nodiscard]] std::string summary() const; }; }