ln.objects/ng/storage/IStorage.cs

65 lines
2.6 KiB
C#

using System;
using System.Collections.Generic;
using ln.objects.catalog;
namespace ln.types.odb.ng.storage
{
public interface IStorage : IDisposable
{
bool Open();
void Close();
bool IsOpen { get; }
/// <summary>
/// Load the specified documentID.
/// </summary>
/// <returns>The loaded Document.</returns>
/// <param name="documentID">Document identifier.</param>
/// <remarks>
/// Non caching storage will return the latest version of the document with each call.
/// Caching storage will return the same Document instance with each call, as long as the document stayed in the cache.
/// <b>No refreshing is done if a cached instance is returned!</b>
/// </remarks>
Document Load(Guid documentID);
/// <summary>
/// Refresh the specified document.
/// </summary>
/// <returns><see langword="true"/> if the document was refreshed successfully</returns>
/// <param name="document">Document to be refreshed. Must have been loaded by a call to <c>Load(..)</c> of the same <c>IStorage</c> instance</param>
/// <remarks>will reload the document from storage and apply the loaded state to this instance.
/// If <paramref name="document"/> references an instance that has not been returned by a call to <c>Load(..)</c> (e.g. by using <c>Clone()</c>), internal caches may not be affected by the refresh.
/// </remarks>
bool Refresh(Document document);
/// <summary>
/// Save the specified document.
/// </summary>
/// <param name="document">Document to store</param>
/// <remarks>Non caching storage will store the Document with its full state.
/// Caching storage, e.g. SessionStorage, may only store changes to storage. Please refer to class specific documentation.
/// </remarks>
void Save(Document document);
/// <summary>
/// Delete the specified documentID from storage.
/// </summary>
/// <param name="documentID">Document identifier</param>
/// <remarks>Will remove the Document identified by <para>documentID</para> from storage.
/// </remarks>
void Delete(Guid documentID);
IDisposable Lock();
bool Contains(Guid documentID);
IEnumerable<Guid> GetDocumentIDs();
IEnumerable<Guid> GetDocumentIDs(string path,Predicate<ODBEntity> predicate);
DateTime GetStorageTimestamp(Guid documentID);
void EnsureIndex(params string[] path);
bool IsCaching { get; }
}
}