diff --git a/include/ircd/stats.h b/include/ircd/stats.h index fa8afd129..d3aaf83a7 100644 --- a/include/ircd/stats.h +++ b/include/ircd/stats.h @@ -52,11 +52,25 @@ namespace ircd::stats template<> struct item; template<> struct item; template<> struct item; + template<> struct item; + template<> struct item; + template<> struct item; + template<> struct item; + template<> struct item; + template<> struct item; + template<> struct item; // Value-carrying items template<> struct item; template<> struct item; template<> struct item; + template<> struct item; + template<> struct item; + template<> struct item; + template<> struct item; + template<> struct item; + template<> struct item; + template<> struct item; extern const size_t NAME_MAX_LEN; extern std::vector *> items; @@ -184,6 +198,22 @@ struct ircd::stats::item using int_item::operator=; }; +template<> +struct ircd::stats::item +:ptr_item +{ + using ptr_item::ptr_item; + using ptr_item::operator=; +}; + +template<> +struct ircd::stats::item +:int_item +{ + using int_item::int_item; + using int_item::operator=; +}; + template<> struct ircd::stats::item :ptr_item @@ -200,6 +230,22 @@ struct ircd::stats::item using int_item::operator=; }; +template<> +struct ircd::stats::item +:ptr_item +{ + using ptr_item::ptr_item; + using ptr_item::operator=; +}; + +template<> +struct ircd::stats::item +:int_item +{ + using int_item::int_item; + using int_item::operator=; +}; + template<> struct ircd::stats::item :ptr_item @@ -215,3 +261,83 @@ struct ircd::stats::item using int_item::int_item; using int_item::operator=; }; + +template<> +struct ircd::stats::item +:ptr_item +{ + using ptr_item::ptr_item; + using ptr_item::operator=; +}; + +template<> +struct ircd::stats::item +:int_item +{ + using int_item::int_item; + using int_item::operator=; +}; + +template<> +struct ircd::stats::item +:ptr_item +{ + using ptr_item::ptr_item; + using ptr_item::operator=; +}; + +template<> +struct ircd::stats::item +:int_item +{ + using int_item::int_item; + using int_item::operator=; +}; + +template<> +struct ircd::stats::item +:ptr_item +{ + using ptr_item::ptr_item; + using ptr_item::operator=; +}; + +template<> +struct ircd::stats::item +:int_item +{ + using int_item::int_item; + using int_item::operator=; +}; + +template<> +struct ircd::stats::item +:ptr_item +{ + using ptr_item::ptr_item; + using ptr_item::operator=; +}; + +template<> +struct ircd::stats::item +:int_item +{ + using int_item::int_item; + using int_item::operator=; +}; + +template<> +struct ircd::stats::item +:ptr_item +{ + using ptr_item::ptr_item; + using ptr_item::operator=; +}; + +template<> +struct ircd::stats::item +:int_item +{ + using int_item::int_item; + using int_item::operator=; +}; diff --git a/ircd/stats.cc b/ircd/stats.cc index 8920a44f9..0aa793950 100644 --- a/ircd/stats.cc +++ b/ircd/stats.cc @@ -35,7 +35,7 @@ ircd::stats::string(const mutable_buffer &buf, { const auto &item { - dynamic_cast &>(item_) + dynamic_cast &>(item_) }; assert(item.val); @@ -44,11 +44,76 @@ ircd::stats::string(const mutable_buffer &buf, buf, "%lu", *item.val }; } + else if(item_.type == typeid(int64_t *)) + { + const auto &item + { + dynamic_cast &>(item_) + }; + + assert(item.val); + return fmt::sprintf + { + buf, "%ld", *item.val + }; + } + else if(item_.type == typeid(nanoseconds *)) + { + const auto &item + { + dynamic_cast &>(item_) + }; + + assert(item.val); + return fmt::sprintf + { + buf, "%ld", item.val->count() + }; + } + else if(item_.type == typeid(microseconds *)) + { + const auto &item + { + dynamic_cast &>(item_) + }; + + assert(item.val); + return fmt::sprintf + { + buf, "%ld", item.val->count() + }; + } + else if(item_.type == typeid(milliseconds *)) + { + const auto &item + { + dynamic_cast &>(item_) + }; + + assert(item.val); + return fmt::sprintf + { + buf, "%ld", item.val->count() + }; + } + else if(item_.type == typeid(seconds *)) + { + const auto &item + { + dynamic_cast &>(item_) + }; + + assert(item.val); + return fmt::sprintf + { + buf, "%ld", item.val->count() + }; + } else if(item_.type == typeid(uint32_t *)) { const auto &item { - dynamic_cast &>(item_) + dynamic_cast &>(item_) }; assert(item.val); @@ -57,11 +122,24 @@ ircd::stats::string(const mutable_buffer &buf, buf, "%u", *item.val }; } + else if(item_.type == typeid(int32_t *)) + { + const auto &item + { + dynamic_cast &>(item_) + }; + + assert(item.val); + return fmt::sprintf + { + buf, "%d", *item.val + }; + } else if(item_.type == typeid(uint16_t *)) { const auto &item { - dynamic_cast &>(item_) + dynamic_cast &>(item_) }; assert(item.val); @@ -70,7 +148,20 @@ ircd::stats::string(const mutable_buffer &buf, buf, "%u", *item.val }; } - else throw error + else if(item_.type == typeid(int16_t *)) + { + const auto &item + { + dynamic_cast &>(item_) + }; + + assert(item.val); + return fmt::sprintf + { + buf, "%d", *item.val + }; + } + else throw invalid { "Unsupported value type '%s'", item_.type.name(),