itom 2.0.0
D:/git-itom/sources/itom/Qitom/organizer/qsciApiManager.h
00001 /* ********************************************************************
00002     itom software
00003     URL: http://www.uni-stuttgart.de/ito
00004     Copyright (C) 2013, Institut für Technische Optik (ITO),
00005     Universität Stuttgart, Germany
00006 
00007     This file is part of itom.
00008   
00009     itom is free software; you can redistribute it and/or modify it
00010     under the terms of the GNU Library General Public Licence as published by
00011     the Free Software Foundation; either version 2 of the Licence, or (at
00012     your option) any later version.
00013 
00014     itom is distributed in the hope that it will be useful, but
00015     WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library
00017     General Public Licence for more details.
00018 
00019     You should have received a copy of the GNU Library General Public License
00020     along with itom. If not, see <http://www.gnu.org/licenses/>.
00021 *********************************************************************** */
00022 
00023 #ifndef QSCIAPIMANAGER_H
00024 #define QSCIAPIMANAGER_H
00025 
00026 // Under Windows, define QSCINTILLA_MAKE_DLL to create a Scintilla DLL, or
00027 // define QSCINTILLA_DLL to link against a Scintilla DLL, or define neither
00028 // to either build or link against a static Scintilla library.
00030 #define QSCINTILLA_DLL  //http://www.riverbankcomputing.com/pipermail/qscintilla/2007-March/000034.html
00031 
00032 #include <Qsci/qsciscintilla.h>
00033 #include <Qsci/qscilexerpython.h>
00034 #include "Qsci/qsciapis.h"
00035 
00036 #include <qstringlist.h>
00037 #include <qdatetime.h>
00038 
00039 namespace ito
00040 {
00041 
00042     class QsciApiManager : public QObject
00043     {
00044         Q_OBJECT
00045 
00046         public:
00047             static QsciApiManager * getInstance(void);
00048 
00049             inline QsciAPIs *getQsciAPIs() const { qDebug("return m_pApi"); return m_pApi; }
00050             inline bool isPreparing() const { return m_isPreparing; }
00051 
00052             int updateAPI(QStringList files, bool forcePreparation = false);
00053 
00054             struct APIFileInfo
00055             {
00056                 APIFileInfo() : absoluteFilename(""), checksum(0), exists(0) {}
00057                 public:
00058                     QString absoluteFilename;
00059                     quint16 checksum;
00060                     bool exists;
00061                     QDateTime lastModified;
00062 
00063                     //sorting depends on filename only
00064                     bool operator < (const APIFileInfo &rhs) const
00065                     {
00066                         return absoluteFilename < rhs.absoluteFilename;
00067                     }
00068             };
00069 
00070         protected:
00071 
00072         private:
00073             QsciApiManager(void);
00074             inline QsciApiManager(QsciApiManager  &/*copyConstr*/) : QObject(), m_isPreparing(0) {}
00075             ~QsciApiManager(void);
00076 
00077             QsciAPIs* m_pApi;
00078             QsciLexerPython* m_qSciLex;
00079 
00080             bool m_isPreparing;
00081             QList<APIFileInfo> m_preparingAPIFiles;
00082             QString m_preparingFileInfo;
00083 
00084             bool m_loaded;
00085 
00086             static QsciApiManager *m_pQsciApiManager;
00087 
00089             class QsciApiSingleton
00090             {
00091                 public:
00092                     ~QsciApiSingleton()
00093                     {
00094                         #pragma omp critical
00095                         {
00096                             if( QsciApiManager::m_pQsciApiManager != NULL)
00097                             {
00098                                 delete QsciApiManager::m_pQsciApiManager;
00099                                 QsciApiManager::m_pQsciApiManager = NULL;
00100                             }
00101                         }
00102                     }
00103             };
00104             friend class QsciApiSingleton;
00105 
00106         signals:
00107 
00108         public slots:
00109 
00110         private slots:
00111             void apiPreparationFinished();
00112             void apiPreparationCancelled();
00113             void apiPreparationStarted();
00114     };
00115 } //namespace ito
00116 
00117 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends