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

  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading;
  7. using System.Threading.Tasks;
  8. namespace IPA.Config
  9. {
  10. /// <summary>
  11. /// A storage for a config structure.
  12. /// </summary>
  13. public interface IConfigStore
  14. {
  15. /// <summary>
  16. /// A synchronization object for the save thread to wait on for changes.
  17. /// It should be signaled whenever the internal state of the object is changed.
  18. /// The writer will never signal this handle.
  19. /// </summary>
  20. WaitHandle SyncObject { get; }
  21. /// <summary>
  22. /// A synchronization object for the load thread and accessors to maintain safe synchronization.
  23. /// Any readers should take a read lock with <see cref="ReaderWriterLockSlim.EnterReadLock()"/> or
  24. /// <see cref="ReaderWriterLockSlim.EnterUpgradeableReadLock()"/>, and any writers should take a
  25. /// write lock with <see cref="ReaderWriterLockSlim.EnterWriteLock()"/>.
  26. /// </summary>
  27. /// <remarks>
  28. /// Read and write are read and write to *this object*, not to the file on disk.
  29. /// </remarks>
  30. ReaderWriterLockSlim WriteSyncObject { get; }
  31. /// <summary>
  32. /// Writes the config structure stored by the current <see cref="IConfigStore"/> to the given
  33. /// <see cref="IConfigProvider"/>.
  34. /// </summary>
  35. /// <param name="provider">the provider to write to</param>
  36. void WriteTo(IConfigProvider provider);
  37. /// <summary>
  38. /// Reads the config structure from the given <see cref="IConfigProvider"/> into the current
  39. /// <see cref="IConfigStore"/>.
  40. /// </summary>
  41. /// <param name="provider"></param>
  42. void ReadFrom(IConfigProvider provider);
  43. }
  44. }