#ifndef THREAD_HH #define THREAD_HH #include #include using namespace std; template class Thread { private: boost::thread* thread; bool isRunning; public: // Ctor Thread() : thread(NULL), isRunning(false) { } virtual ~Thread() { kill(); } void start() { T* derived = dynamic_cast(this); thread = new boost::thread(boost::bind(&Thread::doIt, this, boost::ref(*derived))); } void doIt(T& derived) { } bool isFinished() { return isRunning; } void join() { if(thread) { thread->join(); } } void kill() { if(thread) { thread->interrupt(); delete thread; thread = NULL; } } }; #endif