summaryrefslogtreecommitdiff
path: root/src/common/telemetry.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/telemetry.h')
-rw-r--r--src/common/telemetry.h36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/common/telemetry.h b/src/common/telemetry.h
index 49186e848..3524c857e 100644
--- a/src/common/telemetry.h
+++ b/src/common/telemetry.h
@@ -8,6 +8,8 @@
8#include <map> 8#include <map>
9#include <memory> 9#include <memory>
10#include <string> 10#include <string>
11#include <string_view>
12#include "common/common_funcs.h"
11#include "common/common_types.h" 13#include "common/common_types.h"
12 14
13namespace Common::Telemetry { 15namespace Common::Telemetry {
@@ -28,7 +30,7 @@ struct VisitorInterface;
28/** 30/**
29 * Interface class for telemetry data fields. 31 * Interface class for telemetry data fields.
30 */ 32 */
31class FieldInterface : NonCopyable { 33class FieldInterface {
32public: 34public:
33 virtual ~FieldInterface() = default; 35 virtual ~FieldInterface() = default;
34 36
@@ -52,14 +54,15 @@ public:
52template <typename T> 54template <typename T>
53class Field : public FieldInterface { 55class Field : public FieldInterface {
54public: 56public:
55 Field(FieldType type_, std::string name_, T value_) 57 YUZU_NON_COPYABLE(Field);
56 : name(std::move(name_)), type(type_), value(std::move(value_)) {}
57 58
58 Field(const Field&) = default; 59 Field(FieldType type_, std::string_view name_, T value_)
59 Field& operator=(const Field&) = default; 60 : name(name_), type(type_), value(std::move(value_)) {}
60 61
61 Field(Field&&) = default; 62 ~Field() override = default;
62 Field& operator=(Field&& other) = default; 63
64 Field(Field&&) noexcept = default;
65 Field& operator=(Field&& other) noexcept = default;
63 66
64 void Accept(VisitorInterface& visitor) const override; 67 void Accept(VisitorInterface& visitor) const override;
65 68
@@ -98,9 +101,15 @@ private:
98/** 101/**
99 * Collection of data fields that have been logged. 102 * Collection of data fields that have been logged.
100 */ 103 */
101class FieldCollection final : NonCopyable { 104class FieldCollection final {
102public: 105public:
106 YUZU_NON_COPYABLE(FieldCollection);
107
103 FieldCollection() = default; 108 FieldCollection() = default;
109 ~FieldCollection() = default;
110
111 FieldCollection(FieldCollection&&) noexcept = default;
112 FieldCollection& operator=(FieldCollection&&) noexcept = default;
104 113
105 /** 114 /**
106 * Accept method for the visitor pattern, visits each field in the collection. 115 * Accept method for the visitor pattern, visits each field in the collection.
@@ -115,7 +124,7 @@ public:
115 * @param value Value for the field to add. 124 * @param value Value for the field to add.
116 */ 125 */
117 template <typename T> 126 template <typename T>
118 void AddField(FieldType type, const char* name, T value) { 127 void AddField(FieldType type, std::string_view name, T value) {
119 return AddField(std::make_unique<Field<T>>(type, name, std::move(value))); 128 return AddField(std::make_unique<Field<T>>(type, name, std::move(value)));
120 } 129 }
121 130
@@ -133,7 +142,7 @@ private:
133 * Telemetry fields visitor interface class. A backend to log to a web service should implement 142 * Telemetry fields visitor interface class. A backend to log to a web service should implement
134 * this interface. 143 * this interface.
135 */ 144 */
136struct VisitorInterface : NonCopyable { 145struct VisitorInterface {
137 virtual ~VisitorInterface() = default; 146 virtual ~VisitorInterface() = default;
138 147
139 virtual void Visit(const Field<bool>& field) = 0; 148 virtual void Visit(const Field<bool>& field) = 0;
@@ -160,8 +169,11 @@ struct VisitorInterface : NonCopyable {
160 * Empty implementation of VisitorInterface that drops all fields. Used when a functional 169 * Empty implementation of VisitorInterface that drops all fields. Used when a functional
161 * backend implementation is not available. 170 * backend implementation is not available.
162 */ 171 */
163struct NullVisitor : public VisitorInterface { 172struct NullVisitor final : public VisitorInterface {
164 ~NullVisitor() = default; 173 YUZU_NON_COPYABLE(NullVisitor);
174
175 NullVisitor() = default;
176 ~NullVisitor() override = default;
165 177
166 void Visit(const Field<bool>& /*field*/) override {} 178 void Visit(const Field<bool>& /*field*/) override {}
167 void Visit(const Field<double>& /*field*/) override {} 179 void Visit(const Field<double>& /*field*/) override {}