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