#include "application/diagnostics/DiagnosticsRegistry.h"

#include <stdexcept>
#include <utility>

namespace ta::application::diagnostics
{
    void DiagnosticsRegistry::add(std::string name, Contributor contributor)
    {
        if (name.empty() || !contributor)
            throw std::invalid_argument("diagnostics contributor requires a name and callback");
        entries_.push_back({std::move(name), std::move(contributor)});
    }

    ta::ui::DiagnosticsSnapshot DiagnosticsRegistry::capture() const
    {
        ta::ui::DiagnosticsSnapshot snapshot{};
        for (const Entry& entry : entries_)
            entry.contributor(snapshot);
        return snapshot;
    }
}
