diff options
| author | Ben Beltran <ben@nsovocal.com> | 2017-05-20 09:40:30 -0500 |
|---|---|---|
| committer | Ben Beltran <ben@nsovocal.com> | 2017-05-20 09:40:30 -0500 |
| commit | 29a566fada656091bf92456f6fb0f1bea5b6dca3 (patch) | |
| tree | ca3abc17d3b5077db6b6a1e6d70e4702613eb427 /Sources/source_manager.swift | |
| parent | 85d0536f2e9a3d4596c01b263d76b2b8d9ba70ae (diff) | |
| parent | d852b84edc24f1f1bbf4c34aa359447970e732b0 (diff) | |
Merge branch 'feature/rbdr-document-and-cleanup' into develop
Diffstat (limited to 'Sources/source_manager.swift')
| -rw-r--r-- | Sources/source_manager.swift | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/Sources/source_manager.swift b/Sources/source_manager.swift index dd956ad..5ee1305 100644 --- a/Sources/source_manager.swift +++ b/Sources/source_manager.swift @@ -1,52 +1,50 @@ -/// Manages the different sources. Keeps track of them, lists and toggles +// 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? { - get { - - for source in enabledSources { - if let currentTrack = source.currentTrack { - return currentTrack - } + for source in enabledSources { + if let currentTrack = source.currentTrack { + return currentTrack } - - return nil } + + 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 - get { - var sources = [Source]() + var sources = [Source]() - if let sourceNames = Configuration.sharedInstance["enabled_sources"] as? [String]{ - for sourceName in sourceNames { - if let source = availableSources[sourceName] { - sources.append(source) - } + if let sourceNames = Configuration.shared["enabled_sources"] as? [String] { + for sourceName in sourceNames { + if let source = availableSources[sourceName] { + sources.append(source) } } - - return sources } + + 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) { } - - func getSources(sourceName: String) { - } } |