Jafar
|
This class provides a simple way to control a qt display from c++, dealing with all the constraints of qt. More...
This class provides a simple way to control a qt display from c++, dealing with all the constraints of qt.
Cannot use a template type because it is incompatible with Qt, so use a void* for the shared data structure...
#include <init.hpp>
Public Slots | |
void | display () |
void | onExit () |
Public Member Functions | |
QtAppStart (void(*_display)(SharedDataStructure *), int prioDisplay=0, void(*_main)(SharedDataStructure *)=NULL, int prioMain=0, int display_interval=0, SharedDataStructure *_sharedDataStructure=NULL, void(*_onExit)(SharedDataStructure *, boost::thread *)=NULL) | |
If you want a single thread, only specify display, otherwise main and display will run in parallel (they can create other threads), communicate data with sharedDataStructure and must synchronize using a kernel::FifoMutex in sharedDataStructure. | |
Private Types | |
typedef void | SharedDataStructure |
Private Attributes | |
void(* | main_ )(SharedDataStructure *) |
void(* | display_ )(SharedDataStructure *) |
void(* | onExit_ )(SharedDataStructure *, boost::thread *) |
boost::thread * | thread_main |
QApplication * | app |
QTimer * | timer |
SharedDataStructure * | sharedDataStructure |
jafar::qdisplay::QtAppStart::QtAppStart | ( | void(*)(SharedDataStructure *) | _display, |
int | prioDisplay = 0 , |
||
void(*)(SharedDataStructure *) | _main = NULL , |
||
int | prioMain = 0 , |
||
int | display_interval = 0 , |
||
SharedDataStructure * | _sharedDataStructure = NULL , |
||
void(*)(SharedDataStructure *, boost::thread *) | _onExit = NULL |
||
) |
If you want a single thread, only specify display, otherwise main and display will run in parallel (they can create other threads), communicate data with sharedDataStructure and must synchronize using a kernel::FifoMutex in sharedDataStructure.
If you want the display task to be executed periodically, specify diplay_interval (ms), otherwise it will be called only once, but the display task must execute "QApplication::instance()->processEvents();" regularly so that the display is refreshed. Moreover if you want to sleep or lock a mutex, you should use qtSleep and qtMutexLock functions so that the display is refreshed.
_display | the function that does the display. Must return void and accept one parameter which is a pointer, and must be cast to qdisplay::FUNC. |
prioDisplay | the priority of the display thread (unix process priority : -20 (most priority) to 20 |
_main | the optional function that executes the main program in another thread (see _display) |
prioMain | the priority of the main thread (see prioDisplay) |
display_interval | the interval in ms at which the display function is called. 0 means only once. |
_sharedDataStructure | the data structure that is passed to _main and _display functions |
_onExit | the optional function that is executed just before the application terminates because all windows are closed. Must return void and accept two parameters, a void pointer and a pointer to the main thread, to have the possibility to join it. The function must be cast to qdisplay::EXIT_FUNC |
Generated on Wed Oct 15 2014 00:37:43 for Jafar by doxygen 1.7.6.1 |