geostat/debug.h

29 wiersze
661 B
C
Czysty Zwykły widok Historia

2019-09-08 16:42:10 +00:00
#pragma once
#include <iostream>
#include <string>
#include <sstream>
class Debug {
private:
int lvl; // debug level of the particular instance of Debug stream
static int debug_level; // debug level set globally
std::stringstream buffer;
2019-09-08 16:42:10 +00:00
public:
explicit Debug(int n);
2019-09-08 16:42:10 +00:00
~Debug();
// Copy constructor and assignment operators are deleted to prevent extra destructor and constructor calls when chaining << operator
Debug(const Debug&) = delete;
Debug& operator=(const Debug&) = delete;
template <typename T>
Debug& operator<<(T const& value) {
if (lvl <= debug_level)
buffer << value;
2019-09-08 16:42:10 +00:00
return *this;
}
static void set_debug_level(int n);
};