Add polymorphism support to Ref

This commit is contained in:
2025-09-11 14:15:52 -04:00
parent 9a8d4feedd
commit 5d932bf36c
6 changed files with 331 additions and 6 deletions

View File

@@ -51,6 +51,7 @@
#include <vector>
#include "arena.hpp"
#include "reference.hpp"
namespace metric {
@@ -255,12 +256,12 @@ struct Collector {
/**
* @brief Register a collector with the metrics system.
*
* The system will hold a shared_ptr to the collector and call its collect()
* The system will hold a Ref to the collector and call its collect()
* method during each metric rendering.
*
* @param collector A shared_ptr to the collector to be registered.
* @param collector A Ref to the collector to be registered.
*/
void register_collector(std::shared_ptr<Collector> collector);
void register_collector(Ref<Collector> collector);
// Note: Histograms do not support callbacks due to their multi-value nature
// (buckets + sum + count). Use static histogram metrics only.