make metric_type_t an enum class, deprecate the in-class enum values
This commit is contained in:
parent
acbe3c1880
commit
c2ebae7dbb
|
@ -42,7 +42,7 @@ int main()
|
|||
for (int i = 0; i < int(m.size()); ++i)
|
||||
{
|
||||
std::printf("%s: %s (%d)\n"
|
||||
, m[i].type == stats_metric::type_counter ? "CNTR" : "GAUG"
|
||||
, m[i].type == metric_type_t::counter ? "CNTR" : "GAUG"
|
||||
, m[i].name, m[i].value_index);
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -40,13 +40,21 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
namespace libtorrent {
|
||||
|
||||
enum class metric_type_t
|
||||
{
|
||||
counter, gauge
|
||||
};
|
||||
|
||||
// describes one statistics metric from the session. For more information,
|
||||
// see the session-statistics_ section.
|
||||
struct TORRENT_EXPORT stats_metric
|
||||
{
|
||||
char const* name;
|
||||
int value_index;
|
||||
enum metric_type_t { type_counter, type_gauge };
|
||||
#if TORRENT_ABI_VERSION == 1
|
||||
static constexpr metric_type_t TORRENT_DEPRECATED_MEMBER type_counter = metric_type_t::counter;
|
||||
static constexpr metric_type_t TORRENT_DEPRECATED_MEMBER type_gauge = metric_type_t::gauge;
|
||||
#endif
|
||||
metric_type_t type;
|
||||
};
|
||||
|
||||
|
|
|
@ -39,8 +39,12 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
namespace libtorrent {
|
||||
|
||||
namespace {
|
||||
#if TORRENT_ABI_VERSION == 1
|
||||
constexpr metric_type_t stats_metric::type_counter;
|
||||
constexpr metric_type_t stats_metric::type_gauge;
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
struct stats_metric_impl
|
||||
{
|
||||
|
@ -566,7 +570,7 @@ namespace {
|
|||
stats[i].name = metrics[i].name;
|
||||
stats[i].value_index = metrics[i].value_index;
|
||||
stats[i].type = metrics[i].value_index >= counters::num_stats_counters
|
||||
? stats_metric::type_gauge : stats_metric::type_counter;
|
||||
? metric_type_t::gauge : metric_type_t::counter;
|
||||
}
|
||||
return std::move(stats);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue