comparison utilities/json-to-capnp.cpp @ 21:dff96610ac05

A couple more conversions
author Chris Cannam <c.cannam@qmul.ac.uk>
date Fri, 20 May 2016 14:37:28 +0100
parents 7ca64f74add2
children b0fc4eb51547
comparison
equal deleted inserted replaced
20:7ca64f74add2 21:dff96610ac05
45 else throw NotFound(); 45 else throw NotFound();
46 } 46 }
47 47
48 virtual Vamp::Plugin *handleToPlugin(int32_t h) { 48 virtual Vamp::Plugin *handleToPlugin(int32_t h) {
49 m_handle = h; 49 m_handle = h;
50 m_plugin = reinterpret_cast<Vamp::Plugin *>(1); 50 m_plugin = reinterpret_cast<Vamp::Plugin *>(h);
51 return m_plugin; 51 return m_plugin;
52 } 52 }
53 53
54 private: 54 private:
55 int32_t m_handle; 55 int32_t m_handle;
67 67
68 if (type == "basic") { 68 if (type == "basic") {
69 throw VampJson::Failure("can't convert Basic block on its own"); 69 throw VampJson::Failure("can't convert Basic block on its own");
70 70
71 } else if (type == "configurationrequest") { 71 } else if (type == "configurationrequest") {
72
73 auto req = message.initRoot<ConfigurationRequest>(); 72 auto req = message.initRoot<ConfigurationRequest>();
74 PreservingPluginHandleMapper mapper; 73 PreservingPluginHandleMapper mapper;
75 VampnProto::buildConfigurationRequest 74 VampnProto::buildConfigurationRequest
76 (req, VampJson::toConfigurationRequest(payload, mapper), mapper); 75 (req, VampJson::toConfigurationRequest(payload, mapper), mapper);
77 76
78 } else if (type == "configurationresponse") { 77 } else if (type == "configurationresponse") {
79 throw VampJson::Failure("not implemented yet"); ///!!! 78 auto resp = message.initRoot<ConfigurationResponse>();
79 VampnProto::buildConfigurationResponse
80 (resp, VampJson::toConfigurationResponse(payload));
80 81
81 } else if (type == "feature") { 82 } else if (type == "feature") {
82 auto f = message.initRoot<Feature>(); 83 auto f = message.initRoot<Feature>();
83 VampnProto::buildFeature 84 VampnProto::buildFeature
84 (f, VampJson::toFeature(payload)); 85 (f, VampJson::toFeature(payload));
92 auto req = message.initRoot<LoadRequest>(); 93 auto req = message.initRoot<LoadRequest>();
93 VampnProto::buildLoadRequest 94 VampnProto::buildLoadRequest
94 (req, VampJson::toLoadRequest(payload)); 95 (req, VampJson::toLoadRequest(payload));
95 96
96 } else if (type == "loadresponse") { 97 } else if (type == "loadresponse") {
97 //!!! response types & configure call for plugin handles, but 98 auto resp = message.initRoot<LoadResponse>();
98 //!!! we don't have any context in which a plugin handle can 99 PreservingPluginHandleMapper mapper;
99 //!!! be persistent here 100 VampnProto::buildLoadResponse
100 throw VampJson::Failure("not implemented yet"); ///!!! 101 (resp, VampJson::toLoadResponse(payload, mapper), mapper);
101 102
102 } else if (type == "outputdescriptor") { 103 } else if (type == "outputdescriptor") {
103 auto od = message.initRoot<OutputDescriptor>(); 104 auto od = message.initRoot<OutputDescriptor>();
104 VampnProto::buildOutputDescriptor 105 VampnProto::buildOutputDescriptor
105 (od, VampJson::toOutputDescriptor(payload)); 106 (od, VampJson::toOutputDescriptor(payload));