aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-06-04 12:13:52 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-06-04 12:13:52 +0200
commitf384fdc3a9e4acccac2e4d322676e34115a168f7 (patch)
tree4a5ee252658508b934888324e35a6f633b1a631d
parentc084bee21f66e6322d4d55b8700f0779f2c58d0d (diff)
WIP meer nadenk
-rw-r--r--docs/Parser.h16
-rw-r--r--docs/class-diag.puml20
-rw-r--r--main.cpp48
-rw-r--r--readme.md5
4 files changed, 71 insertions, 18 deletions
diff --git a/docs/Parser.h b/docs/Parser.h
new file mode 100644
index 0000000..a7c90e9
--- /dev/null
+++ b/docs/Parser.h
@@ -0,0 +1,16 @@
+#pragma once
+
+#include <iostream>
+#include <istream>
+
+using std::ostream;
+
+class Parser {
+
+ friend void operator >> (Parser& p, std::istream& filestream) {
+ // cout assigned to another object mycout
+ std::cout << "the file contains:\n" << filestream << std::endl;
+ mycout << "Value of dx and dy are \n";
+ mycout << d.dx << " " << d.dy;
+ }
+}
diff --git a/docs/class-diag.puml b/docs/class-diag.puml
index 85cb721..ea245cd 100644
--- a/docs/class-diag.puml
+++ b/docs/class-diag.puml
@@ -1,12 +1,13 @@
@startuml
abstract class Node { /' (also ConcreteObserver) '/
- + label: string
- + type: string
- + addOutput(Net*)
+ + setOutput(Net*)
+ addInput(Net*)
- inputs: Net*[]
- - outputs: Net*[]
+ - output: Net*
+ - type: static constexpr const string
+ - minInputs: constexpr unsigned int
+ - maxInputs: constexpr int
}
class Net { /' (also ConcreteSubject) '/
- level: SignalLevel
@@ -62,5 +63,16 @@ class CircuitFactory {
+ configure()
}
+class Circuit {
+ + createNode(string type, string label)
+ + createLink(string labelA, string labelB)
+
+ - nets: Map<string label, Net*>
+ - nodes: Map<string label, Node*>
+}
+
+CircuitFactory -[dashed]> Node
+CircuitFactory <-[dashed]- Node
+
@enduml
diff --git a/main.cpp b/main.cpp
index 05ec033..01b78b2 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1,17 +1,39 @@
-#include <cstdio>
-// #include "Observer.h"
-#include "Net.h"
-#include "Gate.h"
+#include <iostream>
+#include <exception>
+#include <fstream>
+
+#include "Parser.h"
+#include "Circuit.h"
+
+using std::cout;
+using std::endl;
+using std::fstream;
+using std::exception;
int main(int argc, char** argv) {
- // Observer ob();
- Net n;
- Gate *g = new GateAnd;
- g->addInput(&n);
- n.setLevel(HIGH);
- int level = 22;
- level = n.getLevel();
- printf("hello world! %d\n", level);
- return 0;
+ Parser main_parser;
+ Circuit circuit;
+
+ main_parser.setCircuit(circuit);
+
+ fstream file{"circuits/full-adder.txt", file.out};
+
+ try {
+ main_parser << file;
+ } catch (exception e) {
+ cout << "Parser error: " << e.what() << endl;
+ return EXIT_FAILURE;
+ }
+
+ try {
+ circuit.run();
+ } catch (exception e) {
+ cout << "Circuit error: " << e.what() << endl;
+ return EXIT_FAILURE;
+ }
+
+ cout << "Circuit output: " << circuit.getOutput() << endl;
+
+ return EXIT_SUCCESS;
}
diff --git a/readme.md b/readme.md
index 218a2e0..1703a9f 100644
--- a/readme.md
+++ b/readme.md
@@ -9,7 +9,10 @@ make
## Applied design patters
- Observer
-- Factory
+- Low binding factory
+- Prototype
+- Dependency injection
+- vast meer!
## TODO