Mercurial > hg > piper-cpp
diff capnproto/VampnProto.h @ 27:cc85c2851605
Wire up Cap'n Proto reading, plus some build and arg processing fixes
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Tue, 24 May 2016 12:00:38 +0100 |
parents | 13393bdfc7ef |
children | b5005ebc5116 |
line wrap: on
line diff
--- a/capnproto/VampnProto.h Tue May 24 11:07:59 2016 +0100 +++ b/capnproto/VampnProto.h Tue May 24 12:00:38 2016 +0100 @@ -748,6 +748,7 @@ case VampRequest::Request::Which::FINISH: return RRType::Finish; } + return RRType::NotValid; } static RRType @@ -764,12 +765,13 @@ case VampResponse::Response::Which::FINISH: return RRType::Finish; } + return RRType::NotValid; } static void readVampRequest_List(const VampRequest::Reader &r) { if (getRequestResponseType(r) != RRType::List) { - throw std::runtime_error("not a list request"); + throw std::logic_error("not a list request"); } } @@ -777,7 +779,7 @@ readVampResponse_List(std::vector<Vamp::HostExt::PluginStaticData> &v, const VampResponse::Reader &r) { if (getRequestResponseType(r) != RRType::List) { - throw std::runtime_error("not a list response"); + throw std::logic_error("not a list response"); } v.clear(); if (r.getSuccess()) { @@ -789,6 +791,94 @@ } } + static void + readVampRequest_Load(Vamp::HostExt::LoadRequest &req, + const VampRequest::Reader &r) { + if (getRequestResponseType(r) != RRType::Load) { + throw std::logic_error("not a load request"); + } + readLoadRequest(req, r.getRequest().getLoad()); + } + + static void + readVampResponse_Load(Vamp::HostExt::LoadResponse &resp, + const VampResponse::Reader &r, + PluginHandleMapper &mapper) { + if (getRequestResponseType(r) != RRType::Load) { + throw std::logic_error("not a load response"); + } + resp = {}; + if (r.getSuccess()) { + readLoadResponse(resp, r.getResponse().getLoad(), mapper); + } + } + + static void + readVampRequest_Configure(Vamp::HostExt::ConfigurationRequest &req, + const VampRequest::Reader &r, + PluginHandleMapper &mapper) { + if (getRequestResponseType(r) != RRType::Configure) { + throw std::logic_error("not a configuration request"); + } + readConfigurationRequest(req, r.getRequest().getConfigure(), mapper); + } + + static void + readVampResponse_Configure(Vamp::HostExt::ConfigurationResponse &resp, + const VampResponse::Reader &r) { + if (getRequestResponseType(r) != RRType::Configure) { + throw std::logic_error("not a configuration response"); + } + resp = {}; + if (r.getSuccess()) { + readConfigurationResponse(resp, r.getResponse().getConfigure()); + } + } + + static void + readVampRequest_Process(Vamp::HostExt::ProcessRequest &req, + const VampRequest::Reader &r, + PluginHandleMapper &mapper) { + if (getRequestResponseType(r) != RRType::Process) { + throw std::logic_error("not a process request"); + } + readProcessRequest(req, r.getRequest().getProcess(), mapper); + } + + static void + readVampResponse_Process(Vamp::HostExt::ProcessResponse &resp, + const VampResponse::Reader &r) { + if (getRequestResponseType(r) != RRType::Process) { + throw std::logic_error("not a process response"); + } + resp = {}; + if (r.getSuccess()) { + readProcessResponse(resp, r.getResponse().getProcess()); + } + } + + static void + readVampRequest_Finish(Vamp::Plugin *&finishPlugin, + const VampRequest::Reader &r, + PluginHandleMapper &mapper) { + if (getRequestResponseType(r) != RRType::Finish) { + throw std::logic_error("not a finish request"); + } + finishPlugin = mapper.handleToPlugin + (r.getRequest().getFinish().getPluginHandle()); + } + + static void + readVampResponse_Finish(Vamp::HostExt::ProcessResponse &resp, + const VampResponse::Reader &r) { + if (getRequestResponseType(r) != RRType::Finish) { + throw std::logic_error("not a finish response"); + } + resp = {}; + if (r.getSuccess()) { + readProcessResponse(resp, r.getResponse().getFinish()); + } + } }; }