Jafar
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
init.hpp
00001 #ifndef _QDISPLAY_DISPLAYINIT_H_
00002 #define _QDISPLAY_DISPLAYINIT_H_
00003 
00004 #include <QObject>
00005 #include <QApplication>
00006 #include <QTimer>
00007 
00008 #include <boost/bind.hpp>
00009 #include <boost/thread/thread.hpp>
00010 #include "kernel/threads.hpp"
00011 
00012 namespace jafar {
00013 namespace qdisplay {
00014 
00021 //template<typename SharedDataStructure = void>
00022 class QtAppStart: public QObject
00023 {
00024   Q_OBJECT
00025   private:
00026     typedef void SharedDataStructure; // cannot use templates with q_object... sucks
00027     void (*main_)(SharedDataStructure*);
00028     void (*display_)(SharedDataStructure*);
00029     void (*onExit_)(SharedDataStructure*,boost::thread*);
00030     boost::thread *thread_main;
00031     QApplication *app;
00032     QTimer *timer;
00033     SharedDataStructure *sharedDataStructure;
00034     
00035   public:
00058     QtAppStart(void (*_display)(SharedDataStructure*), int prioDisplay = 0,
00059       void (*_main)(SharedDataStructure*) = NULL, int prioMain = 0,
00060       int display_interval = 0, SharedDataStructure *_sharedDataStructure = NULL, 
00061       void (*_onExit)(SharedDataStructure*,boost::thread*) = NULL);
00062     ~QtAppStart();
00063     
00064   public slots:
00065     void display();
00066     void onExit();
00067 };
00068 
00072 typedef void(*FUNC)(void*);
00073 typedef void(*EXIT_FUNC)(void*,boost::thread*);
00074 
00079 void qtSleep(int ms);
00080 
00085 template<class Mutex>
00086 void qtMutexLock(Mutex &mutex)
00087 {
00088   while (!mutex.try_lock())
00089     QApplication::instance()->processEvents();
00090 }
00091 
00092 }}
00093 
00094 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

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