more bones v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Fri, 18 Dec 2020 21:35:36 +0100
branchv_0
changeset 1 98274757fcf6
parent 0 4ee5349be21d
child 2 f34476ab597f
more bones
DJMFix.cpp
DJMFix.h
Makefile
djm-fix.cpp
--- a/DJMFix.cpp	Fri Dec 18 20:13:05 2020 +0100
+++ b/DJMFix.cpp	Fri Dec 18 21:35:36 2020 +0100
@@ -14,3 +14,42 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
+#include <iostream>
+
+#include "DJMFix.h"
+
+namespace djmfix {
+
+class DJMFixImpl : public DJMFix {
+private:
+	MidiSender midiSender;
+public:
+
+	DJMFixImpl(MidiSender midiSender) : midiSender(midiSender) {
+		std::cerr << "DJMFixImpl()" << std::endl; // TODO: do not mess STDIO
+	}
+
+	virtual ~DJMFixImpl() override {
+		std::cerr << "~DJMFixImpl()" << std::endl; // TODO: do not mess STDIO
+	}
+
+	virtual void receive(MidiMessage midiMessage) override {
+		std::cerr << "DJMFixImpl::receive()" << std::endl; // TODO: do not mess STDIO
+
+		midiSender({0xf0, 0xf7});
+	}
+
+	void start() override {
+		std::cerr << "DJMFixImpl::start()" << std::endl; // TODO: do not mess STDIO
+	}
+
+	void stop() override {
+		std::cerr << "DJMFixImpl::stop()" << std::endl; // TODO: do not mess STDIO
+	}
+};
+
+DJMFix* create(MidiSender midiSender) {
+	return new DJMFixImpl(midiSender);
+}
+
+}
--- a/DJMFix.h	Fri Dec 18 20:13:05 2020 +0100
+++ b/DJMFix.h	Fri Dec 18 21:35:36 2020 +0100
@@ -14,3 +14,24 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
+#pragma once
+
+#include <vector>
+#include <functional>
+
+namespace djmfix {
+
+using MidiMessage = std::vector<uint8_t>;
+using MidiSender = std::function<void(MidiMessage) >;
+
+class DJMFix {
+public:
+	virtual ~DJMFix() = default;
+	virtual void receive(MidiMessage midiMessage) = 0;
+	virtual void start() = 0;
+	virtual void stop() = 0;
+};
+
+DJMFix* create(MidiSender midiSender);
+
+}
--- a/Makefile	Fri Dec 18 20:13:05 2020 +0100
+++ b/Makefile	Fri Dec 18 21:35:36 2020 +0100
@@ -18,7 +18,10 @@
 clean:
 	rm -rf build
 
-.PHONY: all clean
+run: build/djm-fix
+	build/djm-fix
+
+.PHONY: all clean run
 
 build/djm-fix: DJMFix.cpp DJMFix.h djm-fix.cpp
 	mkdir -p build
--- a/djm-fix.cpp	Fri Dec 18 20:13:05 2020 +0100
+++ b/djm-fix.cpp	Fri Dec 18 21:35:36 2020 +0100
@@ -15,6 +15,21 @@
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <memory>
+#include <iostream>
+
+#include "DJMFix.h"
+
 int main(int argc, char**argv) {
+
+	std::shared_ptr<djmfix::DJMFix> djmFix(djmfix::create([](djmfix::MidiMessage midiMessage) {
+		std::cerr << "main: will send midiMessage" << std::endl; // TODO: do not mess STDIO
+	}));
+
+	djmFix->start();
+	djmFix->receive({0xf0, 0xf7});
+	djmFix->stop();
+
+
 	return 0;
 }