CoriEngine
Loading...
Searching...
No Matches
Trackable.hpp
Go to the documentation of this file.
1#pragma once
2#include "InstanceMetrics.hpp"
3
4namespace Cori {
8 namespace Profiling {
28 template<typename DerivedType, typename... BasePack>
29 class Trackable {
30 public:
31 Trackable(const Trackable&) = delete;
32 Trackable& operator=(const Trackable&) = delete;
33 Trackable(Trackable&&) = delete;
35
36 protected:
39 static ReporterRegistrar registrarTrigger;
40 }
41
45
46 private:
47 struct ReporterRegistrar {
48 ReporterRegistrar() {
49 if constexpr (sizeof...(BasePack) == 0) {
50 Register<DerivedType>();
51 } else {
52 (Register<BasePack>(), ...);
53 }
54 }
55
56 template<typename Base>
57 void Register() {
58 if constexpr (!std::is_same_v<DerivedType, Base>) {
60 std::type_index(typeid(DerivedType)),[]() {
62 }
63 );
65 std::type_index(typeid(DerivedType)), []() -> std::pair<int64_t, int64_t> {
67 }
68 );
69 }
70 }
71 };
72 };
73 }
74}
static void RegisterDerivedReporter(const std::type_index &derivedTypeId, DerivedMetricsReporter reporter)
static int64_t GetDirectAliveCount()
Checks how many instances of type T is alive, not including derived classes.
static int64_t GetDirectTotalCreatedCount()
Checks how many instances of type T were created, not including derived classes.
static void RegisterDerivedMetricsProvider(const std::type_index &derivedTypeId, DerivedMetricsProvider provider)
static void Report(const std::string &indent="")
Will report the data about type T instances.
Trackable & operator=(const Trackable &)=delete
Trackable(const Trackable &)=delete
Trackable(Trackable &&)=delete
Trackable & operator=(Trackable &&)=delete
Profiling tools are in this namespace.
Global engine namespace.