2 * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #ifndef _ardour_luascripting_h_
20 #define _ardour_luascripting_h_
23 #include <boost/shared_ptr.hpp>
24 #include <glibmm/threads.h>
26 #include "ardour/libardour_visibility.h"
30 class LIBARDOUR_API LuaScriptInfo {
41 static std::string type2str (const ScriptType t);
42 static ScriptType str2type (const std::string& str);
44 LuaScriptInfo (ScriptType t, const std::string &n, const std::string &p)
50 virtual ~LuaScriptInfo () { }
59 std::string description;
62 struct LIBARDOUR_API LuaScriptParam {
86 typedef boost::shared_ptr<LuaScriptInfo> LuaScriptInfoPtr;
87 typedef std::vector<LuaScriptInfoPtr> LuaScriptList;
89 typedef boost::shared_ptr<LuaScriptParam> LuaScriptParamPtr;
90 typedef std::vector<LuaScriptParamPtr> LuaScriptParamList;
93 class LIBARDOUR_API LuaScripting {
96 static LuaScripting& instance();
100 LuaScriptList &scripts (LuaScriptInfo::ScriptType);
103 static LuaScriptInfoPtr script_info (const std::string &script ) { return scan_script ("", script); }
105 static LuaScriptParamList script_params (LuaScriptInfoPtr, const std::string &);
106 static LuaScriptParamList session_script_params (LuaScriptInfoPtr lsi) {
107 return script_params (lsi, "sess_params");
110 static bool try_compile (const std::string&, const LuaScriptParamList&);
111 static std::string get_factory_bytecode (const std::string&);
114 static LuaScripting* _instance; // singleton
119 static LuaScriptInfoPtr scan_script (const std::string &, const std::string & sc = "");
120 static void lua_print (std::string s);
122 LuaScriptList *_sl_dsp;
123 LuaScriptList *_sl_session;
124 LuaScriptList *_sl_hook;
125 LuaScriptList *_sl_action;
126 LuaScriptList _empty_script_info;
128 Glib::Threads::Mutex _lock;
131 } // namespace ARDOUR
133 #endif // _ardour_luascripting_h_