2007-08-15 18:13:11 +03:00
|
|
|
#ifndef CCONSOLEHANDLER_H
|
|
|
|
#define CCONSOLEHANDLER_H
|
2008-09-18 23:24:53 +03:00
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
#define WORD std::string
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
#define _kill_thread(a,b) pthread_cancel(a);
|
|
|
|
#else
|
|
|
|
#define _kill_thread(a,b) TerminateThread(a,b);
|
|
|
|
#endif
|
|
|
|
|
2008-09-17 13:18:22 +03:00
|
|
|
namespace boost
|
|
|
|
{
|
|
|
|
template<typename signature>
|
|
|
|
class function;
|
|
|
|
}
|
|
|
|
class DLL_EXPORT CConsoleHandler
|
2007-08-15 18:13:11 +03:00
|
|
|
{
|
|
|
|
public:
|
2008-09-17 13:18:22 +03:00
|
|
|
boost::function<void(const std::string &)> *cb;
|
|
|
|
int curLvl;
|
|
|
|
int run();
|
|
|
|
void setColor(int level);
|
|
|
|
CConsoleHandler();
|
|
|
|
~CConsoleHandler();
|
2008-09-18 23:24:53 +03:00
|
|
|
#ifndef _WIN32
|
|
|
|
static void killConsole(pthread_t hThread); //for windows only, use native handle to the thread
|
|
|
|
#else
|
2008-09-17 13:18:22 +03:00
|
|
|
static void killConsole(void *hThread); //for windows only, use native handle to the thread
|
2008-09-18 23:24:53 +03:00
|
|
|
#endif
|
2008-09-17 13:18:22 +03:00
|
|
|
template<typename T> void print(const T &data, int level)
|
|
|
|
{
|
|
|
|
setColor(level);
|
|
|
|
std::cout << data << std::flush;
|
|
|
|
setColor(-1);
|
|
|
|
}
|
2007-08-15 18:13:11 +03:00
|
|
|
};
|
|
|
|
|
2008-08-02 18:08:03 +03:00
|
|
|
#endif //CCONSOLEHANDLER_H
|