1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-14 06:23:20 +08:00

Secondary documentation pass on BeatmapStore

This commit is contained in:
Dean Herbert 2017-07-26 23:13:02 +09:00
parent 99e53b5109
commit 07d4d2dbe4

View File

@ -27,22 +27,30 @@ namespace osu.Game.Beatmaps
// todo: make this private
public readonly BeatmapDatabase Database;
private readonly Storage storage;
private readonly FileDatabase files;
private readonly RulesetDatabase rulesets;
/// <summary>
/// Fired when a new <see cref="BeatmapSetInfo"/> becomes available in the database.
/// </summary>
public event Action<BeatmapSetInfo> BeatmapSetAdded;
public event Action<BeatmapSetInfo> BeatmapSetRemoved;
// ReSharper disable once NotAccessedField.Local (we should keep a reference to this so it is not finalised)
private BeatmapIPCChannel ipc;
/// <summary>
/// Fired when a <see cref="BeatmapSetInfo"/> is removed from the database.
/// </summary>
public event Action<BeatmapSetInfo> BeatmapSetRemoved;
/// <summary>
/// A default representation of a WorkingBeatmap to use when no beatmap is available.
/// </summary>
public WorkingBeatmap DefaultBeatmap { private get; set; }
private readonly Storage storage;
private readonly FileDatabase files;
private readonly RulesetDatabase rulesets;
// ReSharper disable once NotAccessedField.Local (we should keep a reference to this so it is not finalised)
private BeatmapIPCChannel ipc;
public BeatmapStore(Storage storage, FileDatabase files, SQLiteConnection connection, RulesetDatabase rulesets, IIpcHost importHost = null)
{
Database = new BeatmapDatabase(connection);
@ -167,6 +175,21 @@ namespace osu.Game.Beatmaps
Database.Reset();
}
/// <summary>
/// Perform a lookup query on available <see cref="BeatmapSetInfo"/>s.
/// </summary>
/// <param name="query">The query.</param>
/// <returns>The first result for the provided query, or null if no results were found.</returns>
public BeatmapSetInfo QueryBeatmapSet(Func<BeatmapSetInfo, bool> query)
{
BeatmapSetInfo set = Database.Query<BeatmapSetInfo>().FirstOrDefault(query);
if (set != null)
Database.GetChildren(set, true);
return set;
}
/// <summary>
/// Creates an <see cref="ArchiveReader"/> from a valid storage path.
/// </summary>
@ -257,15 +280,5 @@ namespace osu.Game.Beatmaps
return beatmapSet;
}
public BeatmapSetInfo QueryBeatmapSet(Func<BeatmapSetInfo, bool> func)
{
BeatmapSetInfo set = Database.Query<BeatmapSetInfo>().FirstOrDefault(func);
if (set != null)
Database.GetChildren(set, true);
return set;
}
}
}