-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathxNode.h
More file actions
53 lines (42 loc) · 1.06 KB
/
xNode.h
File metadata and controls
53 lines (42 loc) · 1.06 KB
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
/*
* The Mailo Today Solutions Software License
*
* Copyright 2016 Mailo Today Solutions.
*
* This program is free software, distributed under the terms of the
* GNU General Public License (GPL)
* http://www.gnu.org/licenses
*/
#pragma once
#include <vector>
using namespace std;
class xNode{
protected:
static unsigned int id_base;
int _typeid;
unsigned int xNodeID;
vector<xNode *>parents;
vector<xNode *> children;
bool evaluated;
virtual void evaluate() = 0;
public:
xNode();
template<typename T> void connect(xNode *, T &, T &);
void addParent(xNode *);
unsigned int getNodeID();
bool hasEvaluated();
void evaluateNode();
void evaluateUp();
};
template<typename T>
void xNode::connect(xNode *child, T &from, T &to){
for(xNode *n: children){
if(n->getNodeID() == child->getNodeID()){
to = from;
return;
}
}
children.push_back(child);
to = from;
child->addParent(this);
}