CConsoleHandler.h 589 B

1234567891011121314151617181920212223242526
  1. #ifndef CCONSOLEHANDLER_H
  2. #define CCONSOLEHANDLER_H
  3. namespace boost
  4. {
  5. template<typename signature>
  6. class function;
  7. }
  8. class DLL_EXPORT CConsoleHandler
  9. {
  10. public:
  11. boost::function<void(const std::string &)> *cb;
  12. int curLvl;
  13. int run();
  14. void setColor(int level);
  15. CConsoleHandler();
  16. ~CConsoleHandler();
  17. static void killConsole(void *hThread); //for windows only, use native handle to the thread
  18. template<typename T> void print(const T &data, int level)
  19. {
  20. setColor(level);
  21. std::cout << data << std::flush;
  22. setColor(-1);
  23. }
  24. };
  25. #endif //CCONSOLEHANDLER_H