blob: f294756a6ecd625e8558a4e6a665da2eb511e9e3 (
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
65
66
67
68
69
70
71
72
73
74
|
#ifndef ROTOR_NODES_H
#define ROTOR_NODES_H
#include "rotor.h"
using namespace std;
namespace Rotor{
class Double_node: public Node_type<double> {
public:
Double_node(){output_type="double";};
};
class Time: public Double_node {
public:
Time(){node_type="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 Double_node {
public:
Multiply(){
inlets=create_array<double>("inlet");
value=create_inlet<double>("value");
node_type="multiply";
}
Multiply(map<string,string> &settings):Multiply() {
init(settings);
};
const double &get_output(const Frame_parameters &frame){
result=inlets->get(0,frame)*value->get(frame);
return result;
}
Multiply* clone(map<string,string> &_settings) { return new Multiply(_settings);};
private:
Variable_array_type<double> *inlets;
Variable_type<double> *value;
double result;
};
class String_node: public Node_type<string> {
public:
String_node(){output_type="string";};
};
class Print: public String_node {
public:
Print(){
inlet=create_inlet<double>("inlet");
node_type="print";
}
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
|