Jafar
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Slots | Public Member Functions | Private Types | Private Attributes
jafar::qdisplay::QtAppStart Class Reference

This class provides a simple way to control a qt display from c++, dealing with all the constraints of qt. More...


Detailed Description

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...

Definition at line 22 of file init.hpp.

#include <init.hpp>

List of all members.

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

Constructor & Destructor Documentation

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.

Parameters:
_displaythe function that does the display. Must return void and accept one parameter which is a pointer, and must be cast to qdisplay::FUNC.
prioDisplaythe priority of the display thread (unix process priority : -20 (most priority) to 20
_mainthe optional function that executes the main program in another thread (see _display)
prioMainthe priority of the main thread (see prioDisplay)
display_intervalthe interval in ms at which the display function is called. 0 means only once.
_sharedDataStructurethe data structure that is passed to _main and _display functions
_onExitthe 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

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

Generated on Wed Oct 15 2014 00:37:43 for Jafar by doxygen 1.7.6.1
LAAS-CNRS