summaryrefslogtreecommitdiff
path: root/NT/src/nodes.h
blob: a32408effcca2e64024908d3c4505bfd8b2c7752 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef ROTOR_NODES_H
#define ROTOR_NODES_H

#include "rotor.h"

using namespace std;

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;
	};
}


#endif //ROTOR_NODES_H