diff options
author | Robin Gareus <robin@gareus.org> | 2016-02-12 13:24:41 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2016-02-23 15:41:06 +0100 |
commit | d8008b2db16a37ae3776446597a797df34fad08b (patch) | |
tree | 7ed033bab896e89aa311376f23a099888fc5d169 /libs/ardour/ardour/luascripting.h | |
parent | f0b6c8e111da767dff2394216b309f737a5f6099 (diff) |
libardour lua-script-manager
Diffstat (limited to 'libs/ardour/ardour/luascripting.h')
-rw-r--r-- | libs/ardour/ardour/luascripting.h | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/libs/ardour/ardour/luascripting.h b/libs/ardour/ardour/luascripting.h new file mode 100644 index 0000000000..a5a066b2cd --- /dev/null +++ b/libs/ardour/ardour/luascripting.h @@ -0,0 +1,133 @@ +/* + * Copyright (C) 2016 Robin Gareus <robin@gareus.org> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ +#ifndef _ardour_luascripting_h_ +#define _ardour_luascripting_h_ +#include <vector> + +#include <boost/shared_ptr.hpp> +#include <glibmm/threads.h> + +#include "ardour/libardour_visibility.h" + +namespace ARDOUR { + +class LIBARDOUR_API LuaScriptInfo { + public: + + enum ScriptType { + Invalid, + DSP, + Session, + EditorHook, + EditorAction, + }; + + static std::string type2str (const ScriptType t); + static ScriptType str2type (const std::string& str); + + LuaScriptInfo (ScriptType t, const std::string &n, const std::string &p) + : type (t) + , name (n) + , path (p) + { } + + virtual ~LuaScriptInfo () { } + + ScriptType type; + std::string name; + std::string path; + + std::string author; + std::string license; + std::string category; + std::string description; +}; + +struct LIBARDOUR_API LuaScriptParam { + public: + LuaScriptParam ( + const std::string& n, + const std::string& t, + const std::string& d, + bool o) + : name (n) + , title (t) + , dflt (d) + , optional (o) + , is_set (false) + , value (d) + {} + + std::string name; + std::string title; + std::string dflt; + bool optional; + bool is_set; + std::string value; +}; + + +typedef boost::shared_ptr<LuaScriptInfo> LuaScriptInfoPtr; +typedef std::vector<LuaScriptInfoPtr> LuaScriptList; + +typedef boost::shared_ptr<LuaScriptParam> LuaScriptParamPtr; +typedef std::vector<LuaScriptParamPtr> LuaScriptParamList; + + +class LIBARDOUR_API LuaScripting { + +public: + static LuaScripting& instance(); + + ~LuaScripting (); + + LuaScriptList &scripts (LuaScriptInfo::ScriptType); + + void refresh (); + static LuaScriptInfoPtr script_info (const std::string &script ) { return scan_script ("", script); } + + static LuaScriptParamList script_params (LuaScriptInfoPtr, const std::string &); + static LuaScriptParamList session_script_params (LuaScriptInfoPtr lsi) { + return script_params (lsi, "sess_params"); + } + + static bool try_compile (const std::string&, const LuaScriptParamList&); + static std::string get_factory_bytecode (const std::string&); + +private: + static LuaScripting* _instance; // singleton + LuaScripting (); + + void scan (); + void check_scan (); + static LuaScriptInfoPtr scan_script (const std::string &, const std::string & sc = ""); + static void lua_print (std::string s); + + LuaScriptList *_sl_dsp; + LuaScriptList *_sl_session; + LuaScriptList *_sl_hook; + LuaScriptList *_sl_action; + LuaScriptList _empty_script_info; + + Glib::Threads::Mutex _lock; +}; + +} // namespace ARDOUR + +#endif // _ardour_luascripting_h_ |