This repository has been archived by the owner on Sep 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPluginVisitor.h
75 lines (65 loc) · 1.83 KB
/
PluginVisitor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*****************************************************************//**
* \file PluginVisitor.h
* \brief Directly Musical Data Access library for VST3 with JUCE.
*
* \author WuChang
* \email [email protected]
* \date Jan 2024
* \version 1.2.3
* \license MIT License
*********************************************************************/
#pragma once
#include <JuceHeader.h>
namespace DMDA {
class Context;
/**
* The base for DMDA host to visit the plugin's DMDA context.
*
* Inherit this class then implement the handleContext() method
* to visit the context.
*
* You can pass it to AudioPluginInstance::getExtensions()
* then the handleContext() method could be invoked.
*/
class DMDA_API PluginVisitor : public juce::ExtensionsVisitor {
public:
virtual ~PluginVisitor() override = default;
/**
* For internal use.
*/
void visitVST3Client(
const juce::ExtensionsVisitor::VST3Client& client) override;
protected:
/**
* Handle the plugin's DMDA context.
*/
virtual void handleContext(Context*) = 0;
private:
JUCE_LEAK_DETECTOR(PluginVisitor)
};
/**
* Visit the plugin's DMDA context conveniently with lambda expression.
*
* Create an instance of this with your lambda function
* then pass the object to AudioPluginInstance::getExtensions() to invoke it.
*
* @code
* DMDA::PluginHandler handler([] (DMDA::Context* context) {
* // Do sth. with the context.
* });
* thePluginInstance->getExtensions(handler);
* @endcode
*/
class DMDA_API PluginHandler final : public PluginVisitor {
public:
PluginHandler() = delete;
PluginHandler(std::function<void(Context*)> function);
private:
const std::function<void(Context*)> function;
/**
* For internal use.
*/
void handleContext(Context* context) override;
JUCE_LEAK_DETECTOR(PluginHandler)
};
}