comparison bits/PluginOutputIdMapper.h @ 51:f4244a2d55ac

Introduce and use output id mappers
author Chris Cannam <c.cannam@qmul.ac.uk>
date Fri, 16 Sep 2016 15:10:57 +0100
parents 12e3b396544c
children 8a4bcb3dc3a6
comparison
equal deleted inserted replaced
50:12e3b396544c 51:f4244a2d55ac
40 #include <map> 40 #include <map>
41 #include <string> 41 #include <string>
42 42
43 namespace vampipe { 43 namespace vampipe {
44 44
45 //!!! doc interface
45 class PluginOutputIdMapper 46 class PluginOutputIdMapper
46 { 47 {
47 public: 48 public:
48 PluginOutputIdMapper(Vamp::Plugin *p) { 49 virtual ~PluginOutputIdMapper() { }
49 Vamp::Plugin::OutputList outputs = p->getOutputDescriptors(); 50
50 for (const auto &d: outputs) { 51 virtual int idToIndex(std::string outputId) const = 0;
51 m_ids.push_back(d.identifier); 52 virtual std::string indexToId(int index) const = 0;
52 }
53 }
54
55 int idToIndex(std::string outputId) const {
56 int n = int(m_ids.size());
57 for (int i = 0; i < n; ++i) {
58 if (outputId == m_ids[i]) {
59 return i;
60 }
61 }
62 }
63
64 std::string indexToId(int index) const {
65 return m_ids[index];
66 }
67
68 private:
69 std::vector<std::string> m_ids;
70 }; 53 };
71 54
72 } 55 }
73 56
74 #endif 57 #endif