#include #include "rotor.h" #include "nodes.h" #include "factory.h" using namespace std; using namespace Rotor; string Variable::get_connection_id(){ if (connection) return connection->get_id(); return ""; } template Json::Value Variable_type::to_json(){ Json::Value json; json["type"]=get_type(); json["name"]=name; json["connectable"]=connectable?"yes":"no"; json["input"]=connection?connection->get_id():""; return json; } template Json::Value Variable_array_type::to_json(){ Json::Value json; json["type"]=get_type(); json["name"]=name; json["connectable"]=connectable?"yes":"no"; json["input"]=Json::arrayValue; for (auto& input: values) { json["input"].append(input.is_connected()?input.get_connection_id():""); } return json; } //explicit template instantiation template class Variable_type; template class Variable_type; template class Variable_array_type; Json::Value Node::to_json(){ Json::Value node; node["type"]=type; node["type_id"]=type_id; node["title"]=title; node["output_type"]=get_output_type(); node["description"]=description; node["id"]=id; node["ui_type"]=ui_type; if (vars.size()){ node["vars"]=Json::arrayValue; for (auto& var: vars) { node["vars"].append(var.second->to_json()); } } return node; } //factory generates linker errors if rotor.h implementation is seperated: why? int main(){ Node_factory f; /* map settings={{"node_type","time"}}; Node *t=f.create(settings); settings={{"value","2"},{"node_type","multiply"}}; Node *m=f.create(settings); if (!m->connect("inlet",t)) printf("not connected...\n"); settings={{"node_type","print"}}; Node *p=f.create(settings); if (!p->connect("inlet",m)) printf("not connected...\n"); for (double t=0;t<10.0;t+=0.765){ Frame_parameters f=Frame_parameters(t,25.0,10.0,640,360); printf("%04f %s\n",t,(dynamic_cast*>(p))->get_output(f).c_str()); } delete t; delete m; delete p; */ Json::Value js; f.list_node("time",js); Json::StyledWriter writer; cerr<