1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
class Verbose
{
private:
static int _verboseLevel;
int _messageLevel;
public:
Verbose(int messageLevel = 0);
Verbose(const Verbose & source);
static void setVerboseLevel(int verboselevel);
static int getVerboseLevel();
void setMessageLevel(int messageLevel);
int getMessageLevel() const;
template<typename T> friend const Verbose & operator<<(const Verbose & verbose, const T & t)
{
if(verbose.getMessageLevel() <= verbose.getVerboseLevel())
std::cout << t;
return verbose;
}
friend const Verbose & operator <<(const Verbose & verbose, std::ostream& (*t)(std::ostream&))
{
if(verbose.getMessageLevel() <= verbose.getVerboseLevel())
std::cout << t;
return verbose;
}
}; |