-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNode.h
More file actions
72 lines (60 loc) · 3.02 KB
/
Node.h
File metadata and controls
72 lines (60 loc) · 3.02 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* Node.h
*
* Created on: Jan 18, 2016
* Author: sabeyruw
*/
#ifndef NODE_H_
#define NODE_H_
#if defined(ENERGIA) && !defined(EMBEDDED_MODE)
#define EMBEDDED_MODE
#endif
#include "Vector.h"
// ADT's for building the graph.
/**
* Every object in the graph is an instance of a Node class. But this node
* behaves differently according to its responsibilities.
*/
class Node
{
public:
typedef Vector<Node*> NodeVector;
private:
NodeVector nextNodes;
NodeVector auxiliaryNodes;
NodeVector previousNodes;
int inDegrees;
bool initialized;
bool computationNode;
int threadIndex;
Node* transferredNode;
public:
explicit Node() : inDegrees(0), initialized(false), computationNode(false), threadIndex(0), transferredNode(0) {}
virtual ~Node() { nextNodes.clear(); auxiliaryNodes.clear(); previousNodes.clear(); }
bool isInitialized() const { return initialized; }
void setInitialized(const bool initialized) { this->initialized = initialized; }
bool isComputationNode() const { return computationNode; }
void setComputationNode(const bool computationNode) { this->computationNode = computationNode; }
void addAuxiliaryNode(Node* that) { this->auxiliaryNodes.push_back(that); }
void addPreviousNode(Node* that) { this->previousNodes.push_back(that); }
void addNextNode(Node* that) { this->nextNodes.push_back(that); }
bool isPreviousNodesEmpty() const { return this->previousNodes.empty(); }
bool auxiliaryNodesEmpty() const { return this->auxiliaryNodes.empty(); }
NodeVector& getNextNodes() { return this->nextNodes; }
NodeVector& getPreviousNodes() { return this->previousNodes; }
NodeVector& getAuxiliaryNodes() { return this->auxiliaryNodes; }
void operator++() { this->inDegrees++; }
void operator--() { this->inDegrees--; }
int getInDegrees() const { return inDegrees; }
void setInDegrees(const int& inDegrees) { this->inDegrees = inDegrees; }
int getThreadIndex() const { return threadIndex; }
void setThreadIndex(const int& threadIndex) { this->threadIndex = threadIndex; }
void setTransferredNode(Node* transferredNode) { this->transferredNode = transferredNode; }
Node* getTransferredNode() const { return this->transferredNode; }
virtual const char* getName() const =0;
virtual unsigned int getSize() const =0;
protected: // Copy constructor and operator is not allowed inside the framework
Node(Node const&);
Node& operator=(Node const&);
};
#endif /* NODE_H_ */