NSCore::Thread_Template< ThreadClass > Class Template Reference

Run an object in its own thread. More...

#include <thread_template.h>

Inheritance diagram for NSCore::Thread_Template< ThreadClass >:

QThread
Collaboration diagram for NSCore::Thread_Template< ThreadClass >:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Thread_Template (QObject *p)
 Create a new thread object.
 ~Thread_Template ()
 Stop the thread and delete the thread object.
ThreadClass * item ()
 Access the threaded object.
bool waitForStarted ()
 wait till the thread is started and the object is created.

Private Member Functions

void run ()

Private Attributes

ThreadClass * _item


Detailed Description

template<class ThreadClass>
class NSCore::Thread_Template< ThreadClass >

Run an object in its own thread.

This runs whatever object you have in its own thread. Its basicly the same as inheriting from QThread but easier to apply to objects since there is no need for a new class. So you can use your classes in threaded and non-threaded environments without introducing new classes or changing existing ones.

The object of the thread is created at the start of run(), then a QEventLoop is running and when the thread gets stopped the object is deleted.

Also if you delete the thread-object itself the eventloop is stopped and the threaded object deleted.


Constructor & Destructor Documentation

template<class ThreadClass>
NSCore::Thread_Template< ThreadClass >::Thread_Template ( QObject p  )  [inline]

Create a new thread object.

template<class ThreadClass>
NSCore::Thread_Template< ThreadClass >::~Thread_Template (  )  [inline]

Stop the thread and delete the thread object.

References NSCore::Thread_Template< ThreadClass >::_item.


Member Function Documentation

template<class ThreadClass>
ThreadClass* NSCore::Thread_Template< ThreadClass >::item (  )  [inline]

Access the threaded object.

References NSCore::Thread_Template< ThreadClass >::_item.

Referenced by EMEAWindow::objectInNewThread().

template<class ThreadClass>
bool NSCore::Thread_Template< ThreadClass >::waitForStarted (  )  [inline]

wait till the thread is started and the object is created.

References NSCore::Thread_Template< ThreadClass >::_item.

Referenced by EMEAWindow::objectInNewThread().

template<class ThreadClass>
void NSCore::Thread_Template< ThreadClass >::run (  )  [inline, private]


Member Data Documentation

template<class ThreadClass>
ThreadClass* NSCore::Thread_Template< ThreadClass >::_item [private]


The documentation for this class was generated from the following file:

Generated on Tue Apr 12 02:10:29 2011 for epos by  doxygen 1.5.5