Stellarium 0.11.3
Home · All Namespaces · All Classes · Functions · Coding Style · Scripting · Plugins · File Structure

core/SimbadSearcher.hpp

00001 /*
00002  * Copyright (C) 2008 Fabien Chereau
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
00017  */
00018 
00019 #ifndef SIMBADSEARCHER_HPP_
00020 #define SIMBADSEARCHER_HPP_
00021 
00022 #include "VecMath.hpp"
00023 #include <QObject>
00024 #include <QMap>
00025 
00026 class QNetworkReply;
00027 class QNetworkAccessManager;
00028 
00032 class SimbadLookupReply : public QObject
00033 {
00034     Q_OBJECT
00035     Q_ENUMS(SimbadLookupStatus);
00036 
00037 public:
00038     friend class SimbadSearcher;
00039 
00041     enum SimbadLookupStatus
00042     {
00043         SimbadLookupQuerying,       
00044         SimbadLookupErrorOccured,   
00045         SimbadLookupFinished        
00046     };
00047 
00048     ~SimbadLookupReply();
00049 
00051     QMap<QString, Vec3d> getResults() const {return resultPositions;}
00052 
00054     SimbadLookupStatus getCurrentStatus() const {return currentStatus;}
00055 
00057     QString getCurrentStatusString() const;
00058 
00060     QString getErrorString() const {return errorString;}
00061 
00062 signals:
00064     void statusChanged();
00065 
00066 private slots:
00067     void httpQueryFinished();
00068     void delayTimerCompleted();
00069 
00070 private:
00072     SimbadLookupReply(const QString& url, QNetworkAccessManager* mgr, int delayMs=500);
00073 
00074     QString url;
00075 
00077     QNetworkReply* reply;
00078     QNetworkAccessManager* netMgr;
00079 
00081     QMap<QString, Vec3d> resultPositions;
00082 
00084     SimbadLookupStatus currentStatus;
00085 
00087     QString errorString;
00088 };
00089 
00090 
00094 class SimbadSearcher : public QObject
00095 {
00096     Q_OBJECT
00097 
00098 public:
00099     SimbadSearcher(QObject* parent);
00100 
00108     SimbadLookupReply* lookup(const QString& serverUrl, const QString& objectName, int maxNbResult=1, int delayMs=500);
00109 
00110 private:
00112     QNetworkAccessManager* networkMgr;
00113 };
00114 
00115 #endif /*SIMBADSEARCHER_HPP_*/
Generated on Thu May 31 10:37:18 2012 for Stellarium by  doxygen 1.6.3