2021-09-30 15:44:39 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-06-12 02:17:05 +08:00
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
2021-09-30 15:44:39 +08:00
|
|
|
using System.Collections.Generic;
|
2019-06-12 01:12:57 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Database
|
|
|
|
{
|
2019-06-12 21:05:34 +08:00
|
|
|
/// <summary>
|
2019-11-17 20:48:23 +08:00
|
|
|
/// Represents a model manager that publishes events when <typeparamref name="TModel"/>s are added or removed.
|
2019-06-12 21:05:34 +08:00
|
|
|
/// </summary>
|
|
|
|
/// <typeparam name="TModel">The model type.</typeparam>
|
2021-11-05 15:27:13 +08:00
|
|
|
public interface IModelManager<TModel>
|
2019-06-12 21:05:34 +08:00
|
|
|
where TModel : class
|
2019-06-12 01:12:57 +08:00
|
|
|
{
|
2021-09-30 15:44:39 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Delete an item from the manager.
|
|
|
|
/// Is a no-op for already deleted items.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="item">The item to delete.</param>
|
|
|
|
/// <returns>false if no operation was performed</returns>
|
|
|
|
bool Delete(TModel item);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Delete multiple items.
|
|
|
|
/// This will post notifications tracking progress.
|
|
|
|
/// </summary>
|
|
|
|
void Delete(List<TModel> items, bool silent = false);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Restore multiple items that were previously deleted.
|
|
|
|
/// This will post notifications tracking progress.
|
|
|
|
/// </summary>
|
|
|
|
void Undelete(List<TModel> items, bool silent = false);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Restore an item that was previously deleted. Is a no-op if the item is not in a deleted state, or has its protected flag set.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="item">The item to restore</param>
|
|
|
|
void Undelete(TModel item);
|
|
|
|
|
2021-09-30 17:21:16 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Checks whether a given <typeparamref name="TModel"/> is already available in the local store.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="model">The <typeparamref name="TModel"/> whose existence needs to be checked.</param>
|
|
|
|
/// <returns>Whether the <typeparamref name="TModel"/> exists.</returns>
|
|
|
|
bool IsAvailableLocally(TModel model);
|
2019-06-12 01:12:57 +08:00
|
|
|
}
|
|
|
|
}
|