examples/example.stats/include/carb/stats/IStats.h
File members: examples/example.stats/include/carb/stats/IStats.h
// Copyright (c) 2022-2024, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include <carb/Interface.h>
#include <carb/Strong.h>
// example-begin carbonite-interface-walkthrough-version-decl
#define carb_stats_IStats_latest CARB_HEXVERSION(1, 1)
#ifndef carb_stats_IStats
# define carb_stats_IStats CARB_HEXVERSION(1, 0)
#endif
// example-end carbonite-interface-walkthrough-version-decl
namespace carb
{
namespace stats
{
CARB_STRONGTYPE(StatId, size_t);
constexpr StatId kBadStatId = StatId(~0ull);
enum class StatType
{
eInt,
eDouble,
};
enum class AggregationType
{
eReplace,
eAccumulate,
eAverage,
eMin,
eMax,
};
struct Value
{
StatType type;
int64_t intValue = 0;
double doubleValue = 0.0;
};
struct StatDesc
{
const char* name;
const char* description = nullptr;
AggregationType aggregationType = AggregationType::eReplace;
Value value;
};
// example-begin carbonite-interface-walkthrough-plugin-interface
struct IStats
{
CARB_PLUGIN_INTERFACE_EX("carb::stats::IStats", carb_stats_IStats_latest, carb_stats_IStats)
StatId(CARB_ABI* addStat)(const StatDesc& desc);
bool(CARB_ABI* removeStat)(StatId stat);
bool(CARB_ABI* addValue)(StatId stat, const Value& value);
bool(CARB_ABI* getValue)(StatId stat, StatDesc& value);
#if CARB_VERSION_ATLEAST(carb_stats_IStats, 1, 1)
size_t(CARB_ABI* getCount)();
#endif
};
// example-end carbonite-interface-walkthrough-plugin-interface
} // namespace stats
} // namespace carb