]> git.r.bdr.sh - rbdr/lyricli/blobdiff - Sources/source_manager.swift
Add the arguments source
[rbdr/lyricli] / Sources / source_manager.swift
diff --git a/Sources/source_manager.swift b/Sources/source_manager.swift
new file mode 100644 (file)
index 0000000..d0af817
--- /dev/null
@@ -0,0 +1,52 @@
+/// Manages the different sources. Keeps track of them, lists and toggles
+public class SourceManager {
+
+    private var availableSources: [String: Source] = [
+        "arguments": ArgumentsSource()
+    ]
+
+    var currentTrack: Track? {
+        get {
+
+            for source in enabledSources {
+                if let currentTrack = source.currentTrack {
+                    return currentTrack
+                }
+            }
+
+            return nil
+        }
+    }
+
+    var enabledSources: [Source] {
+
+        // Checks the config and returns an array of sources based on the
+        // enabled and available ones
+
+        get {
+            var sources = [Source]()
+
+            if let sourceNames = Configuration.sharedInstance["enabled_sources"] as? [String]{
+                for sourceName in sourceNames {
+                    if let source = availableSources[sourceName] {
+                        sources.append(source)
+                    }
+                }
+            }
+
+            return sources
+        }
+    }
+
+    func enable(sourceName: String) {
+    }
+
+    func disable(sourceName: String) {
+    }
+
+    func reset(sourceName: String) {
+    }
+
+    func getSources(sourceName: String) {
+    }
+}