src/qvcore/qvapplication.h

Go to the documentation of this file.
00001 /*
00002  *      Copyright (C) 2007, 2008. PARP Research Group.
00003  *      <http://perception.inf.um.es>
00004  *      University of Murcia, Spain.
00005  *
00006  *      This file is part of the QVision library.
00007  *
00008  *      QVision is free software: you can redistribute it and/or modify
00009  *      it under the terms of the GNU Lesser General Public License as
00010  *      published by the Free Software Foundation, version 3 of the License.
00011  *
00012  *      QVision is distributed in the hope that it will be useful,
00013  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *      GNU Lesser General Public License for more details.
00016  *
00017  *      You should have received a copy of the GNU Lesser General Public
00018  *      License along with QVision. If not, see <http://www.gnu.org/licenses/>.
00019  */
00020 
00024 
00025 #ifndef QVAPPLICATION_H
00026 #define QVAPPLICATION_H
00027 
00028 #include <QSet>
00029 #include <QList>
00030 #include <QString>
00031 #include <QStringList>
00032 #include <QApplication>
00033 
00034 #include <qvdefines.h>
00035 
00036 class QVGUI;
00037 class QVPropertyContainer;
00038 class QVImageCanvas;
00039 
00040 #define qvApp ((QVApplication*) qApp)
00041 
00051 class QVApplication : public QApplication
00052 {
00053         Q_OBJECT
00054 public:
00068         QVApplication (int &argc, char **argv,
00069                                    QString info = QString(), bool GUIenabled = TRUE);
00070 
00086         int exec();
00087 
00095         void setTerminateOnLastWorker(bool terminate) { terminateOnLastWorker=terminate; };
00096 
00109         void setArgumentAsUsed(QString argument);
00110 
00120         QStringList getUnusedArguments();
00121 
00124         bool isRunning() { return isRunningFlag; };
00125 
00128         bool forHelp() { return forHelpFlag; };
00129 
00132         static QVApplication* instance() { return dynamic_cast<QVApplication*>(qApp); }
00133 
00134 #ifndef DOXYGEN_IGNORE_THIS
00135         void registerQVPropertyContainer(QVPropertyContainer *qvp);
00136         void deregisterQVPropertyContainer(QVPropertyContainer *qvp);
00137         void registerGUI(QVGUI *visionInterface);
00138         void deregisterGUI();
00139         QSet<QVPropertyContainer *> getQVPropertyContainers() { return qvps; };
00140 #endif
00141 
00142 public slots:
00146         bool startItems();
00147 
00153         void quitItems();
00154 
00159         void quit();
00160 
00161 private slots:
00162         void workerFinished();
00163 
00164 private:
00165         QString info;
00166         QStringList unusedArguments;
00167         QSet<QVPropertyContainer *> qvps;
00168         QVGUI *visionInterface;
00169         bool isRunningFlag;
00170         int workerCount;
00171         bool terminateOnLastWorker, forHelpFlag;
00172 
00173         void printHelp() const;
00174 };
00175 #endif // QVAPPLICATION_H