|
Urbi SDK Remote for C++
2.7.3
|
00001 /* 00002 * Copyright (C) 2004-2011, Gostai S.A.S. 00003 * 00004 * This software is provided "as is" without warranty of any kind, 00005 * either expressed or implied, including but not limited to the 00006 * implied warranties of fitness for a particular purpose. 00007 * 00008 * See the LICENSE file for more information. 00009 */ 00010 00011 #ifndef URBI_QT_UMAIN_HH 00012 # define URBI_QT_UMAIN_HH 00013 00014 # include <urbi/usyncclient.hh> 00015 # include <urbi/uobject.hh> 00016 # include <libport/windows.hh> 00017 # ifndef WIN32 00018 # include <libport/unistd.h> 00019 # endif 00020 00021 # ifdef URBI_ENV_REMOTE 00022 00023 # include <QApplication> 00024 # include <QObject> 00025 00033 # define UMAIN() \ 00034 namespace urbi \ 00035 { \ 00036 \ 00037 class ProcessUrbiEvent: \ 00038 public ::QObject \ 00039 { \ 00040 public: \ 00041 \ 00042 ProcessUrbiEvent ( QObject* parent = 0 ) \ 00043 : QObject (parent) \ 00044 { \ 00045 startTimer(3); \ 00046 \ 00047 cl = dynamic_cast<urbi::USyncClient*> \ 00048 (urbi::getDefaultClient ()); \ 00049 cl->stopCallbackThread (); \ 00050 } \ 00051 \ 00052 protected: \ 00053 \ 00054 void \ 00055 timerEvent ( QTimerEvent* ) \ 00056 { \ 00057 if (cl) \ 00058 cl->processEvents(3 * 1000); \ 00059 } \ 00060 \ 00061 protected: \ 00062 urbi::USyncClient* cl; \ 00063 \ 00064 }; \ 00065 } \ 00066 \ 00067 int main(int argc, char *argv[]) \ 00068 { \ 00069 urbi::main(argc, (const char**)argv, false); \ 00070 \ 00071 QApplication app (argc, argv) ; \ 00072 urbi::ProcessUrbiEvent obj; \ 00073 \ 00074 return app.exec(); \ 00075 } 00076 # else 00077 # define UMAIN() 00078 # endif /* !URBI_ENV_REMOTE */ 00079 00080 #endif /* !URBI_QT_UMAIN_HH */