Ardour  9.0-pre0-350-gf17a656217
luascripting.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016-2019 Robin Gareus <robin@gareus.org>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
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.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 #ifndef _ardour_luascripting_h_
19 #define _ardour_luascripting_h_
20 
21 #include <memory>
22 #include <vector>
23 
24 #include <glibmm/threads.h>
25 
26 #include "pbd/signals.h"
28 
29 namespace ARDOUR {
30 
32  public:
33 
34  enum ScriptType {
36  DSP,
42  };
43 
44  /* binary flags, valid for ActionScripts */
46  None = 0x00,
47  RouteSetup = 0x01,
48  SessionSetup = 0x02,
49  };
50 
51  static std::string type2str (const ScriptType t);
52  static ScriptType str2type (const std::string& str);
53 
54  LuaScriptInfo (ScriptType t, const std::string &n, const std::string &p, const std::string &uid)
55  : type (t)
56  , subtype (0)
57  , name (n)
58  , path (p)
59  , unique_id (uid)
60  { }
61 
62  virtual ~LuaScriptInfo () { }
63 
65  uint32_t subtype;
66 
67  std::string name;
68  std::string path;
69  std::string unique_id;
70 
71  std::string author;
72  std::string license;
73  std::string category;
74  std::string description;
75 };
76 
78  public:
80  const std::string& n,
81  const std::string& t,
82  const std::string& d,
83  bool o, bool p)
84  : name (n)
85  , title (t)
86  , dflt (d)
87  , optional (o)
88  , preseeded (p)
89  , is_set (false)
90  , value (d)
91  {}
92 
93  std::string name;
94  std::string title;
95  std::string dflt;
96  bool optional;
97  bool preseeded;
98  bool is_set;
99  std::string value;
100 };
101 
102 
103 typedef std::shared_ptr<LuaScriptInfo> LuaScriptInfoPtr;
104 typedef std::vector<LuaScriptInfoPtr> LuaScriptList;
105 
106 typedef std::shared_ptr<LuaScriptParam> LuaScriptParamPtr;
107 typedef std::vector<LuaScriptParamPtr> LuaScriptParamList;
108 
109 
111 
112 public:
114 
116 
118  void refresh (bool run_scan = false);
120 
122 
123  static LuaScriptInfoPtr script_info (const std::string &script);
124  static bool try_compile (const std::string&, const LuaScriptParamList&);
125  static std::string get_factory_bytecode (const std::string&, const std::string& ffn = "factory", const std::string& fp = "f");
126  static std::string user_script_dir ();
127 
129  bool operator() (LuaScriptInfoPtr const a, LuaScriptInfoPtr const b) const;
130  };
131 
132 private:
133  static LuaScripting* _instance; // singleton
135 
136  void scan ();
137  static LuaScriptInfoPtr scan_script (const std::string &, const std::string & sc = "");
138  static void lua_print (std::string s);
139 
148 
149  Glib::Threads::Mutex _lock;
150 };
151 
152 } // namespace ARDOUR
153 
154 #endif // _ardour_luascripting_h_
void None
Definition: TypeList.h:49
LuaScriptInfo(ScriptType t, const std::string &n, const std::string &p, const std::string &uid)
Definition: luascripting.h:54
static ScriptType str2type(const std::string &str)
static std::string type2str(const ScriptType t)
virtual ~LuaScriptInfo()
Definition: luascripting.h:62
std::string category
Definition: luascripting.h:73
std::string unique_id
Definition: luascripting.h:69
std::string description
Definition: luascripting.h:74
static LuaScriptInfoPtr scan_script(const std::string &, const std::string &sc="")
static std::string get_factory_bytecode(const std::string &, const std::string &ffn="factory", const std::string &fp="f")
LuaScriptInfoPtr by_name(const std::string &, LuaScriptInfo::ScriptType)
PBD::Signal< void()> scripts_changed
Definition: luascripting.h:119
LuaScriptList * _sl_action
Definition: luascripting.h:143
static void lua_print(std::string s)
LuaScriptList & scripts(LuaScriptInfo::ScriptType)
static bool try_compile(const std::string &, const LuaScriptParamList &)
LuaScriptList _empty_script_info
Definition: luascripting.h:147
static std::string user_script_dir()
LuaScriptList * _sl_session
Definition: luascripting.h:141
LuaScriptList * _sl_snippet
Definition: luascripting.h:144
Glib::Threads::Mutex _lock
Definition: luascripting.h:149
void refresh(bool run_scan=false)
LuaScriptList * _sl_setup
Definition: luascripting.h:145
static LuaScriptInfoPtr script_info(const std::string &script)
LuaScriptList * _sl_tracks
Definition: luascripting.h:146
static LuaScripting * _instance
Definition: luascripting.h:133
static LuaScripting & instance()
LuaScriptList * _sl_hook
Definition: luascripting.h:142
LuaScriptList * _sl_dsp
Definition: luascripting.h:140
GtkImageIconNameData name
Definition: gtkimage.h:6
#define LIBARDOUR_API
std::shared_ptr< LuaScriptInfo > LuaScriptInfoPtr
Definition: luascripting.h:103
std::vector< LuaScriptInfoPtr > LuaScriptList
Definition: luascripting.h:104
std::shared_ptr< LuaScriptParam > LuaScriptParamPtr
Definition: luascripting.h:106
std::vector< LuaScriptParamPtr > LuaScriptParamList
Definition: luascripting.h:107
LuaScriptParam(const std::string &n, const std::string &t, const std::string &d, bool o, bool p)
Definition: luascripting.h:79