00001
00014 #ifndef _DLR_THREAD_THREADFUNCTOR_H_
00015 #define _DLR_THREAD_THREADFUNCTOR_H_
00016
00017 #include <string>
00018 #include <boost/thread.hpp>
00019
00020 namespace dlr {
00021
00022 namespace thread {
00023
00088 class ThreadFunctor
00089 {
00090 public:
00091
00101 ThreadFunctor(const std::string& threadName="anonymous")
00102 : m_threadName(threadName), m_threadPtr(0) {};
00103
00104
00113 ThreadFunctor(const ThreadFunctor& source)
00114 : m_threadName(source.m_threadName), m_threadPtr(0) {};
00115
00116
00121 virtual
00122 ~ThreadFunctor();
00123
00124
00137 ThreadFunctor&
00138 operator=(const ThreadFunctor& source);
00139
00140
00149 virtual void
00150 operator()();
00151
00152
00159 const std::string&
00160 getThreadName() {return m_threadName;}
00161
00162
00180 virtual void
00181 handleError(const std::string& errorMessage,
00182 const std::string& errorDetail);
00183
00184
00190 void
00191 join();
00192
00193
00199 virtual void
00200 main() = 0;
00201
00202
00208 void
00209 run();
00210
00211
00222 void
00223 setName(const std::string& threadName) {m_threadName = threadName;}
00224
00225 protected:
00226
00227 std::string m_threadName;
00228 boost::thread* m_threadPtr;
00229 };
00230
00231 }
00232
00233 }
00234
00235 #endif