OpenWalnut
1.4.0
|
00001 //--------------------------------------------------------------------------- 00002 // 00003 // Project: OpenWalnut ( http://www.openwalnut.org ) 00004 // 00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS 00006 // For more information see http://www.openwalnut.org/copying 00007 // 00008 // This file is part of OpenWalnut. 00009 // 00010 // OpenWalnut is free software: you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as published by 00012 // the Free Software Foundation, either version 3 of the License, or 00013 // (at your option) any later version. 00014 // 00015 // OpenWalnut is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 // GNU Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public License 00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>. 00022 // 00023 //--------------------------------------------------------------------------- 00024 00025 #ifndef WSCRIPTENGINE_H 00026 #define WSCRIPTENGINE_H 00027 00028 #include <string> 00029 #include <vector> 00030 00031 #include <boost/shared_ptr.hpp> 00032 00033 #include "../kernel/WModuleContainer.h" 00034 00035 #include "WScriptInterpreter.h" 00036 00037 /** 00038 * The script engine. Provides all script interpreters available for the OpenWalnut installation. Which 00039 * interpreters are available depends on the libs available at OpenWalnut build time. 00040 */ 00041 class WScriptEngine 00042 { 00043 public: 00044 /** 00045 * Constructs a new script engine. 00046 * 00047 * \param rootContainer The root module container to use for modules inserted via scripts. 00048 */ 00049 explicit WScriptEngine( boost::shared_ptr< WModuleContainer > const& rootContainer ); 00050 00051 /** 00052 * Destructor. 00053 */ 00054 virtual ~WScriptEngine(); 00055 00056 /** 00057 * This finds an interpreter suitable for executing script files ending with the given extension. 00058 * 00059 * \param ext The extension of the script file to execute. 00060 * 00061 * \return The matching script interpreter or a NULL-pointer, if no such interpreter was available. 00062 */ 00063 boost::shared_ptr< WScriptInterpreter > getInterpreterByFileExtension( std::string const& ext ); 00064 00065 /** 00066 * This finds an interpreter by script language name. 00067 * 00068 * \param name The name of the script language. 00069 * 00070 * \return The matching script interpreter or a NULL-pointer, if no such interpreter was available. 00071 */ 00072 boost::shared_ptr< WScriptInterpreter > getInterpreter( std::string const& name ); 00073 00074 /** 00075 * Get the number of script interpreters available. 00076 * 00077 * \return The number of available script interpreters. 00078 */ 00079 std::size_t getNumInterpreters() const; 00080 00081 /** 00082 * Get the i'th script interpreter. 00083 * 00084 * \param index The index of the script interpreter to retrieve, must be in [0,getNumInterpreters()-1]. 00085 * 00086 * \return The script interpreter or a NULL-pointer if the index was invalid. 00087 */ 00088 boost::shared_ptr< WScriptInterpreter > getInterpreter( std::size_t index ); 00089 00090 private: 00091 //! The list of available script interpreters. 00092 std::vector< boost::shared_ptr< WScriptInterpreter > > m_interpreters; 00093 }; 00094 00095 #endif // WSCRIPTENGINE_H