aboutsummaryrefslogtreecommitdiff
path: root/Sources/source_manager.swift
diff options
context:
space:
mode:
authorBen Beltran <ben@nsovocal.com>2017-05-20 09:52:30 -0500
committerBen Beltran <ben@nsovocal.com>2017-05-20 09:52:30 -0500
commitee966aa755acd8eea53c982e43e13aef4f193984 (patch)
tree5df111da5948ea198c5db1ca8f62e6c6ebe51178 /Sources/source_manager.swift
parentbcd37f402a2586d051ac10a6a4982c8c226b2cce (diff)
parent0d4485a445dd387235c141afca7764481eac0311 (diff)
Merge branch 'release/0.1.0'0.1.0
Diffstat (limited to 'Sources/source_manager.swift')
-rw-r--r--Sources/source_manager.swift50
1 files changed, 50 insertions, 0 deletions
diff --git a/Sources/source_manager.swift b/Sources/source_manager.swift
new file mode 100644
index 0000000..5ee1305
--- /dev/null
+++ b/Sources/source_manager.swift
@@ -0,0 +1,50 @@
+// Collect and manage the available and enabled source
+class SourceManager {
+
+ // List of sources enabled for the crurent platform
+ private var availableSources: [String: Source] = [
+ "arguments": ArgumentsSource()
+ ]
+
+ // Iterate over the sources until we find a track or run out of sources
+ var currentTrack: Track? {
+ for source in enabledSources {
+ if let currentTrack = source.currentTrack {
+ return currentTrack
+ }
+ }
+
+ return nil
+ }
+
+ // Return the list of enabled sources based on the configuration
+ var enabledSources: [Source] {
+
+ // Checks the config and returns an array of sources based on the
+ // enabled and available ones
+
+ var sources = [Source]()
+
+ if let sourceNames = Configuration.shared["enabled_sources"] as? [String] {
+ for sourceName in sourceNames {
+ if let source = availableSources[sourceName] {
+ sources.append(source)
+ }
+ }
+ }
+
+ return sources
+ }
+
+ // Given a source name, it will enable it and add it to the enabled sources config
+ func enable(sourceName: String) {
+ }
+
+ // Given a source name, it will remove it from the enabled sources config
+ func disable(sourceName: String) {
+ }
+
+ // Given a source name, it removes any stored configuration and disables it
+ func reset(sourceName: String) {
+ }
+}