Mercurial > hg > piper-cpp
comparison json/VampJson.h @ 25:5b9690d18241
Pull up type determination into VampJson
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Tue, 24 May 2016 10:43:34 +0100 |
parents | 533ca5ca3404 |
children | 2d97883d20df |
comparison
equal
deleted
inserted
replaced
24:533ca5ca3404 | 25:5b9690d18241 |
---|---|
45 | 45 |
46 #include <vamp-hostsdk/Plugin.h> | 46 #include <vamp-hostsdk/Plugin.h> |
47 #include <vamp-hostsdk/PluginLoader.h> | 47 #include <vamp-hostsdk/PluginLoader.h> |
48 | 48 |
49 #include "bits/PluginHandleMapper.h" | 49 #include "bits/PluginHandleMapper.h" |
50 #include "bits/RequestResponseType.h" | |
50 | 51 |
51 namespace vampipe { | 52 namespace vampipe { |
52 | 53 |
53 /** | 54 /** |
54 * Convert the structures laid out in the Vamp SDK classes into JSON | 55 * Convert the structures laid out in the Vamp SDK classes into JSON |
990 } | 991 } |
991 return j["success"].bool_value(); | 992 return j["success"].bool_value(); |
992 } | 993 } |
993 | 994 |
994 public: | 995 public: |
996 static RRType | |
997 getRequestResponseType(json11::Json j) { | |
998 | |
999 if (!j["type"].is_string()) { | |
1000 throw Failure("string expected for type"); | |
1001 } | |
1002 | |
1003 std::string type = j["type"].string_value(); | |
1004 | |
1005 if (type == "list") return RRType::List; | |
1006 else if (type == "load") return RRType::Load; | |
1007 else if (type == "configure") return RRType::Configure; | |
1008 else if (type == "process") return RRType::Process; | |
1009 else if (type == "finish") return RRType::Finish; | |
1010 else { | |
1011 throw Failure("unknown or unexpected request/response type \"" + | |
1012 type + "\""); | |
1013 } | |
1014 } | |
1015 | |
995 static void | 1016 static void |
996 toVampRequest_List(json11::Json j) { | 1017 toVampRequest_List(json11::Json j) { |
997 | 1018 |
998 checkTypeField(j, "list"); | 1019 checkTypeField(j, "list"); |
999 } | 1020 } |