summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorGravatar Morph2022-02-02 16:04:26 -0500
committerGravatar GitHub2022-02-02 16:04:26 -0500
commitd68eb751c53df785f842d56983ce4dfbb89aae3f (patch)
tree510752a162e2bbb0e0f5a1e60b499aa4dca0493e /src/common
parentMerge pull request #7834 from german77/repeat (diff)
parentcommon_types: Remove NonCopyable struct (diff)
downloadyuzu-d68eb751c53df785f842d56983ce4dfbb89aae3f.tar.gz
yuzu-d68eb751c53df785f842d56983ce4dfbb89aae3f.tar.xz
yuzu-d68eb751c53df785f842d56983ce4dfbb89aae3f.zip
Merge pull request #7838 from lioncash/noncopy
common_types: Remove NonCopyable struct
Diffstat (limited to 'src/common')
-rw-r--r--src/common/common_types.h10
-rw-r--r--src/common/telemetry.h26
2 files changed, 17 insertions, 19 deletions
diff --git a/src/common/common_types.h b/src/common/common_types.h
index 4cec89fbd..99bffc460 100644
--- a/src/common/common_types.h
+++ b/src/common/common_types.h
@@ -46,13 +46,3 @@ using GPUVAddr = u64; ///< Represents a pointer in the GPU virtual address space
46 46
47using u128 = std::array<std::uint64_t, 2>; 47using u128 = std::array<std::uint64_t, 2>;
48static_assert(sizeof(u128) == 16, "u128 must be 128 bits wide"); 48static_assert(sizeof(u128) == 16, "u128 must be 128 bits wide");
49
50// An inheritable class to disallow the copy constructor and operator= functions
51class NonCopyable {
52protected:
53 constexpr NonCopyable() = default;
54 ~NonCopyable() = default;
55
56 NonCopyable(const NonCopyable&) = delete;
57 NonCopyable& operator=(const NonCopyable&) = delete;
58};
diff --git a/src/common/telemetry.h b/src/common/telemetry.h
index 49186e848..d38aeac99 100644
--- a/src/common/telemetry.h
+++ b/src/common/telemetry.h
@@ -8,6 +8,7 @@
8#include <map> 8#include <map>
9#include <memory> 9#include <memory>
10#include <string> 10#include <string>
11#include "common/common_funcs.h"
11#include "common/common_types.h" 12#include "common/common_types.h"
12 13
13namespace Common::Telemetry { 14namespace Common::Telemetry {
@@ -28,7 +29,7 @@ struct VisitorInterface;
28/** 29/**
29 * Interface class for telemetry data fields. 30 * Interface class for telemetry data fields.
30 */ 31 */
31class FieldInterface : NonCopyable { 32class FieldInterface {
32public: 33public:
33 virtual ~FieldInterface() = default; 34 virtual ~FieldInterface() = default;
34 35
@@ -52,14 +53,15 @@ public:
52template <typename T> 53template <typename T>
53class Field : public FieldInterface { 54class Field : public FieldInterface {
54public: 55public:
56 YUZU_NON_COPYABLE(Field);
57
55 Field(FieldType type_, std::string name_, T value_) 58 Field(FieldType type_, std::string name_, T value_)
56 : name(std::move(name_)), type(type_), value(std::move(value_)) {} 59 : name(std::move(name_)), type(type_), value(std::move(value_)) {}
57 60
58 Field(const Field&) = default; 61 ~Field() override = default;
59 Field& operator=(const Field&) = default;
60 62
61 Field(Field&&) = default; 63 Field(Field&&) noexcept = default;
62 Field& operator=(Field&& other) = default; 64 Field& operator=(Field&& other) noexcept = default;
63 65
64 void Accept(VisitorInterface& visitor) const override; 66 void Accept(VisitorInterface& visitor) const override;
65 67
@@ -98,9 +100,15 @@ private:
98/** 100/**
99 * Collection of data fields that have been logged. 101 * Collection of data fields that have been logged.
100 */ 102 */
101class FieldCollection final : NonCopyable { 103class FieldCollection final {
102public: 104public:
105 YUZU_NON_COPYABLE(FieldCollection);
106
103 FieldCollection() = default; 107 FieldCollection() = default;
108 ~FieldCollection() = default;
109
110 FieldCollection(FieldCollection&&) noexcept = default;
111 FieldCollection& operator=(FieldCollection&&) noexcept = default;
104 112
105 /** 113 /**
106 * Accept method for the visitor pattern, visits each field in the collection. 114 * Accept method for the visitor pattern, visits each field in the collection.
@@ -133,7 +141,7 @@ private:
133 * Telemetry fields visitor interface class. A backend to log to a web service should implement 141 * Telemetry fields visitor interface class. A backend to log to a web service should implement
134 * this interface. 142 * this interface.
135 */ 143 */
136struct VisitorInterface : NonCopyable { 144struct VisitorInterface {
137 virtual ~VisitorInterface() = default; 145 virtual ~VisitorInterface() = default;
138 146
139 virtual void Visit(const Field<bool>& field) = 0; 147 virtual void Visit(const Field<bool>& field) = 0;
@@ -160,8 +168,8 @@ struct VisitorInterface : NonCopyable {
160 * Empty implementation of VisitorInterface that drops all fields. Used when a functional 168 * Empty implementation of VisitorInterface that drops all fields. Used when a functional
161 * backend implementation is not available. 169 * backend implementation is not available.
162 */ 170 */
163struct NullVisitor : public VisitorInterface { 171struct NullVisitor final : public VisitorInterface {
164 ~NullVisitor() = default; 172 YUZU_NON_COPYABLE(NullVisitor);
165 173
166 void Visit(const Field<bool>& /*field*/) override {} 174 void Visit(const Field<bool>& /*field*/) override {}
167 void Visit(const Field<double>& /*field*/) override {} 175 void Visit(const Field<double>& /*field*/) override {}