00001 /****************************************************************************** 00002 * This file is part of the Gluon Development Platform 00003 * Copyright (C) 2010 Dan Leinir Turthra Jensen <admin@leinir.dk> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library 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 GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 */ 00019 00020 #ifndef GLUONENGINE_SCRIPTINGENGINE_H 00021 #define GLUONENGINE_SCRIPTINGENGINE_H 00022 00023 #include "gluon_engine_export.h" 00024 #include "gameobject.h" 00025 00026 #include <core/singleton.h> 00027 00028 #include <QScriptValue> 00029 #include <QScriptEngine> 00030 00031 namespace GluonEngine 00032 { 00033 class ScriptingAsset; 00034 class GLUON_ENGINE_EXPORT ScriptingEngine : public GluonCore::Singleton<ScriptingEngine> 00035 { 00036 Q_OBJECT 00037 00038 public Q_SLOTS: 00044 QScriptSyntaxCheckResult registerAsset( const GluonEngine::ScriptingAsset* asset ); 00050 bool unregisterAsset( const GluonEngine::ScriptingAsset* asset ) const; 00056 bool isRegistered( const GluonEngine::ScriptingAsset* asset ) const; 00057 00062 QString className( const GluonEngine::ScriptingAsset* asset ) const; 00068 QScriptValue instantiateClass( const GluonEngine::ScriptingAsset* asset ) const; 00074 QScriptValue instantiateClass( const QString& className ) const; 00075 00076 QScriptEngine* scriptEngine() const; 00077 00078 private: 00079 friend class GluonCore::Singleton<ScriptingEngine>; 00080 00081 ScriptingEngine( QObject* parent = 0 ); 00082 ~ScriptingEngine(); 00083 00084 Q_DISABLE_COPY( ScriptingEngine ); 00085 00086 class Private; 00087 Private* d; 00088 }; 00089 } 00090 00091 QScriptValue GLUON_ENGINE_EXPORT gameObjectToScriptValue( QScriptEngine* engine, GluonEngine::GameObject*const& in ); 00092 void GLUON_ENGINE_EXPORT gameObjectFromScriptValue( const QScriptValue& object, GluonEngine::GameObject *&out ); 00093 QScriptValue GLUON_ENGINE_EXPORT gluonObjectToScriptValue( QScriptEngine* engine, GluonCore::GluonObject*const& in ); 00094 void GLUON_ENGINE_EXPORT gluonObjectFromScriptValue( const QScriptValue& object, GluonCore::GluonObject*& out ); 00095 00096 #endif // GLUONENGINE_SCRIPTINGENGINE_H