blob: 96851414e75ad3bb88f542074c47a307433b0e06 (
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
|
#pragma once
#include <string>
#include <vector>
#include "Observer.h"
#include "Net.h"
#include "NodeVisitor.h"
using std::string;
using std::vector;
class Node : Observer {
public:
Node() = default;
virtual ~Node() = default;
virtual Node * clone() const = 0;
public:
//! alias to \p sim() for Observer
void update();
virtual void addInput(Net *);
virtual void setOutput(Net *);
//! validate and simulate
virtual void sim();
//! logical implementation of the node/gate
virtual SignalLevel level() = 0;
protected:
Node(const char * type);
vector<Net *> inputs;
Net * output = nullptr;
protected:
int min_inputs = 2; // at least 2 inputs for most gates
int max_inputs = -1; // unlimited
public:
virtual void accept(NodeVisitor & visitor) { visitor.visit(*this); }
friend NodeVisitor;
};
|