TinkerCell Core 1.0
TinkerCell's Core library providing all basic functionalities
Public Slots | Signals | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Slots | Protected Member Functions | Protected Attributes
Tinkercell::CThread Class Reference

This class is used to run specific functions inside a C dynamic library as a separate thread. The class can be used to load a library or just run a specific function inside an already loaded library. If the library is loaded by this class, the library will be unloaded upon completion on the function. To prevent the automatic unloading, use the setAutoUnload option. Only four types of functions are supported. More...

#include <CThread.h>

Collaboration diagram for Tinkercell::CThread:
Collaboration graph
[legend]

List of all members.

Public Slots

virtual void unload ()
 unload the C library
virtual void update ()
 call the callback function, if one exists

Signals

void setProgress (int)
 display progress of this thread (0-100). This signal is usually connected to a slot in ProgressBarSignalItem
void setTitle (const QString &)
void hideProgressBar ()
 hide the progress bar
void showProgressBar ()
 show the progress bar

Public Member Functions

virtual void showProgress (const QString &, int)
 show progress in a progress dialog
 CThread (MainWindow *main, QLibrary *lib=0, bool autoUnload=false)
 constructor
 CThread (MainWindow *main, const QString &lib, bool autoUnload=false)
 constructor
virtual ~CThread ()
 destructor. unload and deletes the library
virtual void setFunction (void(*f)(void), QSemaphore *sem=0)
 set the function to run inside this threads
virtual void setFunction (void(*f)(double), QSemaphore *sem=0)
 set the function to run inside this threads
virtual void setFunction (void(*f)(const char *), QSemaphore *sem=0)
 set the function to run inside this threads
virtual void setFunction (void(*f)(tc_matrix), QSemaphore *sem=0)
 set the function to run inside this threads
virtual void setVoidFunction (const char *, QSemaphore *sem=0)
 set the function to run inside this threads
virtual void setDoubleFunction (const char *, QSemaphore *sem=0)
 set the function to run inside this threads
virtual void setCharFunction (const char *, QSemaphore *sem=0)
 set the function to run inside this threads
virtual void setMatrixFunction (const char *, QSemaphore *sem=0)
 set the function to run inside this threads
virtual void setLibrary (QLibrary *)
 set the dynamic library for this threads. The library will be loaded if it has not already been loaded
virtual void setLibrary (const QString &)
 set the dynamic library for this threads.
virtual QLibrary * library ()
 the library used inside this thread
virtual void setAutoUnload (bool)
 set whether or not to automatically unload the library when the thread is done running
virtual bool autoUnload ()
 whether or not to automatically unload the library when the thread is done running
virtual void setArg (double, QSemaphore *sem=0)
 set the argument for the target function
virtual void setArg (const QString &, QSemaphore *sem=0)
 set the argument for the target function
virtual void setArg (const DataTable< qreal > &, QSemaphore *sem=0)
 set the argument for the target function

Static Public Member Functions

static QLibrary * loadLibrary (const QString &name, QObject *parent=0)
 search the default tinkercell folders for the library and load it

Public Attributes

MainWindowmainWindow
 main window

Static Public Attributes

static QList< CThread * > cthreads
 list stores pointers to different threads

Protected Slots

virtual void cleanupAfterTerminated ()
 cleanup (such as unload libraries) upon termination

Protected Member Functions

virtual void setupCFunctionPointers (QLibrary *lib=0)
 setup the C pointers in TC_Main.h
virtual void call_tc_main ()
 call tc_main
virtual void run ()
 the main function that runs one of the specified functions

Protected Attributes

bool hasDialog
bool autoUnloadLibrary
 whether or not to automatically unload the library when the thread is done running
void(* f1 )(void)
 one of the functions that can be run inside this thread
void(* f2 )(double)
 one of the functions that can be run inside this thread
void(* f3 )(const char *)
 one of the functions that can be run inside this thread
void(* f4 )(tc_matrix)
 one of the functions that can be run inside this thread
void(* callbackPtr )(void)
 callback function
void(* callWhenExitPtr )(void)
 call when exit function
QLibrary * lib
 the library where the functions are located that can be run inside this thread
double argDouble
 the argument for one of the the run function
QString argString
 the argument for one of the the run function
DataTable< qreal > argMatrix
 the argument for one of the the run function

Detailed Description

This class is used to run specific functions inside a C dynamic library as a separate thread. The class can be used to load a library or just run a specific function inside an already loaded library. If the library is loaded by this class, the library will be unloaded upon completion on the function. To prevent the automatic unloading, use the setAutoUnload option. Only four types of functions are supported.

Definition at line 50 of file CThread.h.


Constructor & Destructor Documentation

Tinkercell::CThread::CThread ( MainWindow main,
QLibrary *  lib = 0,
bool  autoUnload = false 
)

constructor

Parameters:
MainWindowthe Tinkercell main window
QLibrarythe dynamic library to load (optional)
boolwhether or not to automatically unload the library

Definition at line 54 of file CThread.cpp.

Here is the call graph for this function:

Tinkercell::CThread::CThread ( MainWindow main,
const QString &  lib,
bool  autoUnload = false 
)

constructor

Parameters:
MainWindowthe Tinkercell main window
QStringthe name of the dynamic library to load (optional)
boolwhether or not to automatically unload the library

Definition at line 74 of file CThread.cpp.

Here is the call graph for this function:

Tinkercell::CThread::~CThread ( ) [virtual]

destructor. unload and deletes the library

Definition at line 103 of file CThread.cpp.


Member Function Documentation

bool Tinkercell::CThread::autoUnload ( ) [virtual]

whether or not to automatically unload the library when the thread is done running

Returns:
bool

Definition at line 241 of file CThread.cpp.

void Tinkercell::CThread::call_tc_main ( ) [protected, virtual]

call tc_main

Definition at line 94 of file CThread.cpp.

Here is the caller graph for this function:

void Tinkercell::CThread::cleanupAfterTerminated ( ) [protected, virtual, slot]

cleanup (such as unload libraries) upon termination

Definition at line 292 of file CThread.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Tinkercell::CThread::hideProgressBar ( ) [signal]

hide the progress bar

Here is the caller graph for this function:

QLibrary * Tinkercell::CThread::library ( ) [virtual]

the library used inside this thread

Returns:
QLibrary*

Definition at line 231 of file CThread.cpp.

QLibrary * Tinkercell::CThread::loadLibrary ( const QString &  name,
QObject *  parent = 0 
) [static]

search the default tinkercell folders for the library and load it

Parameters:
QStringname of library (with or without full path)
QObjectparent
Returns:
QLibrary* the loaded library. 0 if cannot be loaded.

Definition at line 416 of file CThread.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Tinkercell::CThread::run ( ) [protected, virtual]

the main function that runs one of the specified functions

Definition at line 246 of file CThread.cpp.

Here is the call graph for this function:

void Tinkercell::CThread::setArg ( double  d,
QSemaphore *  sem = 0 
) [virtual]

set the argument for the target function

Parameters:
double

Definition at line 271 of file CThread.cpp.

Here is the caller graph for this function:

void Tinkercell::CThread::setArg ( const QString &  s,
QSemaphore *  sem = 0 
) [virtual]

set the argument for the target function

Parameters:
QString

Definition at line 278 of file CThread.cpp.

void Tinkercell::CThread::setArg ( const DataTable< qreal > &  dat,
QSemaphore *  sem = 0 
) [virtual]

set the argument for the target function

Parameters:
DataTable

Definition at line 285 of file CThread.cpp.

void Tinkercell::CThread::setAutoUnload ( bool  b) [virtual]

set whether or not to automatically unload the library when the thread is done running

Parameters:
bool

Definition at line 236 of file CThread.cpp.

void Tinkercell::CThread::setCharFunction ( const char *  f,
QSemaphore *  sem = 0 
) [virtual]

set the function to run inside this threads

Parameters:
voidname of the function inside the library that has been loaded in this thread.

Definition at line 155 of file CThread.cpp.

void Tinkercell::CThread::setDoubleFunction ( const char *  f,
QSemaphore *  sem = 0 
) [virtual]

set the function to run inside this threads

Parameters:
voidname of the function inside the library that has been loaded in this thread.

Definition at line 140 of file CThread.cpp.

void Tinkercell::CThread::setFunction ( void(*)(void)  f,
QSemaphore *  sem = 0 
) [virtual]

set the function to run inside this threads

Parameters:
voidfunction pointer

Definition at line 118 of file CThread.cpp.

Here is the caller graph for this function:

void Tinkercell::CThread::setFunction ( void(*)(double)  f,
QSemaphore *  sem = 0 
) [virtual]

set the function to run inside this threads

Parameters:
voidfunction pointer

Definition at line 133 of file CThread.cpp.

void Tinkercell::CThread::setFunction ( void(*)(const char *)  f,
QSemaphore *  sem = 0 
) [virtual]

set the function to run inside this threads

Parameters:
voidfunction pointer

Definition at line 148 of file CThread.cpp.

void Tinkercell::CThread::setFunction ( void(*)(tc_matrix)  f,
QSemaphore *  sem = 0 
) [virtual]

set the function to run inside this threads

Parameters:
voidfunction pointer

Definition at line 163 of file CThread.cpp.

void Tinkercell::CThread::setLibrary ( QLibrary *  lib) [virtual]

set the dynamic library for this threads. The library will be loaded if it has not already been loaded

Parameters:
QLibrary*library

Definition at line 204 of file CThread.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Tinkercell::CThread::setLibrary ( const QString &  libname) [virtual]

set the dynamic library for this threads.

Parameters:
QLibrary*library

Definition at line 219 of file CThread.cpp.

Here is the call graph for this function:

void Tinkercell::CThread::setMatrixFunction ( const char *  f,
QSemaphore *  sem = 0 
) [virtual]

set the function to run inside this threads

Parameters:
voidname of the function inside the library that has been loaded in this thread.

Definition at line 170 of file CThread.cpp.

Here is the caller graph for this function:

void Tinkercell::CThread::setProgress ( int  ) [signal]

display progress of this thread (0-100). This signal is usually connected to a slot in ProgressBarSignalItem

Here is the caller graph for this function:

void Tinkercell::CThread::setTitle ( const QString &  ) [signal]

set title of the dialog for this thread that shows the progress bar and kill button

Here is the caller graph for this function:

void Tinkercell::CThread::setupCFunctionPointers ( QLibrary *  lib = 0) [protected, virtual]

setup the C pointers in TC_Main.h

Definition at line 184 of file CThread.cpp.

Here is the caller graph for this function:

void Tinkercell::CThread::setVoidFunction ( const char *  f,
QSemaphore *  sem = 0 
) [virtual]

set the function to run inside this threads

Parameters:
voidname of the function inside the library that has been loaded in this thread.

Definition at line 125 of file CThread.cpp.

void Tinkercell::CThread::showProgress ( const QString &  title,
int  progress 
) [virtual]

show progress in a progress dialog

Parameters:
QStringtitle of the progress bar
intprogress in range 0-100

Definition at line 392 of file CThread.cpp.

Here is the call graph for this function:

void Tinkercell::CThread::showProgressBar ( ) [signal]

show the progress bar

Here is the caller graph for this function:

void Tinkercell::CThread::unload ( ) [virtual, slot]

unload the C library

Definition at line 304 of file CThread.cpp.

Here is the caller graph for this function:

void Tinkercell::CThread::update ( ) [virtual, slot]

call the callback function, if one exists

Definition at line 298 of file CThread.cpp.


Member Data Documentation

double Tinkercell::CThread::argDouble [protected]

the argument for one of the the run function

Definition at line 242 of file CThread.h.

the argument for one of the the run function

Definition at line 250 of file CThread.h.

QString Tinkercell::CThread::argString [protected]

the argument for one of the the run function

Definition at line 246 of file CThread.h.

whether or not to automatically unload the library when the thread is done running

Definition at line 210 of file CThread.h.

void(* Tinkercell::CThread::callbackPtr)(void) [protected]

callback function

Definition at line 230 of file CThread.h.

void(* Tinkercell::CThread::callWhenExitPtr)(void) [protected]

call when exit function

Definition at line 234 of file CThread.h.

list stores pointers to different threads

Definition at line 91 of file CThread.h.

void(* Tinkercell::CThread::f1)(void) [protected]

one of the functions that can be run inside this thread

Definition at line 214 of file CThread.h.

void(* Tinkercell::CThread::f2)(double) [protected]

one of the functions that can be run inside this thread

Definition at line 218 of file CThread.h.

void(* Tinkercell::CThread::f3)(const char *) [protected]

one of the functions that can be run inside this thread

Definition at line 222 of file CThread.h.

void(* Tinkercell::CThread::f4)(tc_matrix) [protected]

one of the functions that can be run inside this thread

Definition at line 226 of file CThread.h.

Definition at line 201 of file CThread.h.

QLibrary* Tinkercell::CThread::lib [protected]

the library where the functions are located that can be run inside this thread

Definition at line 238 of file CThread.h.

main window

Definition at line 197 of file CThread.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines