diff options
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; +} |
