OpenWalnut  1.4.0
WScriptInterpreter.h
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 WSCRIPTINTERPRETER_H
00026 #define WSCRIPTINTERPRETER_H
00027 
00028 #include <string>
00029 #include <vector>
00030 
00031 /**
00032  * \class WScriptInterpreter
00033  *
00034  * An abstract base class for a script interpreter.
00035  */
00036 class WScriptInterpreter
00037 {
00038 public:
00039     /**
00040      * Destructor.
00041      */
00042     virtual ~WScriptInterpreter();
00043 
00044     /**
00045      * Initialize OpenWalnut-bindings. These allow OW-classes to be used via the script interpreter.
00046      */
00047     virtual void initBindings() = 0;
00048 
00049     /**
00050      * Sets the script parameters. These are the parameters you would normally call your script with, e.g.
00051      * "./myscript.py param 1 param2".
00052      *
00053      * \param params The parameters to the script. In our example, they would be "./myscript.py", "param", "1" and "param2".
00054      */
00055     virtual void setParameters( std::vector< std::string > const& params ) = 0;
00056 
00057     /**
00058      * Execute some code.
00059      *
00060      * \param line The code to interpret.
00061      */
00062     virtual void execute( std::string const& line ) = 0;
00063 
00064     /**
00065      * Execute a script in a seperate thread. This function returns immediately.
00066      *
00067      * \param script The script to execute.
00068      */
00069     virtual void executeAsync( std::string const& script ) = 0;
00070 
00071     /**
00072      * Execute a file.
00073      *
00074      * \param filename The script file to execute.
00075      */
00076     virtual void executeFile( std::string const& filename ) = 0;
00077 
00078     /**
00079      * Execute a script file in a seperate thread. This function returns immediately.
00080      *
00081      * \param filename The script file to execute.
00082      */
00083     virtual void executeFileAsync( std::string const& filename ) = 0;
00084 
00085     /**
00086      * Get the name of the language interpreted by this interpreter.
00087      *
00088      * \return The name of the script language.
00089      */
00090     virtual std::string const getName() const = 0;
00091 
00092     /**
00093      * Get the default extension for script file belonging to the script interpreter's language.
00094      *
00095      * \return The default file extension.
00096      */
00097     virtual std::string const getExtension() const = 0;
00098 };
00099 
00100 #endif  // WSCRIPTINTERPRETER_H