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 "pbd/signals.h"
27 #include "ardour/libardour_visibility.h"
31 class LIBARDOUR_API LuaScriptInfo {
44 /* binary flags, valid for ActionScripts */
51 static std::string type2str (const ScriptType t);
52 static ScriptType str2type (const std::string& str);
54 LuaScriptInfo (ScriptType t, const std::string &n, const std::string &p, const std::string &uid)
62 virtual ~LuaScriptInfo () { }
69 std::string unique_id;
74 std::string description;
77 struct LIBARDOUR_API LuaScriptParam {
103 typedef boost::shared_ptr<LuaScriptInfo> LuaScriptInfoPtr;
104 typedef std::vector<LuaScriptInfoPtr> LuaScriptList;
106 typedef boost::shared_ptr<LuaScriptParam> LuaScriptParamPtr;
107 typedef std::vector<LuaScriptParamPtr> LuaScriptParamList;
110 class LIBARDOUR_API LuaScripting {
113 static LuaScripting& instance();
117 LuaScriptList &scripts (LuaScriptInfo::ScriptType);
118 void refresh (bool run_scan = false);
119 PBD::Signal0<void> scripts_changed;
121 static LuaScriptInfoPtr script_info (const std::string &script);
122 static bool try_compile (const std::string&, const LuaScriptParamList&);
123 static std::string get_factory_bytecode (const std::string&, const std::string& ffn = "factory", const std::string& fp = "f");
124 static std::string user_script_dir ();
127 static LuaScripting* _instance; // singleton
131 static LuaScriptInfoPtr scan_script (const std::string &, const std::string & sc = "");
132 static void lua_print (std::string s);
134 LuaScriptList *_sl_dsp;
135 LuaScriptList *_sl_session;
136 LuaScriptList *_sl_hook;
137 LuaScriptList *_sl_action;
138 LuaScriptList *_sl_snippet;
139 LuaScriptList *_sl_setup;
140 LuaScriptList *_sl_tracks;
141 LuaScriptList _empty_script_info;
143 Glib::Threads::Mutex _lock;
146 } // namespace ARDOUR
148 #endif // _ardour_luascripting_h_