File: PluginDictionary.h

package info (click to toggle)
pd-vstplugin 0.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,008 kB
  • sloc: cpp: 22,794; lisp: 2,860; makefile: 37; sh: 26
file content (53 lines) | stat: -rw-r--r-- 1,794 bytes parent folder | download
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
#pragma once

#include "Interface.h"
#include "PluginDesc.h"
#include "Sync.h"

#include <array>
#include <unordered_map>
#include <unordered_set>

namespace vst {

// thread-safe dictionary for VST plugins (factories and descriptions)

class PluginDictionary {
 public:
    PluginDictionary() = default;
    PluginDictionary(const PluginDictionary&) = delete;
    PluginDictionary(PluginDictionary&&) = delete;

    // factories
    void addFactory(const std::string& path, IFactory::ptr factory);
    IFactory::const_ptr findFactory(const std::string& path) const;
    // black-listed modules
    void addException(const std::string& path);
    bool isException(const std::string& path) const;
    // plugin descriptions
    void addPlugin(const std::string& key, PluginDesc::const_ptr plugin);
    PluginDesc::const_ptr findPlugin(const std::string& key) const;
    std::vector<PluginDesc::const_ptr> pluginList() const;
    // remove factories and plugin descriptions
    void clear();
    // (de)serialize
    // throws an Error exception on failure!
    void read(const std::string& path, bool update = true);
    void write(const std::string& path) const;
    // read a single plugin description
    PluginDesc::const_ptr readPlugin(std::istream& stream);
 private:
    PluginDesc::const_ptr doReadPlugin(std::istream& stream, double timestamp,
                                       int versionMajor, int versionMinor, int versionPatch);
    void doWrite(const std::string& path) const;
    std::unordered_map<std::string, IFactory::ptr> factories_;
    enum {
        NATIVE = 0,
        BRIDGED = 1
    };
    std::array<std::unordered_map<std::string, PluginDesc::const_ptr>, 2> plugins_;
    std::unordered_set<std::string> exceptions_;
    mutable SharedMutex mutex_;
};

} // vst