summaryrefslogtreecommitdiff
path: root/Gate.h
diff options
context:
space:
mode:
authorDaniel Jones <admin@danieljon.es>2020-06-29 22:45:32 +0930
committerDaniel Jones <admin@danieljon.es>2020-06-29 22:45:32 +0930
commit1e76ef7d2df9d49a905f416774f33fdedfcf6f34 (patch)
tree22e37a8cb08cb84232e99bc235d20549a495d587 /Gate.h
parent11937e7d2256702698baba3acaf847523fe0f066 (diff)
downloadfoxlogicgates-1e76ef7d2df9d49a905f416774f33fdedfcf6f34.tar.gz
foxlogicgates-1e76ef7d2df9d49a905f416774f33fdedfcf6f34.zip
Logic: created ned Object class and derived gates from that
This class will allow us to make new devices (displays, custom gates etc) easily
Diffstat (limited to 'Gate.h')
-rw-r--r--Gate.h26
1 files changed, 3 insertions, 23 deletions
diff --git a/Gate.h b/Gate.h
index 7073aa7..a0d8cf6 100644
--- a/Gate.h
+++ b/Gate.h
@@ -18,8 +18,9 @@
#include <string>
#include <vector>
+#include "Object.h"
-class Gate
+class Gate : public Object
{
public:
enum GATE_TYPE
@@ -36,52 +37,31 @@ class Gate
XNOR,
};
- Gate(GATE_TYPE type = INPUT, int x = 0, int y = 0, int width = 70, int height = 50, int loaded_id = -1);
+ Gate(GATE_TYPE type = INPUT, int x = 0, int y = 0, int width = 70, int height = 50, int id = -1);
~Gate();
- int get_id() { return this->id; }
- int get_x() { return this->x; };
- int get_y() { return this->y; };
- int get_width() { return this->w; };
- int get_height() { return this->h; };
bool get_output_state() { return this->output_state; };
std::vector<int> *get_output_gates() { return &this->output_gate_ids; };
GATE_TYPE get_gate_type() { return this->gate_type; };
Gate *get_input_gate1() { return this->input_gate1; };
Gate *get_input_gate2() { return this->input_gate2; };
- //Gate *get_output_gate() { return this->output_gate; };
std::string get_output_type_text();
- void set_x(int x) { this->x = x; };
- void set_y(int y) { this->y = y; };
void set_state(bool state) { this->output_state = state; };
void set_input_gate1(Gate *gate) { this->input_gate1 = gate; };
void set_input_gate2(Gate *gate) { this->input_gate2 = gate; };
- //void set_output_gate(Gate *gate) { this->output_gate = gate; };
void add_output_gate_id(int id) { this->output_gate_ids.push_back(id); };
void remove_output_gate_id(int id);
void remove_input_gate(int id);
void update_state();
- static void set_id_counter(int id) { gate_id_counter = id; };
- static int get_id_counter() { return gate_id_counter; };
private:
GATE_TYPE gate_type;
- int id;
- int x;
- int y;
- int w;
- int h;
-
- static int gate_id_counter; // used as the id of a new gate - this is NOT a count of the number of gates
/* inputs/outputs */
Gate *input_gate1;
Gate *input_gate2;
- //Gate *output_gate;
- std::vector<int> output_gate_ids;
-
/* states */
bool output_state = false;
};