Mercurial > hg > piper-cpp
comparison capnproto/VampnProto.h @ 56:815e94fedc1c
Introduce ListResponse type as well
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Mon, 19 Sep 2016 14:10:19 +0100 |
parents | 38780f15ac8d |
children | 7aec704705c7 |
comparison
equal
deleted
inserted
replaced
55:38780f15ac8d | 56:815e94fedc1c |
---|---|
680 b.getRequest().setList(); | 680 b.getRequest().setList(); |
681 } | 681 } |
682 | 682 |
683 static void | 683 static void |
684 buildVampResponse_List(VampResponse::Builder &b, | 684 buildVampResponse_List(VampResponse::Builder &b, |
685 std::string errorText, | 685 const Vamp::HostExt::ListResponse &resp) { |
686 const std::vector<Vamp::HostExt::PluginStaticData> &d) { | 686 b.setSuccess(true); |
687 b.setSuccess(errorText == ""); | |
688 b.setErrorText(errorText); | |
689 auto r = b.getResponse().initList(); | 687 auto r = b.getResponse().initList(); |
690 auto p = r.initPlugins(d.size()); | 688 auto p = r.initPlugins(resp.pluginData.size()); |
691 for (size_t i = 0; i < d.size(); ++i) { | 689 for (size_t i = 0; i < resp.pluginData.size(); ++i) { |
692 auto pd = p[i]; | 690 auto pd = p[i]; |
693 buildPluginStaticData(pd, d[i]); | 691 buildPluginStaticData(pd, resp.pluginData[i]); |
694 } | 692 } |
695 } | 693 } |
696 | 694 |
697 static void | 695 static void |
698 buildVampRequest_Load(VampRequest::Builder &b, | 696 buildVampRequest_Load(VampRequest::Builder &b, |
704 static void | 702 static void |
705 buildVampResponse_Load(VampResponse::Builder &b, | 703 buildVampResponse_Load(VampResponse::Builder &b, |
706 const Vamp::HostExt::LoadResponse &resp, | 704 const Vamp::HostExt::LoadResponse &resp, |
707 const PluginHandleMapper &pmapper) { | 705 const PluginHandleMapper &pmapper) { |
708 b.setSuccess(resp.plugin != 0); | 706 b.setSuccess(resp.plugin != 0); |
709 b.setErrorText(""); | |
710 auto u = b.getResponse().initLoad(); | 707 auto u = b.getResponse().initLoad(); |
711 buildLoadResponse(u, resp, pmapper); | 708 buildLoadResponse(u, resp, pmapper); |
712 } | 709 } |
713 | 710 |
714 static void | 711 static void |
722 static void | 719 static void |
723 buildVampResponse_Configure(VampResponse::Builder &b, | 720 buildVampResponse_Configure(VampResponse::Builder &b, |
724 const Vamp::HostExt::ConfigurationResponse &cr, | 721 const Vamp::HostExt::ConfigurationResponse &cr, |
725 const PluginHandleMapper &pmapper) { | 722 const PluginHandleMapper &pmapper) { |
726 b.setSuccess(!cr.outputs.empty()); | 723 b.setSuccess(!cr.outputs.empty()); |
727 b.setErrorText(""); | |
728 auto u = b.getResponse().initConfigure(); | 724 auto u = b.getResponse().initConfigure(); |
729 buildConfigurationResponse(u, cr, pmapper); | 725 buildConfigurationResponse(u, cr, pmapper); |
730 } | 726 } |
731 | 727 |
732 static void | 728 static void |
740 static void | 736 static void |
741 buildVampResponse_Process(VampResponse::Builder &b, | 737 buildVampResponse_Process(VampResponse::Builder &b, |
742 const Vamp::HostExt::ProcessResponse &pr, | 738 const Vamp::HostExt::ProcessResponse &pr, |
743 const PluginHandleMapper &pmapper) { | 739 const PluginHandleMapper &pmapper) { |
744 b.setSuccess(true); | 740 b.setSuccess(true); |
745 b.setErrorText(""); | |
746 auto u = b.getResponse().initProcess(); | 741 auto u = b.getResponse().initProcess(); |
747 buildProcessResponse(u, pr, pmapper); | 742 buildProcessResponse(u, pr, pmapper); |
748 } | 743 } |
749 | 744 |
750 static void | 745 static void |
842 throw std::logic_error("not a list request"); | 837 throw std::logic_error("not a list request"); |
843 } | 838 } |
844 } | 839 } |
845 | 840 |
846 static void | 841 static void |
847 readVampResponse_List(std::vector<Vamp::HostExt::PluginStaticData> &v, | 842 readVampResponse_List(Vamp::HostExt::ListResponse &resp, |
848 const VampResponse::Reader &r) { | 843 const VampResponse::Reader &r) { |
849 if (getRequestResponseType(r) != RRType::List) { | 844 if (getRequestResponseType(r) != RRType::List) { |
850 throw std::logic_error("not a list response"); | 845 throw std::logic_error("not a list response"); |
851 } | 846 } |
852 v.clear(); | 847 resp.pluginData.clear(); |
853 if (r.getSuccess()) { | 848 if (r.getSuccess()) { |
854 auto pp = r.getResponse().getList().getPlugins(); | 849 auto pp = r.getResponse().getList().getPlugins(); |
855 for (const auto &p: pp) { | 850 for (const auto &p: pp) { |
856 Vamp::HostExt::PluginStaticData psd; | 851 Vamp::HostExt::PluginStaticData psd; |
857 readPluginStaticData(psd, p); | 852 readPluginStaticData(psd, p); |
858 v.push_back(psd); | 853 resp.pluginData.push_back(psd); |
859 } | 854 } |
860 } | 855 } |
861 } | 856 } |
862 | 857 |
863 static void | 858 static void |