2026-03-24 18:03:01 -04:00
|
|
|
using System;
|
2026-04-05 01:36:32 -04:00
|
|
|
using SabreTools.Metadata.Filter;
|
2026-03-24 18:03:01 -04:00
|
|
|
|
|
|
|
|
namespace SabreTools.Metadata.DatItems
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Base class for all items included in a set that are backed by an internal model
|
|
|
|
|
/// </summary>
|
2026-04-05 02:24:05 -04:00
|
|
|
public abstract class DatItem<T> : DatItem, ICloneable
|
2026-04-05 01:36:32 -04:00
|
|
|
where T : Data.Models.Metadata.DatItem, new()
|
2026-03-24 18:03:01 -04:00
|
|
|
{
|
2026-04-05 01:36:32 -04:00
|
|
|
#region Private Fields
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Internal model
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected T _internal;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2026-03-24 18:03:01 -04:00
|
|
|
#region Constructors
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Create a default, empty object
|
|
|
|
|
/// </summary>
|
|
|
|
|
public DatItem()
|
|
|
|
|
{
|
2026-03-26 23:46:20 -04:00
|
|
|
_internal = new T();
|
2026-03-24 18:03:01 -04:00
|
|
|
|
|
|
|
|
SetName(string.Empty);
|
2026-04-02 16:23:16 -04:00
|
|
|
Machine = new Machine();
|
2026-03-24 18:03:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Create an object from the internal model
|
|
|
|
|
/// </summary>
|
|
|
|
|
public DatItem(T item)
|
|
|
|
|
{
|
|
|
|
|
_internal = item;
|
|
|
|
|
|
2026-04-02 16:23:16 -04:00
|
|
|
Machine = new Machine();
|
2026-03-24 18:03:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Cloning Methods
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Get a clone of the current internal model
|
|
|
|
|
/// </summary>
|
2026-04-04 13:11:10 -04:00
|
|
|
public abstract T GetInternalClone();
|
2026-03-24 18:03:01 -04:00
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2026-04-05 01:36:32 -04:00
|
|
|
#region Manipulation
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
public override bool PassesFilter(FilterRunner filterRunner)
|
|
|
|
|
{
|
|
|
|
|
if (Machine is not null && !Machine.PassesFilter(filterRunner))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return filterRunner.Run(_internal);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
public override bool PassesFilterDB(FilterRunner filterRunner)
|
|
|
|
|
=> filterRunner.Run(_internal);
|
|
|
|
|
|
|
|
|
|
#endregion
|
2026-03-24 18:03:01 -04:00
|
|
|
}
|
|
|
|
|
}
|