comparison vamp-capnp/VampnProto.h @ 127:5b113c87b6e6

Add and implement the "from" param for list request. The simple-server implementation is not yet correct.
author Chris Cannam <c.cannam@qmul.ac.uk>
date Wed, 02 Nov 2016 14:27:42 +0000
parents d15cb1151d76
children 0876b5e67afe
comparison
equal deleted inserted replaced
126:2004ec2b653e 127:5b113c87b6e6
493 c.currentProgram = r.getCurrentProgram(); 493 c.currentProgram = r.getCurrentProgram();
494 c.channelCount = r.getChannelCount(); 494 c.channelCount = r.getChannelCount();
495 c.stepSize = r.getStepSize(); 495 c.stepSize = r.getStepSize();
496 c.blockSize = r.getBlockSize(); 496 c.blockSize = r.getBlockSize();
497 } 497 }
498 498
499 static void
500 buildListRequest(piper::ListRequest::Builder &r,
501 const ListRequest &resp) {
502
503 auto p = r.initFrom(unsigned(resp.from.size()));
504 for (int i = 0; i < int(resp.from.size()); ++i) {
505 p.set(i, resp.from[i]);
506 }
507 }
508
509 static void
510 readListRequest(ListRequest &lr,
511 const piper::ListRequest::Reader &r) {
512
513 lr.from.clear();
514 for (auto f: r.getFrom()) {
515 lr.from.push_back(f);
516 }
517 }
518
519 static void
520 buildListResponse(piper::ListResponse::Builder &r,
521 const ListResponse &resp) {
522
523 auto p = r.initAvailable(unsigned(resp.available.size()));
524 for (int i = 0; i < int(resp.available.size()); ++i) {
525 auto pd = p[i];
526 buildExtractorStaticData(pd, resp.available[i]);
527 }
528 }
529
499 static void 530 static void
500 readListResponse(ListResponse &lr, 531 readListResponse(ListResponse &lr,
501 const piper::ListResponse::Reader &r) { 532 const piper::ListResponse::Reader &r) {
502 533
503 lr.available.clear(); 534 lr.available.clear();
726 readFeatureSet(pr.features, r.getFeatures(), 757 readFeatureSet(pr.features, r.getFeatures(),
727 *pmapper.handleToOutputIdMapper(r.getHandle())); 758 *pmapper.handleToOutputIdMapper(r.getHandle()));
728 } 759 }
729 760
730 static void 761 static void
731 buildRpcRequest_List(piper::RpcRequest::Builder &b) { 762 buildRpcRequest_List(piper::RpcRequest::Builder &b,
732 b.getRequest().initList(); 763 const ListRequest &req) {
764 auto r = b.getRequest().initList();
765 buildListRequest(r, req);
733 } 766 }
734 767
735 static void 768 static void
736 buildRpcResponse_List(piper::RpcResponse::Builder &b, 769 buildRpcResponse_List(piper::RpcResponse::Builder &b,
737 const ListResponse &resp) { 770 const ListResponse &resp) {
738 771
739 auto r = b.getResponse().initList(); 772 auto r = b.getResponse().initList();
740 auto p = r.initAvailable(unsigned(resp.available.size())); 773 buildListResponse(r, resp);
741 for (int i = 0; i < int(resp.available.size()); ++i) {
742 auto pd = p[i];
743 buildExtractorStaticData(pd, resp.available[i]);
744 }
745 } 774 }
746 775
747 static void 776 static void
748 buildRpcRequest_Load(piper::RpcRequest::Builder &b, 777 buildRpcRequest_Load(piper::RpcRequest::Builder &b,
749 const LoadRequest &req) { 778 const LoadRequest &req) {
902 code = r.getResponse().getError().getCode(); 931 code = r.getResponse().getError().getCode();
903 message = r.getResponse().getError().getMessage(); 932 message = r.getResponse().getError().getMessage();
904 } 933 }
905 934
906 static void 935 static void
907 readRpcRequest_List(const piper::RpcRequest::Reader &r) { 936 readRpcRequest_List(ListRequest &req,
937 const piper::RpcRequest::Reader &r) {
908 if (getRequestResponseType(r) != RRType::List) { 938 if (getRequestResponseType(r) != RRType::List) {
909 throw std::logic_error("not a list request"); 939 throw std::logic_error("not a list request");
910 } 940 }
941 readListRequest(req, r.getRequest().getList());
911 } 942 }
912 943
913 static void 944 static void
914 readRpcResponse_List(ListResponse &resp, 945 readRpcResponse_List(ListResponse &resp,
915 const piper::RpcResponse::Reader &r) { 946 const piper::RpcResponse::Reader &r) {