Home · All Namespaces · All Classes · Functions · Coding Style · 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, 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 
00031 class SimbadLookupReply : public QObject
00032 {
00033     Q_OBJECT
00034     Q_ENUMS(SimbadLookupStatus);
00035     
00036 public:
00037     friend class SimbadSearcher;
00038     
00040     enum SimbadLookupStatus
00041     {
00042         SimbadLookupQuerying,       
00043         SimbadLookupErrorOccured,   
00044         SimbadLookupFinished        
00045     };
00046 
00047     ~SimbadLookupReply();
00048     
00050     QMap<QString, Vec3d> getResults() const {return resultPositions;}
00051     
00053     SimbadLookupStatus getCurrentStatus() const {return currentStatus;}
00054     
00056     QString getCurrentStatusString() const;
00057     
00059     QString getErrorString() const {return errorString;}
00060     
00061 signals:
00063     void statusChanged();
00064     
00065 private slots:
00066     void httpQueryFinished();
00067     
00068 private:
00070     SimbadLookupReply(QNetworkReply* r);
00071     
00073     QNetworkReply* reply;
00074     
00076     QMap<QString, Vec3d> resultPositions;
00077     
00079     SimbadLookupStatus currentStatus;
00080     
00082     QString errorString;
00083 };
00084 
00085 
00089 class SimbadSearcher : public QObject
00090 {
00091     Q_OBJECT
00092 
00093 public:
00094     SimbadSearcher(QObject* parent);
00095 
00100     SimbadLookupReply* lookup(const QString& objectName, int maxNbResult=1);
00101         
00102 private:    
00104     class QNetworkAccessManager* networkMgr;
00105 };
00106 
00107 #endif /*SIMBADSEARCHER_HPP_*/

Generated on Mon Feb 2 17:23:47 2009 for Stellarium by  doxygen 1.5.5