#include "factory.h" using namespace Rotor; using namespace std; Node_factory::Node_factory(std::string _log_id){ log_id=_log_id; //for now, statically load prototype map in constructor add_type(new Time(),"nodes"); add_type(new Multiply(),"nodes"); add_type(new Print(),"nodes"); } 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 json; } } json["error"]="Node '"+_type+"' not found"; 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; }