summaryrefslogtreecommitdiffhomepage
path: root/debug.h
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2025-01-03 15:36:22 +0100
committerRoland Reichwein <mail@reichwein.it>2025-01-03 15:36:22 +0100
commit9de0b7f8937b7f6ce990132609f0b26851b31f2b (patch)
treea69f73358c9b75e5a11c9ed18d934964461360bf /debug.h
parent05895c86bddf50aacb3bb5e6a6bcc073965341ef (diff)
Monitor CPU
Diffstat (limited to 'debug.h')
-rw-r--r--debug.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/debug.h b/debug.h
new file mode 100644
index 0000000..1965de0
--- /dev/null
+++ b/debug.h
@@ -0,0 +1,40 @@
+#pragma once
+
+#include <iostream>
+#include <ostream>
+
+class debug_ostream
+{
+public:
+ debug_ostream(): m_active(false) {}
+
+ void activate()
+ {
+ m_active = true;
+ }
+
+ void deactivate()
+ {
+ m_active = false;
+ }
+
+ template<typename T>
+ debug_ostream& operator<<(const T& arg) {
+ if (m_active)
+ std::cout << arg;
+ return *this;
+ }
+
+ debug_ostream& operator<<(
+ std::basic_ostream<char>& (*func)
+ (std::basic_ostream<char>&) ) {
+ if (m_active)
+ std::cout << *func;
+ return *this;
+ }
+
+private:
+ bool m_active;
+};
+
+extern debug_ostream debug_cout;