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.

53 lines
2.1 KiB

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