Files
vcmi/CConsoleHandler.h
T

46 lines
1022 B
C++
Raw Normal View History

2009-04-16 11:14:13 +00:00
#ifndef __CCONSOLEHANDLER_H__
#define __CCONSOLEHANDLER_H__
/*
* CConsoleHandler.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
2009-04-16 11:14:13 +00:00
*/
namespace boost
{
template<typename signature>
class function;
2009-06-23 08:14:49 +00:00
class thread;
2009-04-16 11:14:13 +00:00
}
2009-06-23 08:14:49 +00:00
2009-04-16 11:14:13 +00:00
class DLL_EXPORT CConsoleHandler
{
public:
boost::function<void(const std::string &)> *cb; //function to be called when message is received
int curLvl; //logging level
2009-06-23 08:14:49 +00:00
boost::thread *thread;
2009-04-16 11:14:13 +00:00
int run();
void setColor(int level); //sets color of text appropriate for given logging level
2009-06-23 08:14:49 +00:00
CConsoleHandler(); //c-tor
~CConsoleHandler(); //d-tor
2009-06-23 08:14:49 +00:00
void start(); //starts listening thread
void end(); //kills listening thread
2009-04-16 11:14:13 +00:00
template<typename T> void print(const T &data, int level)
{
setColor(level);
std::cout << data << std::flush;
setColor(-1);
}
};
#endif // __CCONSOLEHANDLER_H__