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

scripting/StelScriptMgr.hpp

00001 /*
00002  * Stellarium
00003  * Copyright (C) 2007 Fabien Chereau, 2009 Matthew Gates
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018  */
00019 
00020 #ifndef _STELSCRIPTMGR_HPP_
00021 #define _STELSCRIPTMGR_HPP_
00022 
00023 #include "VecMath.hpp"
00024 
00025 #include <QObject>
00026 #include <QtScript>
00027 #include <QStringList>
00028 #include <QFile>
00029 #include <QTime>
00030 
00031 class StelMainScriptAPI;
00032 
00033 #ifdef ENABLE_SCRIPT_CONSOLE
00034 class ScriptConsole;
00035 #endif
00036 
00038 class StelScriptMgr : public QObject
00039 {
00040     Q_OBJECT
00041         
00042 #ifdef ENABLE_SCRIPT_CONSOLE
00043 friend class ScriptConsole;
00044 #endif
00045 
00046 public:
00047     StelScriptMgr(QObject *parent=0);
00048     ~StelScriptMgr();
00049 
00050     QStringList getScriptList(void);
00051 
00054     bool scriptIsRunning(void);
00058     QString runningScriptId(void);
00059     
00060 public slots:
00067     const QString getName(const QString& s);
00068 
00075     const QString getAuthor(const QString& s);
00076 
00083     const QString getLicense(const QString& s);
00084 
00092     const QString getDescription(const QString& s);
00093 
00102     bool runScript(const QString& fileName, const QString& includePath="");
00103 
00106     bool stopScript(void);
00107 
00108     void setScriptRate(double r);
00109     double getScriptRate(void);
00110 
00113     void debug(const QString& msg);
00114 
00115 private slots:
00117     void scriptEnded();
00118 
00119 signals:
00121     void scriptRunning();
00123     void scriptStopped();
00125     void scriptDebug(const QString&);
00126 
00127 private:
00128     // Utility functions for preprocessor
00129     QMap<QString, QString> mappify(const QStringList& args, bool lowerKey=false);
00130     bool strToBool(const QString& str);
00131     // Pre-processor functions
00132     bool preprocessScript(QFile& input, QFile& output, const QString& scriptDir);
00133 
00134 #ifdef ENABLE_STRATOSCRIPT_COMPAT
00135     bool preprocessStratoScript(QFile& input, QFile& output, const QString& scriptDir);
00136 #endif
00137 
00144     const QString getHeaderSingleLineCommentText(const QString& s, const QString& id, const QString& notFoundText="");  
00145     QScriptEngine engine;
00146     
00148     class StelScriptThread* thread;
00149     StelMainScriptAPI *mainAPI;
00150 };
00151 
00152 #endif // _STELSCRIPTMGR_HPP_

Generated on Mon Mar 22 09:55:38 2010 for Stellarium by  doxygen 1.5.5