forked from Tracktion/pluginval
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathValidator.h
More file actions
119 lines (94 loc) · 4.41 KB
/
Copy pathValidator.h
File metadata and controls
119 lines (94 loc) · 4.41 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*==============================================================================
Copyright 2018 by Tracktion Corporation.
For more information visit www.tracktion.com
You may also use this code under the terms of the GPL v3 (see
www.gnu.org/licenses).
pluginval IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================*/
#pragma once
#include "juce_audio_processors/juce_audio_processors.h"
#include "PluginTests.h"
class ChildProcessValidator;
class AsyncValidator;
class MultiValidator;
//==============================================================================
//==============================================================================
/** Enum to determine the type of validation to run. */
enum class ValidationType
{
inProcess, /**< Runs the validation in the calling process. */
childProcess /**< Runs the validation in the a separate process. */
};
//==============================================================================
/**
A single, asynchronous validation pass for a specific plugin.
*/
class ValidationPass
{
public:
//==============================================================================
/** Starts a validation process with a set of options and callbacks.
The validation will be async so either use the validationEnded callback or
poll hasFinished() to find out when the validation has completed.
N.B. outputGenerated will be called from a background thread.
*/
ValidationPass (const juce::String& fileOrIdToValidate, PluginTests::Options, ValidationType,
std::function<void (juce::String)> validationStarted,
std::function<void (juce::String, uint32_t /*exitCode*/)> validationEnded,
std::function<void(const juce::String&)> outputGenerated);
/** Destructor. */
~ValidationPass();
/** Returns true when the validation pass has ended. */
[[nodiscard]] bool hasFinished() const;
private:
//==============================================================================
std::unique_ptr<ChildProcessValidator> childProcessValidator;
std::unique_ptr<AsyncValidator> asyncValidator;
};
//==============================================================================
//==============================================================================
/**
Manages validation calls via a separate process and provides a listener
interface to find out the results of the validation.
*/
class Validator : public juce::ChangeBroadcaster,
private juce::AsyncUpdater
{
public:
//==============================================================================
/** Constructor. */
Validator();
/** Destructor. */
~Validator() override;
/** Returns true if there is currently an open connection to a validator process. */
bool isConnected() const;
/** Validates an array of fileOrIDs. */
bool validate (const juce::StringArray& fileOrIDsToValidate, PluginTests::Options);
/** Validates an array of PluginDescriptions. */
bool validate (const juce::Array<juce::PluginDescription>& pluginsToValidate, PluginTests::Options);
/** Call this to make validation happen in the same process.
This can be useful for debugging but should not generally be used as a crashing
plugin will bring down the app.
*/
void setValidateInProcess (bool useSameProcess);
//==============================================================================
struct Listener
{
virtual ~Listener() = default;
virtual void validationStarted (const juce::String& idString) = 0;
virtual void logMessage (const juce::String&) = 0;
virtual void itemComplete (const juce::String& idString, uint32_t exitCode) = 0;
virtual void allItemsComplete() = 0;
};
void addListener (Listener* l) { listeners.add (l); }
void removeListener (Listener* l) { listeners.remove (l); }
private:
//==============================================================================
std::unique_ptr<MultiValidator> multiValidator;
juce::ListenerList<Listener> listeners;
bool launchInProcess = false;
void logMessage (const juce::String&);
void handleAsyncUpdate() override;
};