Skip to content

Commit 22f1645

Browse files
committed
Adding WIP demo (data source) plugin
Signed-off-by: Ted Waine <ted.waine@gmail.com>
1 parent 6c496b1 commit 22f1645

File tree

71 files changed

+4939
-295
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+4939
-295
lines changed

CMakePresets.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"CMAKE_INSTALL_PREFIX": "xstudio_install",
1212
"X_VCPKG_APPLOCAL_DEPS_INSTALL": "ON",
1313
"BUILD_DOCS": "OFF",
14-
"USE_VCPKG": "ON"
14+
"USE_VCPKG": "ON",
15+
"STUDIO_PLUGINS": ""
1516
}
1617
},
1718
{

docs/reference/build_guides/macos.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ Follow [these instructions](downloading_qt.md)
2626

2727
### Download the VCPKG repo
2828

29-
To build xSTUDIO we need a number of other open source software packages. We use the VCPKG package manager to do this. All that we need to do is download the repo and run the bootstrap script before we build xstudio.
29+
To build xSTUDIO we need a number of other open source software packages. We use the VCPKG package manager to do this. All that we need to do is download the repo, run the bootstrap script and then siwtch to a specific git commit before we build xstudio. Run these commands in a terminal:
3030

3131
git clone https://github.com/microsoft/vcpkg.git
32-
./vcpkg/bootstrap-vcpkg.sh
32+
./vcpkg/bootstrap-vcpkg.bat
33+
git checkout c2aeddd80357b17592e59ad965d2adf65a19b22f
3334

3435
### Download the xSTUDIO repo
3536

docs/reference/build_guides/windows.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ Start a Windows Powershell to continue these instructions, where you must run a
2929
mkdir dev
3030
cd dev
3131

32-
To build xSTUDIO we need a number of other open source software packages. We use the VCPKG package manager to do this. All that we need to do is download the repo and run the bootstrap script before we build xstudio. Run these commands in the Powershell:
32+
To build xSTUDIO we need a number of other open source software packages. We use the VCPKG package manager to do this. All that we need to do is download the repo, run the bootstrap script and then siwtch to a specific git commit before we build xstudio. Run these commands in the Powershell:
3333

3434
git clone https://github.com/microsoft/vcpkg.git
3535
./vcpkg/bootstrap-vcpkg.bat
36+
git checkout c2aeddd80357b17592e59ad965d2adf65a19b22f
3637

3738
### Download the xSTUDIO repo
3839

include/xstudio/atoms.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,7 @@ CAF_BEGIN_TYPE_ID_BLOCK(xstudio_plugin_atoms, FIRST_CUSTOM_ID + (200 * 3))
528528
CAF_ADD_ATOM(xstudio_plugin_atoms, xstudio::embedded_python, python_eval_file_atom)
529529
CAF_ADD_ATOM(xstudio_plugin_atoms, xstudio::embedded_python, python_eval_locals_atom)
530530
CAF_ADD_ATOM(xstudio_plugin_atoms, xstudio::embedded_python, python_exec_atom)
531+
CAF_ADD_ATOM(xstudio_plugin_atoms, xstudio::embedded_python, python_exec_plugin_method_atom)
531532
CAF_ADD_ATOM(xstudio_plugin_atoms, xstudio::embedded_python, python_output_atom)
532533
CAF_ADD_ATOM(xstudio_plugin_atoms, xstudio::embedded_python, python_remove_session_atom)
533534
CAF_ADD_ATOM(xstudio_plugin_atoms, xstudio::embedded_python, python_session_input_atom)
@@ -549,7 +550,6 @@ CAF_BEGIN_TYPE_ID_BLOCK(xstudio_plugin_atoms, FIRST_CUSTOM_ID + (200 * 3))
549550
CAF_ADD_ATOM(xstudio_plugin_atoms, xstudio::plugin_manager, get_resident_atom)
550551
CAF_ADD_ATOM(xstudio_plugin_atoms, xstudio::plugin_manager, spawn_plugin_atom)
551552
CAF_ADD_ATOM(xstudio_plugin_atoms, xstudio::plugin_manager, spawn_plugin_base_atom)
552-
CAF_ADD_ATOM(xstudio_plugin_atoms, xstudio::plugin_manager, spawn_plugin_ui_atom)
553553
CAF_ADD_ATOM(xstudio_plugin_atoms, xstudio::shotgun_client, shotgun_acquire_authentication_atom)
554554
CAF_ADD_ATOM(xstudio_plugin_atoms, xstudio::shotgun_client, shotgun_acquire_token_atom)
555555
CAF_ADD_ATOM(xstudio_plugin_atoms, xstudio::shotgun_client, shotgun_authenticate_atom)

include/xstudio/data_source/data_source.hpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,22 +52,18 @@ namespace data_source {
5252
public:
5353
DataSourcePlugin(
5454
utility::Uuid uuid,
55-
std::string name = "",
56-
std::string author = "",
57-
std::string description = "",
58-
semver::version version = semver::version("0.0.0"),
59-
std::string widget_ui_string = "",
60-
std::string menu_ui_string = "")
55+
std::string name = "",
56+
std::string author = "",
57+
std::string description = "",
58+
semver::version version = semver::version("0.0.0"))
6159
: plugin_manager::PluginFactoryTemplate<T>(
6260
uuid,
6361
name,
6462
plugin_manager::PluginFlags::PF_DATA_SOURCE,
6563
true,
6664
author,
6765
description,
68-
version,
69-
widget_ui_string,
70-
menu_ui_string) {}
66+
version) {}
7167
~DataSourcePlugin() override = default;
7268
};
7369

include/xstudio/embedded_python/embedded_python_actor.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace embedded_python {
2424
void join_broadcast(caf::actor act);
2525
void leave_broadcast(caf::actor act);
2626
void delayed_callback(utility::Uuid &cb_id, const int microseconds_delay);
27-
27+
utility::JsonStore process_non_specific_message(caf::message &msg);
2828
void main_loop();
2929

3030
private:

include/xstudio/global/global_actor.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ namespace global {
5757

5858
void connect_api(const caf::actor &embedded_python);
5959
void disconnect_api(const caf::actor &embedded_python, const bool force = false);
60+
void honour_requests_for_python_interpreter(const caf::actor &embedded_python);
6061

6162
template <class AudioOutputDev>
6263
caf::actor spawn_audio_output_actor(const utility::JsonStore &prefs) {
@@ -82,6 +83,7 @@ namespace global {
8283
int port_maximum_;
8384
std::string bind_address_;
8485
bool connected_;
86+
bool connection_attempted_ = {false};
8587

8688
std::string remote_api_session_name_;
8789
utility::RemoteSessionManager rsm_;
@@ -93,6 +95,7 @@ namespace global {
9395
StatusType status_{StatusType::ST_NONE};
9496
std::set<caf::actor_addr> busy_;
9597
utility::JsonStore file_map_regex_;
98+
std::vector<caf::typed_response_promise<caf::actor>> pending_python_interp_requests_;
9699
};
97100
} // namespace global
98101
} // namespace xstudio

include/xstudio/module/module.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,10 @@ namespace module {
378378

379379
// Override this function to receive callbacks from QML from items
380380
// created by 'create_qml_item'
381-
virtual void qml_item_callback(
382-
const utility::Uuid &qml_item_id, const utility::JsonStore &callback_data) {}
381+
virtual utility::JsonStore qml_item_callback(
382+
const utility::Uuid &qml_item_id, const utility::JsonStore &callback_data) {
383+
return utility::JsonStore();
384+
}
383385

384386
// This method can be overriden to receive a callback when the number of viewports
385387
// connected to the module changes. This is used by the Playhead class, for example

include/xstudio/plugin_manager/plugin_factory.hpp

Lines changed: 52 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,36 @@
1212
#include "xstudio/utility/json_store.hpp"
1313
#include "xstudio/plugin_manager/enums.hpp"
1414

15+
// Use the following macros to declare plugins.
16+
// See src/plugin/data_source/demo/demo_datasource_plugin/src/demo_plugin.cpp for example useage
17+
18+
#define XSTUDIO_PLUGIN_DECLARE_BEGIN() \
19+
extern "C" { \
20+
plugin_manager::PluginFactoryCollection *plugin_factory_collection_ptr() { \
21+
\
22+
auto pfc = new plugin_manager::PluginFactoryCollection();
23+
24+
#define XSTUDIO_PLUGIN_DECLARE_END() \
25+
return pfc; \
26+
} \
27+
}
28+
29+
#define XSTUDIO_REGISTER_PLUGIN( \
30+
PLUGIN_CLASS, UUID, NAME, TYPE, RESIDENT, AUTHOR, DESCRIPTION, VERSION) \
31+
pfc->register_plugin<PLUGIN_CLASS>( \
32+
UUID, #NAME, TYPE, RESIDENT, #AUTHOR, #DESCRIPTION, semver::version(#VERSION));
33+
34+
#define XSTUDIO_REGISTER_MEDIA_READER_PLUGIN(PLUGIN_CLASS, UUID, NAME, AUTHOR, DESCRIPTION, VERSION) \
35+
pfc->register_plugin<media_reader::MediaReaderActor<PLUGIN_CLASS>>( \
36+
UUID, \
37+
#NAME, \
38+
plugin_manager::PluginFlags::PF_MEDIA_READER, \
39+
false, \
40+
#AUTHOR, \
41+
#DESCRIPTION, \
42+
semver::version(#VERSION));
43+
44+
1545
namespace xstudio {
1646
namespace plugin_manager {
1747

@@ -35,32 +65,25 @@ namespace plugin_manager {
3565
}
3666

3767
virtual void *instance_q_object(void *parent_q_object) { return nullptr; }
38-
39-
[[nodiscard]] virtual std::string spawn_widget_ui() { return ""; }
40-
[[nodiscard]] virtual std::string spawn_menu_ui() { return ""; }
4168
};
4269

4370
template <typename T> class PluginFactoryTemplate : public PluginFactory {
4471
public:
4572
PluginFactoryTemplate(
4673
utility::Uuid uuid,
47-
std::string name = "",
48-
PluginType type = PluginFlags::PF_CUSTOM,
49-
bool resident = false,
50-
std::string author = "",
51-
std::string description = "",
52-
semver::version version = semver::version("0.0.0"),
53-
std::string ui_widget_string = "",
54-
std::string ui_menu_string = "")
74+
std::string _name = "",
75+
PluginType type = PluginFlags::PF_CUSTOM,
76+
bool resident = false,
77+
std::string author = "",
78+
std::string description = "",
79+
semver::version version = semver::version("0.0.0"))
5580
: uuid_(std::move(uuid)),
56-
name_(std::move(name)),
81+
name_(std::move(_name)),
5782
type_(type),
5883
resident_(resident),
5984
author_(std::move(author)),
6085
description_(std::move(description)),
61-
version_(std::move(version)),
62-
ui_widget_string_(std::move(ui_widget_string)),
63-
ui_menu_string_(std::move(ui_menu_string)) {}
86+
version_(std::move(version)) {}
6487
~PluginFactoryTemplate() override = default;
6588

6689
[[nodiscard]] std::string name() const override { return name_; }
@@ -70,8 +93,6 @@ namespace plugin_manager {
7093
[[nodiscard]] std::string author() const override { return author_; }
7194
[[nodiscard]] std::string description() const override { return description_; }
7295
[[nodiscard]] semver::version version() const override { return version_; }
73-
[[nodiscard]] std::string spawn_widget_ui() override { return ui_widget_string_; }
74-
[[nodiscard]] std::string spawn_menu_ui() override { return ui_menu_string_; }
7596
[[nodiscard]] caf::actor spawn(
7697
caf::blocking_actor &sys,
7798
const utility::JsonStore &json = utility::JsonStore()) override {
@@ -119,8 +140,6 @@ namespace plugin_manager {
119140
[[nodiscard]] std::string author() const override { return author_; }
120141
[[nodiscard]] std::string description() const override { return description_; }
121142
[[nodiscard]] semver::version version() const override { return version_; }
122-
[[nodiscard]] std::string spawn_widget_ui() override { return ui_widget_string_; }
123-
[[nodiscard]] std::string spawn_menu_ui() override { return ui_menu_string_; }
124143

125144
void *instance_q_object(void *parent_q_object) override {
126145
return T::instance_q_object(parent_q_object);
@@ -133,8 +152,6 @@ namespace plugin_manager {
133152
std::string author_;
134153
std::string description_;
135154
semver::version version_;
136-
std::string ui_widget_string_;
137-
std::string ui_menu_string_;
138155
};
139156

140157

@@ -148,6 +165,20 @@ namespace plugin_manager {
148165
: factories_(std::move(vpf)) {}
149166
virtual ~PluginFactoryCollection() = default;
150167

168+
template <typename T>
169+
void register_plugin(
170+
utility::Uuid uuid,
171+
std::string name = "",
172+
PluginType type = PluginFlags::PF_CUSTOM,
173+
bool resident = false,
174+
std::string author = "",
175+
std::string description = "",
176+
semver::version version = semver::version("0.0.0")) {
177+
factories_.push_back(
178+
std::make_shared<PluginFactoryTemplate<T>>(
179+
uuid, name, type, resident, author, description, version));
180+
}
181+
151182
std::vector<std::shared_ptr<PluginFactory>> &factories() { return factories_; }
152183

153184
protected:

include/xstudio/plugin_manager/plugin_manager.hpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@ namespace plugin_manager {
1212
class PluginEntry {
1313
public:
1414
PluginEntry(std::shared_ptr<PluginFactory> pf, std::string path)
15-
: plugin_factory_(std::move(pf)), path_(std::move(path)) {
16-
// auto enable xstudio plugins
17-
// we might want to use uuids list.
18-
if (plugin_factory_.get()->author() != "xStudio")
19-
enabled_ = false;
20-
}
15+
: plugin_factory_(std::move(pf)), path_(std::move(path)) {}
2116

2217
virtual ~PluginEntry() = default;
2318

@@ -29,6 +24,7 @@ namespace plugin_manager {
2924
private:
3025
std::shared_ptr<PluginFactory> plugin_factory_;
3126
std::string path_;
27+
// Plugins are always enabled by default
3228
bool enabled_{true};
3329
};
3430

@@ -101,8 +97,6 @@ namespace plugin_manager {
10197
caf::blocking_actor &sys,
10298
const utility::Uuid &uuid,
10399
const utility::JsonStore &json = utility::JsonStore());
104-
[[nodiscard]] std::string spawn_widget_ui(const utility::Uuid &uuid);
105-
[[nodiscard]] std::string spawn_menu_ui(const utility::Uuid &uuid);
106100

107101
private:
108102
std::list<std::string> plugin_paths_;

0 commit comments

Comments
 (0)