You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

49 lines
1.8 KiB

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace IPA.Config
{
/// <summary>
/// A storage for a config structure.
/// </summary>
public interface IConfigStore
{
/// <summary>
/// A synchronization object for the save thread to wait on for changes.
/// It should be signaled whenever the internal state of the object is changed.
/// The writer will never signal this handle.
/// </summary>
WaitHandle SyncObject { get; }
/// <summary>
/// A synchronization object for the load thread and accessors to maintain safe synchronization.
/// Any readers should take a read lock with <see cref="ReaderWriterLockSlim.EnterReadLock()"/> or
/// <see cref="ReaderWriterLockSlim.EnterUpgradeableReadLock()"/>, and any writers should take a
/// write lock with <see cref="ReaderWriterLockSlim.EnterWriteLock()"/>.
/// </summary>
/// <remarks>
/// Read and write are read and write to *this object*, not to the file on disk.
/// </remarks>
ReaderWriterLockSlim WriteSyncObject { get; }
/// <summary>
/// Writes the config structure stored by the current <see cref="IConfigStore"/> to the given
/// <see cref="IConfigProvider"/>.
/// </summary>
/// <param name="provider">the provider to write to</param>
void WriteTo(IConfigProvider provider);
/// <summary>
/// Reads the config structure from the given <see cref="IConfigProvider"/> into the current
/// <see cref="IConfigStore"/>.
/// </summary>
/// <param name="provider"></param>
void ReadFrom(IConfigProvider provider);
}
}