Mercurial > hg > piper-cpp
diff 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 |
line wrap: on
line diff
--- a/json/VampJson.h Mon May 23 16:09:25 2016 +0100 +++ b/json/VampJson.h Tue May 24 10:43:34 2016 +0100 @@ -47,6 +47,7 @@ #include <vamp-hostsdk/PluginLoader.h> #include "bits/PluginHandleMapper.h" +#include "bits/RequestResponseType.h" namespace vampipe { @@ -992,6 +993,26 @@ } public: + static RRType + getRequestResponseType(json11::Json j) { + + if (!j["type"].is_string()) { + throw Failure("string expected for type"); + } + + std::string type = j["type"].string_value(); + + if (type == "list") return RRType::List; + else if (type == "load") return RRType::Load; + else if (type == "configure") return RRType::Configure; + else if (type == "process") return RRType::Process; + else if (type == "finish") return RRType::Finish; + else { + throw Failure("unknown or unexpected request/response type \"" + + type + "\""); + } + } + static void toVampRequest_List(json11::Json j) {