From 0dfbf40106d6a6c70d949e1f5bcfa1b33b20a68f Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Mon, 20 Jan 2014 01:59:04 +0000 Subject: member access permissions --- NT/src/factory.cpp | 1 + NT/src/factory.h | 2 +- NT/src/graph.h | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ NT/src/nodes.h | 4 +-- NT/src/rotor.cpp | 11 +++++-- NT/src/rotor.h | 22 ++++++++++++-- 6 files changed, 116 insertions(+), 9 deletions(-) diff --git a/NT/src/factory.cpp b/NT/src/factory.cpp index 73a96f4..86b6a48 100644 --- a/NT/src/factory.cpp +++ b/NT/src/factory.cpp @@ -10,6 +10,7 @@ Node_factory::Node_factory(){ } bool Node_factory::list_node(const string &_type,Json::Value &json){ for (auto& type: type_map) { +cerr<to_json(); return true; diff --git a/NT/src/factory.h b/NT/src/factory.h index 0482ebe..9d77cb7 100644 --- a/NT/src/factory.h +++ b/NT/src/factory.h @@ -13,7 +13,7 @@ namespace Rotor { for (auto t:type_map) delete t.second; } void add_type(Node* proto){ - type_map[proto->type]=proto; + type_map[proto->get_type()]=proto; }; void add_type(Node* proto,std::string category){ add_type(proto); diff --git a/NT/src/graph.h b/NT/src/graph.h index 87be66e..0a20ffe 100644 --- a/NT/src/graph.h +++ b/NT/src/graph.h @@ -1,6 +1,91 @@ #ifndef GRAPH_H #define GRAPH_H +/* +Graph object manages a collection of nodes and provides the interface for rendering frames + + +*/ + #include "rotor.h" +/* +namespace Rotor { + class Graph{ + public: + Graph(){duration=20.0;loaded = false;audio_loaded=false;bitRate=0;outW=640;outH=360;audio_thumb=new Audio_thumbnailer();use_fragmentation=false;analysis_seed=0;Log_name="";}; + Graph(const string& _uid,const string& _desc){ + Graph(); + init(_uid,_desc); + }; + void init(const string& _uid,const string& _desc){ + uid=_uid; + description=_desc; + duration=20.0; + framerate=25.0; + loaded=false; + cancelled=false; + }; + ~Graph(){ clear(); delete audio_thumb;}; + void clear(){ + for (auto n: nodes) { + delete n.second; + } + nodes.clear(); + loaded=false; + } + string uid; //every version of a graph has a UUID, no particular need to actually read its data(?) + //?? is it faster than using strings?? + string description; + std::unordered_map nodes; + vector find_nodes(const string &type); //could be a way of finding a set based on capabilities? + Node* find_node(const string &type); + bool signal_render(xmlIO &XML,const string &node,const double framerate); + bool video_render(const string &output_filename,const double framerate,int start, int end); + bool load(string data,string media_path); + bool loadFile(string &filename,string media_path); + bool parseXml(string media_path); + bool parseJson(string &data,string &media_path); + bool set_resolution(int w,int h); + bool preview(xmlIO &XML,string &node,string &format,int frame,int w,int h); + bool check_audio(string audio,string path); + bool print_features(xmlIO &XML,string &node); + bool load_audio(const string &filename,vector processors); + bool load_video(const string &nodeID,const string &filename);//can be performance or clip + bool set_bitrate(int b){ + if (b>1000){ + bitRate=b; + return true; + } + else return false; + } + bool set_fragmentation(bool f){ + use_fragmentation=f; + return true; + } + bool loaded; + double duration; + double framerate; + const string graphToString(); + xmlIO xml; + bool audio_loaded; + string audio_filename; + bool cancelled; + double progress; + int bitRate; + void set_log_name(string _Log_name){ + Log_name=_Log_name; + } + + Audio_thumbnailer *audio_thumb; + private: + int outW,outH; + bool use_fragmentation; + int analysis_seed; + string Log_name; + + }; +} +*/ + #endif //GRAPH_H diff --git a/NT/src/nodes.h b/NT/src/nodes.h index 64d14a2..1632363 100644 --- a/NT/src/nodes.h +++ b/NT/src/nodes.h @@ -17,7 +17,7 @@ namespace Rotor{ init(settings); }; const double &get_output(const Frame_parameters &frame){ - value=frame.time; + value=frame.get_time(); return value; } Time* clone(Json::Value &_settings) { return new Time(_settings);}; @@ -39,7 +39,7 @@ namespace Rotor{ }; const double &get_output(const Frame_parameters &frame){ result=1.0f; - for (auto var:factors->values) result*=var.get(frame); + for (auto var:factors->get_values()) result*=var.get(frame); return result; } Multiply* clone(Json::Value &_settings) { return new Multiply(_settings);}; diff --git a/NT/src/rotor.cpp b/NT/src/rotor.cpp index 5225c02..1b75187 100644 --- a/NT/src/rotor.cpp +++ b/NT/src/rotor.cpp @@ -7,13 +7,18 @@ 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->id:""; + json["input"]=connection?connection->get_id():""; return json; } @@ -25,7 +30,7 @@ Json::Value Variable_array_type::to_json(){ json["connectable"]=connectable?"yes":"no"; json["input"]=Json::arrayValue; for (auto& input: values) { - json["input"].append(input.connection?input.connection->id:""); + json["input"].append(input.is_connected()?input.get_connection_id():""); } return json; } @@ -42,7 +47,7 @@ Json::Value Node::to_json(){ node["type"]=type; node["type_id"]=type_id; node["title"]=title; - node["output_type"]=output_type(); + node["output_type"]=get_type(); node["description"]=description; node["id"]=id; node["ui_type"]=ui_type; diff --git a/NT/src/rotor.h b/NT/src/rotor.h index ef90eb6..040435b 100644 --- a/NT/src/rotor.h +++ b/NT/src/rotor.h @@ -70,6 +70,10 @@ namespace Rotor { Frame_parameters nextframe() const{ return Frame_parameters(time+(1.0/framerate),framerate,duration,w,h); } + double get_time() const{ + return time; + } + private: double time; //num/denom ? double framerate; double duration; @@ -83,6 +87,12 @@ namespace Rotor { virtual void init(Json::Value s)=0; virtual bool connect(Node* target)=0; virtual std::string get_type()=0; + bool is_connected(){ + if (connection) return true; + return false; + } + std::string get_connection_id(); + protected: Node* connection; bool connectable; std::string name; @@ -115,6 +125,7 @@ namespace Rotor { } return value; } + protected: T value; }; class Variable_array: public Variable { @@ -131,7 +142,7 @@ namespace Rotor { name=s["name"].asString(); } Json::Value to_json(); - std::string get_type(){ //need this to output node templates + std::string get_type(){ return TypeName::Get(); } bool connect(Node* target){ @@ -158,6 +169,8 @@ namespace Rotor { } return value; } + const std::vector>& get_values(){return values;}; + protected: std::vector> values; T value; }; @@ -187,9 +200,12 @@ namespace Rotor { } return false; } + std::string get_type(){return type;}; + std::string& get_id(){return id;}; Json::Value to_json(); virtual Node* clone(Json::Value &_settings)=0; - virtual std::string output_type()=0; + virtual std::string get_output_type()=0; + protected: std::string type; std::string id; std::string type_id; @@ -209,7 +225,7 @@ namespace Rotor { } if (settings["id"]!=nullptr) id=settings["id"].asString(); } - std::string output_type(){return TypeName::Get();}; + std::string get_output_type(){return TypeName::Get();}; template Variable_type* create_inlet(std::string name){ vars[name]=new Variable_type(name,true); return (dynamic_cast*>(vars[name])); -- cgit v1.2.3