#include "graph.h" using namespace Rotor; using namespace std; bool Graph::check_audio(string audio,string path){ if (audio!="") { audio_filename=path+audio; Poco::File f=Poco::File(audio_filename); if (f.exists()) { //here we should check the audio is actually valid audio_loaded=true; cerr<<"Rotor: loading "<::iterator it=nodes.begin();it!=nodes.end();++it) { if (it->second->get_type()==type) return it->second; } return nullptr; }; bool Graph::parse_json(string &data,string &media_path){ Json::Value root; // will contain the root value after parsing. Json::Reader reader; bool parsing_successful = reader.parse( data, root ); if ( !parsing_successful ) { std::cout << "Failed to parse configuration\n" << reader.getFormattedErrorMessages(); return false; } //The json validates, now we should attempt to retain nodes which haven't changed //for now just clear the existing graph clear(); Node_factory factory; check_audio(root["audio"].asString(),media_path); init(root["id"].asString()); Json::Value jnodes = root["nodes"]; for ( uint32_t i = 0; i < jnodes.size(); ++i ) { string node_id=jnodes[i]["id"].asString(); Node* node=factory.create(jnodes[i]); if (node) { if (nodes.find(node_id)==nodes.end()){ cerr << "Rotor: creating node '"<create_connections(nodes); nodes[node_id]=node; } else cerr << "ERROR: duplicate node '"<