diff options
| author | Tim Redfern <tim@eclectronics.org> | 2014-01-27 12:24:41 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2014-01-27 12:24:41 +0000 |
| commit | 487fcf990f3c536d7e1d2f66daa0c34c0407eac5 (patch) | |
| tree | 4f0dd5aa9d74af5e3e7628fbe20e1f0af60f512a /NT/src/factory.cpp | |
| parent | 1f2bc21fd5ee9bff4fce190d7bb0ee4462e76e87 (diff) | |
NT resinstated as HTTP server
Diffstat (limited to 'NT/src/factory.cpp')
| -rw-r--r-- | NT/src/factory.cpp | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/NT/src/factory.cpp b/NT/src/factory.cpp index b8f4642..2bd51ac 100644 --- a/NT/src/factory.cpp +++ b/NT/src/factory.cpp @@ -10,14 +10,39 @@ Node_factory::Node_factory(std::string _log_id){ add_type(new Multiply(),"nodes"); add_type(new Print(),"nodes"); } -bool Node_factory::list_node(const string &_type,Json::Value &json){ +Json::Value Node_factory::list_node(const string &_type){ + Json::Value json; for (auto& type: type_map) { if (type.first==_type) { json["node"]=type.second->to_json(); - return true; + return json; } } json["error"]="Node '"+_type+"' not found"; - return false; + return json; }; +Json::Value Node_factory::list_nodes(){ + Json::Value json; + json["nodeslist"]=Json::arrayValue; + for (auto& type: type_map) { + if (type.second->get_description()!="") { //blank description = internal/ testing node + json["nodeslist"].append(list_node(type.first)); + } + } + return json; +} +Json::Value Node_factory::list_categories(){ + Json::Value json; + json["category"]=Json::arrayValue; + for (auto& _category: category_map) { + Json::Value category; + category["name"]=_category.first; + category["nodes"]=Json::arrayValue; + for (auto& _node: _category.second){ + category["nodes"].append(list_node(_node->get_type())); + } + json["category"].append(category); + } + return json; +} |
