#include #include #include #include #include "utils.h" namespace Rotor { template void from_string(T t,std::string s) { std::istringstream cur(s); cur >> t; }; class Node; class Frame_parameters; class Variable { //base type for variable pointers public: virtual void init(std::string s){}; virtual ~Variable(){}; Node* connection; bool connectable; }; template class Variable_type : public Variable { public: void init(std::string s){ from_string(value,s); }; T* get(Frame_parameters frame); T value; }; //what happens if we want to link an unlinked attribute at runtime //should attributes and paramaters just be the same thing //it would be really nice if there could be arithmetic //type objects that could act on multiple types //either we call them attributes and inlets or just vars //for the author, is it better to have seperate static members? //for the GUI, yes. but is that another issue? //does the gui need a hint for the "basic" mode inlets so they stand out? class Node { //base type for node pointers public: virtual ~Node(){ for (auto v:vars){ delete v.second; } } protected: std::unordered_map vars; }; template class Node_type : public Node { public: NT* get_output(Frame_parameters frame); void init(std::map settings){ for (auto s:settings) { if (vars.find(s.first)){ vars[s.first]->init(s.second); } } } template IT* create_inlet(std::string name){ vars[name]=new Variable_type(); return &((dynamic_cast*>(vars[name]))->value); } }; class a_node: public Node_type { public: a_node(){ p1=create_inlet("p1"); p2=create_inlet("p2"); p3=create_inlet("p3"); //initialise the pointer to point at the instance variable //how to delete the vars ??? }; private: int *p1; float *p2; double *p3; }; }