From d8008b2db16a37ae3776446597a797df34fad08b Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 12 Feb 2016 13:24:41 +0100 Subject: libardour lua-script-manager --- libs/ardour/ardour/luascripting.h | 133 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 libs/ardour/ardour/luascripting.h (limited to 'libs/ardour/ardour/luascripting.h') 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 + * + * 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 + +#include +#include + +#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 LuaScriptInfoPtr; +typedef std::vector LuaScriptList; + +typedef boost::shared_ptr LuaScriptParamPtr; +typedef std::vector 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_ -- cgit v1.2.3