Chatterino
DebugCount.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 
5 #include <mutex>
6 #include <typeinfo>
7 
8 #include <QMap>
9 #include <QString>
10 
11 namespace chatterino {
12 
14 {
15 public:
16  static void increase(const QString &name)
17  {
18  auto counts = counts_.access();
19 
20  auto it = counts->find(name);
21  if (it == counts->end())
22  {
23  counts->insert(name, 1);
24  }
25  else
26  {
27  reinterpret_cast<int64_t &>(it.value())++;
28  }
29  }
30  static void increase(const QString &name, const int64_t &amount)
31  {
32  auto counts = counts_.access();
33 
34  auto it = counts->find(name);
35  if (it == counts->end())
36  {
37  counts->insert(name, amount);
38  }
39  else
40  {
41  reinterpret_cast<int64_t &>(it.value()) += amount;
42  }
43  }
44 
45  static void decrease(const QString &name)
46  {
47  auto counts = counts_.access();
48 
49  auto it = counts->find(name);
50  if (it == counts->end())
51  {
52  counts->insert(name, -1);
53  }
54  else
55  {
56  reinterpret_cast<int64_t &>(it.value())--;
57  }
58  }
59  static void decrease(const QString &name, const int64_t &amount)
60  {
61  auto counts = counts_.access();
62 
63  auto it = counts->find(name);
64  if (it == counts->end())
65  {
66  counts->insert(name, -amount);
67  }
68  else
69  {
70  reinterpret_cast<int64_t &>(it.value()) -= amount;
71  }
72  }
73 
74  static QString getDebugText()
75  {
76  auto counts = counts_.access();
77 
78  QString text;
79  for (auto it = counts->begin(); it != counts->end(); it++)
80  {
81  text += it.key() + ": " + QString::number(it.value()) + "\n";
82  }
83  return text;
84  }
85 
86  QString toString()
87  {
88  return "";
89  }
90 
91 private:
93 };
94 
95 } // namespace chatterino
static QString getDebugText()
Definition: DebugCount.hpp:74
Definition: Application.cpp:48
QString toString()
Definition: DebugCount.hpp:86
AccessGuard< T > access() const
Definition: UniqueAccess.hpp:83
Definition: DebugCount.hpp:13
Definition: UniqueAccess.hpp:53
static void increase(const QString &name)
Definition: DebugCount.hpp:16
static void decrease(const QString &name)
Definition: DebugCount.hpp:45
QString name
Definition: Credentials.cpp:94
static void decrease(const QString &name, const int64_t &amount)
Definition: DebugCount.hpp:59
static void increase(const QString &name, const int64_t &amount)
Definition: DebugCount.hpp:30