Mercurial > hg > piper-cpp
comparison 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 |
comparison
equal
deleted
inserted
replaced
26:13393bdfc7ef | 27:cc85c2851605 |
---|---|
746 case VampRequest::Request::Which::PROCESS: | 746 case VampRequest::Request::Which::PROCESS: |
747 return RRType::Process; | 747 return RRType::Process; |
748 case VampRequest::Request::Which::FINISH: | 748 case VampRequest::Request::Which::FINISH: |
749 return RRType::Finish; | 749 return RRType::Finish; |
750 } | 750 } |
751 return RRType::NotValid; | |
751 } | 752 } |
752 | 753 |
753 static RRType | 754 static RRType |
754 getRequestResponseType(const VampResponse::Reader &r) { | 755 getRequestResponseType(const VampResponse::Reader &r) { |
755 switch (r.getResponse().which()) { | 756 switch (r.getResponse().which()) { |
762 case VampResponse::Response::Which::PROCESS: | 763 case VampResponse::Response::Which::PROCESS: |
763 return RRType::Process; | 764 return RRType::Process; |
764 case VampResponse::Response::Which::FINISH: | 765 case VampResponse::Response::Which::FINISH: |
765 return RRType::Finish; | 766 return RRType::Finish; |
766 } | 767 } |
768 return RRType::NotValid; | |
767 } | 769 } |
768 | 770 |
769 static void | 771 static void |
770 readVampRequest_List(const VampRequest::Reader &r) { | 772 readVampRequest_List(const VampRequest::Reader &r) { |
771 if (getRequestResponseType(r) != RRType::List) { | 773 if (getRequestResponseType(r) != RRType::List) { |
772 throw std::runtime_error("not a list request"); | 774 throw std::logic_error("not a list request"); |
773 } | 775 } |
774 } | 776 } |
775 | 777 |
776 static void | 778 static void |
777 readVampResponse_List(std::vector<Vamp::HostExt::PluginStaticData> &v, | 779 readVampResponse_List(std::vector<Vamp::HostExt::PluginStaticData> &v, |
778 const VampResponse::Reader &r) { | 780 const VampResponse::Reader &r) { |
779 if (getRequestResponseType(r) != RRType::List) { | 781 if (getRequestResponseType(r) != RRType::List) { |
780 throw std::runtime_error("not a list response"); | 782 throw std::logic_error("not a list response"); |
781 } | 783 } |
782 v.clear(); | 784 v.clear(); |
783 if (r.getSuccess()) { | 785 if (r.getSuccess()) { |
784 for (const auto &p: r.getResponse().getList().getPlugins()) { | 786 for (const auto &p: r.getResponse().getList().getPlugins()) { |
785 Vamp::HostExt::PluginStaticData psd; | 787 Vamp::HostExt::PluginStaticData psd; |
787 v.push_back(psd); | 789 v.push_back(psd); |
788 } | 790 } |
789 } | 791 } |
790 } | 792 } |
791 | 793 |
794 static void | |
795 readVampRequest_Load(Vamp::HostExt::LoadRequest &req, | |
796 const VampRequest::Reader &r) { | |
797 if (getRequestResponseType(r) != RRType::Load) { | |
798 throw std::logic_error("not a load request"); | |
799 } | |
800 readLoadRequest(req, r.getRequest().getLoad()); | |
801 } | |
802 | |
803 static void | |
804 readVampResponse_Load(Vamp::HostExt::LoadResponse &resp, | |
805 const VampResponse::Reader &r, | |
806 PluginHandleMapper &mapper) { | |
807 if (getRequestResponseType(r) != RRType::Load) { | |
808 throw std::logic_error("not a load response"); | |
809 } | |
810 resp = {}; | |
811 if (r.getSuccess()) { | |
812 readLoadResponse(resp, r.getResponse().getLoad(), mapper); | |
813 } | |
814 } | |
815 | |
816 static void | |
817 readVampRequest_Configure(Vamp::HostExt::ConfigurationRequest &req, | |
818 const VampRequest::Reader &r, | |
819 PluginHandleMapper &mapper) { | |
820 if (getRequestResponseType(r) != RRType::Configure) { | |
821 throw std::logic_error("not a configuration request"); | |
822 } | |
823 readConfigurationRequest(req, r.getRequest().getConfigure(), mapper); | |
824 } | |
825 | |
826 static void | |
827 readVampResponse_Configure(Vamp::HostExt::ConfigurationResponse &resp, | |
828 const VampResponse::Reader &r) { | |
829 if (getRequestResponseType(r) != RRType::Configure) { | |
830 throw std::logic_error("not a configuration response"); | |
831 } | |
832 resp = {}; | |
833 if (r.getSuccess()) { | |
834 readConfigurationResponse(resp, r.getResponse().getConfigure()); | |
835 } | |
836 } | |
837 | |
838 static void | |
839 readVampRequest_Process(Vamp::HostExt::ProcessRequest &req, | |
840 const VampRequest::Reader &r, | |
841 PluginHandleMapper &mapper) { | |
842 if (getRequestResponseType(r) != RRType::Process) { | |
843 throw std::logic_error("not a process request"); | |
844 } | |
845 readProcessRequest(req, r.getRequest().getProcess(), mapper); | |
846 } | |
847 | |
848 static void | |
849 readVampResponse_Process(Vamp::HostExt::ProcessResponse &resp, | |
850 const VampResponse::Reader &r) { | |
851 if (getRequestResponseType(r) != RRType::Process) { | |
852 throw std::logic_error("not a process response"); | |
853 } | |
854 resp = {}; | |
855 if (r.getSuccess()) { | |
856 readProcessResponse(resp, r.getResponse().getProcess()); | |
857 } | |
858 } | |
859 | |
860 static void | |
861 readVampRequest_Finish(Vamp::Plugin *&finishPlugin, | |
862 const VampRequest::Reader &r, | |
863 PluginHandleMapper &mapper) { | |
864 if (getRequestResponseType(r) != RRType::Finish) { | |
865 throw std::logic_error("not a finish request"); | |
866 } | |
867 finishPlugin = mapper.handleToPlugin | |
868 (r.getRequest().getFinish().getPluginHandle()); | |
869 } | |
870 | |
871 static void | |
872 readVampResponse_Finish(Vamp::HostExt::ProcessResponse &resp, | |
873 const VampResponse::Reader &r) { | |
874 if (getRequestResponseType(r) != RRType::Finish) { | |
875 throw std::logic_error("not a finish response"); | |
876 } | |
877 resp = {}; | |
878 if (r.getSuccess()) { | |
879 readProcessResponse(resp, r.getResponse().getFinish()); | |
880 } | |
881 } | |
792 }; | 882 }; |
793 | 883 |
794 } | 884 } |
795 | 885 |
796 | 886 |