Ardour  9.2-79-gba93f2fe52
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 "pbd/mutex.h"
25 #include "pbd/signals.h"
27 
28 namespace ARDOUR {
29 
31  public:
32 
33  enum ScriptType {
35  DSP,
41  };
42 
43  /* binary flags, valid for ActionScripts */
45  None = 0x00,
46  RouteSetup = 0x01,
47  SessionSetup = 0x02,
48  };
49 
50  static std::string type2str (const ScriptType t);
51  static ScriptType str2type (const std::string& str);
52 
53  LuaScriptInfo (ScriptType t, const std::string &n, const std::string &p, const std::string &uid)
54  : type (t)
55  , subtype (0)
56  , name (n)
57  , path (p)
58  , unique_id (uid)
59  { }
60 
61  virtual ~LuaScriptInfo () { }
62 
64  uint32_t subtype;
65 
66  std::string name;
67  std::string path;
68  std::string unique_id;
69 
70  std::string author;
71  std::string license;
72  std::string category;
73  std::string description;
74 };
75 
77  public:
79  const std::string& n,
80  const std::string& t,
81  const std::string& d,
82  bool o, bool p)
83  : name (n)
84  , title (t)
85  , dflt (d)
86  , optional (o)
87  , preseeded (p)
88  , is_set (false)
89  , value (d)
90  {}
91 
92  std::string name;
93  std::string title;
94  std::string dflt;
95  bool optional;
96  bool preseeded;
97  bool is_set;
98  std::string value;
99 };
100 
101 
102 typedef std::shared_ptr<LuaScriptInfo> LuaScriptInfoPtr;
103 typedef std::vector<LuaScriptInfoPtr> LuaScriptList;
104 
105 typedef std::shared_ptr<LuaScriptParam> LuaScriptParamPtr;
106 typedef std::vector<LuaScriptParamPtr> LuaScriptParamList;
107 
108 
110 
111 public:
113 
115 
117  void refresh (bool run_scan = false);
119 
121 
122  static LuaScriptInfoPtr script_info (const std::string &script);
123  static bool try_compile (const std::string&, const LuaScriptParamList&);
124  static std::string get_factory_bytecode (const std::string&, const std::string& ffn = "factory", const std::string& fp = "f");
125  static std::string user_script_dir ();
126 
128  bool operator() (LuaScriptInfoPtr const a, LuaScriptInfoPtr const b) const;
129  };
130 
131 private:
132  static LuaScripting* _instance; // singleton
134 
135  void scan ();
136  static LuaScriptInfoPtr scan_script (const std::string &, const std::string & sc = "");
137  static void lua_print (std::string s);
138 
147 
149 };
150 
151 } // namespace ARDOUR
152 
153 #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:53
static ScriptType str2type(const std::string &str)
static std::string type2str(const ScriptType t)
virtual ~LuaScriptInfo()
Definition: luascripting.h:61
std::string category
Definition: luascripting.h:72
std::string unique_id
Definition: luascripting.h:68
std::string description
Definition: luascripting.h:73
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:118
LuaScriptList * _sl_action
Definition: luascripting.h:142
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:146
static std::string user_script_dir()
LuaScriptList * _sl_session
Definition: luascripting.h:140
LuaScriptList * _sl_snippet
Definition: luascripting.h:143
void refresh(bool run_scan=false)
LuaScriptList * _sl_setup
Definition: luascripting.h:144
static LuaScriptInfoPtr script_info(const std::string &script)
LuaScriptList * _sl_tracks
Definition: luascripting.h:145
static LuaScripting * _instance
Definition: luascripting.h:132
static LuaScripting & instance()
LuaScriptList * _sl_hook
Definition: luascripting.h:141
LuaScriptList * _sl_dsp
Definition: luascripting.h:139
GtkImageIconNameData name
Definition: gtkimage.h:6
#define LIBARDOUR_API
std::shared_ptr< LuaScriptInfo > LuaScriptInfoPtr
Definition: luascripting.h:102
std::vector< LuaScriptInfoPtr > LuaScriptList
Definition: luascripting.h:103
std::shared_ptr< LuaScriptParam > LuaScriptParamPtr
Definition: luascripting.h:105
std::vector< LuaScriptParamPtr > LuaScriptParamList
Definition: luascripting.h:106
LuaScriptParam(const std::string &n, const std::string &t, const std::string &d, bool o, bool p)
Definition: luascripting.h:78