skip relations with missing mandatory attributes v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sat, 03 Oct 2020 13:40:07 +0200
branchv_0
changeset 13 a85c191709e6
parent 12 f56620b95180
child 14 9ad606c80d3b
skip relations with missing mandatory attributes
src/JackHandler.h
--- a/src/JackHandler.h	Sat Oct 03 12:50:31 2020 +0200
+++ b/src/JackHandler.h	Sat Oct 03 13:40:07 2020 +0200
@@ -100,6 +100,8 @@
 	 */
 	class RelationContext {
 	public:
+		bool skip = false;
+
 		size_t indexOfEvent = -1;
 		size_t indexOfChannel = -1;
 		size_t indexOfNoteOn = -1;
@@ -155,6 +157,7 @@
 
 		jack_set_process_callback(realTimeContext.jackClient, RealTimeContext::processCallback, &realTimeContext);
 		// TODO: report also other events (connections etc.)
+		// TODO: jack_set_error_function() + avoid mixing char and wchar output
 
 		realTimeContext.jackPort = jack_port_register(realTimeContext.jackClient, "output", JACK_DEFAULT_MIDI_TYPE, JackPortIsOutput, 0);
 		if (realTimeContext.jackPort == nullptr) throw JackException(L"Could not register port.");
@@ -190,9 +193,16 @@
 
 		// TODO: check also data types and skipt relation if important attributes are missing
 		// TODO: configurable relation name
+
+		if (relationContext.indexOfEvent == -1 || relationContext.indexOfRaw == -1) {
+			relationContext.skip = true;
+			fwprintf(stderr, L"Relation „%ls“ will be ignored because mandatory attributes are missing.\n", name.c_str());
+		}
+
 	}
 
 	void attribute(const relpipe::common::type::StringX& value) override {
+		if (relationContext.skip) return;
 		// TODO: switch to RelationalReaderStringHandler
 		// TODO: if (continueProcessing) {} ?