aboutsummaryrefslogtreecommitdiff
path: root/Sources/source_manager.swift
blob: e55cc8b18ae19e1acc222b442c6be788b21ea09c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/// Manages the different sources. Keeps track of them, lists and toggles
class SourceManager {

    private var availableSources: [String: Source] = [
        "arguments": ArgumentsSource()
    ]

    var currentTrack: Track? {
        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

        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) {
    }
}