From d9abdcbce9f0c3c7dbfebc00827e05536cb196e4 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Mon, 30 Dec 2013 08:55:15 +0000 Subject: adding node factory --- NT/src/nodes.h | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 NT/src/nodes.h (limited to 'NT/src/nodes.h') diff --git a/NT/src/nodes.h b/NT/src/nodes.h new file mode 100644 index 0000000..5bb8830 --- /dev/null +++ b/NT/src/nodes.h @@ -0,0 +1,56 @@ +#include "rotor.h" + +namespace Rotor { + class time: public Node_type { + public: + time(){}; + time(map &settings):time() { + init(settings); + }; + const double &get_output(const Frame_parameters &frame){ + value=frame.time; + return value; + } + time* clone(map &_settings) { return new time(_settings);}; + private: + double value; + }; + class multiply: public Node_type { + public: + multiply(){ + inlet=create_inlet("inlet"); + value=create_inlet("value"); + } + multiply(map &settings):multiply() { + init(settings); + }; + const double &get_output(const Frame_parameters &frame){ + result=inlet->get(frame)*value->get(frame); + return result; + } + multiply* clone(map &_settings) { return new multiply(_settings);}; + private: + Variable_type *inlet; + Variable_type *value; + double result; + }; + class print: public Node_type { + public: + print(){ + inlet=create_inlet("inlet"); + } + print(map &settings):print() { + init(settings); + }; + const std::string &get_output(const Frame_parameters &frame){ + std::ostringstream out; + out << inlet->get(frame); + result=out.str(); + return result; + } + print* clone(map &_settings) { return new print(_settings);}; + private: + Variable_type *inlet; + std::string result; + }; +} -- cgit v1.2.3