aboutsummaryrefslogtreecommitdiff
path: root/Sources/source_manager.swift
blob: dd956ad3ca680418376cc06e1b494d14f511ac3b (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
48
49
50
51
52
/// Manages the different sources. Keeps track of them, lists and toggles
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) {
    }
}