summaryrefslogtreecommitdiff
path: root/NT/src/nodes.h
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2013-12-30 08:55:15 +0000
committerTim Redfern <tim@eclectronics.org>2013-12-30 08:55:15 +0000
commitd9abdcbce9f0c3c7dbfebc00827e05536cb196e4 (patch)
tree342cb8fe4e6c176fb07aee11ede41bb5263deee7 /NT/src/nodes.h
parentf7813a5324be39d13ab536c245d15dfc602a7849 (diff)
adding node factory
Diffstat (limited to 'NT/src/nodes.h')
-rw-r--r--NT/src/nodes.h56
1 files changed, 56 insertions, 0 deletions
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<double> {
+ public:
+ time(){};
+ time(map<string,string> &settings):time() {
+ init(settings);
+ };
+ const double &get_output(const Frame_parameters &frame){
+ value=frame.time;
+ return value;
+ }
+ time* clone(map<string,string> &_settings) { return new time(_settings);};
+ private:
+ double value;
+ };
+ class multiply: public Node_type<double> {
+ public:
+ multiply(){
+ inlet=create_inlet<double>("inlet");
+ value=create_inlet<double>("value");
+ }
+ multiply(map<string,string> &settings):multiply() {
+ init(settings);
+ };
+ const double &get_output(const Frame_parameters &frame){
+ result=inlet->get(frame)*value->get(frame);
+ return result;
+ }
+ multiply* clone(map<string,string> &_settings) { return new multiply(_settings);};
+ private:
+ Variable_type<double> *inlet;
+ Variable_type<double> *value;
+ double result;
+ };
+ class print: public Node_type<std::string> {
+ public:
+ print(){
+ inlet=create_inlet<double>("inlet");
+ }
+ print(map<string,string> &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<string,string> &_settings) { return new print(_settings);};
+ private:
+ Variable_type<double> *inlet;
+ std::string result;
+ };
+}