Store<T> Class
Namespace: Stride.Core.IOAssembly: Stride.Core.Serialization.dll
A store that will be incrementally saved on the HDD. Thread-safe and process-safe.
public abstract class Store<T> : IDisposable where T : new()
Type Parameters
Name | Description |
---|---|
T | The type of elements in the store. |
Name | Description | |
---|---|---|
Constructors | ||
Store(Stream) | ||
Fields | ||
lockObject | ||
stream | ||
transaction | ||
Properties | ||
AutoLoadNewValues | Gets or sets a flag specifying if a Save should also load new values that happened in between. |
|
UseTransaction | Gets or sets a flag specifying if the index map changes should be kept aside instead of being committed immediately. |
|
Methods | ||
AddLoaded(T) | Adds a value that has already been saved in the store (saved state). |
|
AddUnsaved(T, Int32) | Adds a value that has not yet been saved in the store (pending state). |
|
AddValue(T) | Adds a value to the store. |
|
AddValues(IEnumerable<T>) | Adds multiple values to the store |
|
BuildContext(Stream) | ||
Dispose() | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. Waits for pending operation to finish, if any. Note that it does not write pending transaction if Save() has not been called before. |
|
GetPendingItems(Int32) | Gets the list of pending items for a given transaction index. |
|
LoadNewValues() | Refreshes URL to ObjectId mapping from the latest results in the index file. |
|
ReadEntries(Stream) | ||
RemoveUnsaved(T, Int32) | Removes a value that has not yet been saved (pending state). |
|
RemoveUnsaved(IEnumerable<T>, Int32) | Removes values that have not yet been saved (pending state). |
|
Reset() | Resets the store to an empty state. |
|
ResetInternal() | Resets the store to an empty state, to be implemented by subclasses if necessary. |
|
Save() | Saves the newly added mapping (only necessary when UseTransaction is set to true). |
|
WriteEntry(Stream, T) |
Constructors
Store(Stream)
protected Store(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream |
Fields
lockObject
protected object lockObject
Field Value
Type | Description |
---|---|
System.Object |
stream
protected Stream stream
Field Value
Type | Description |
---|---|
System.IO.Stream |
transaction
protected int transaction
Field Value
Type | Description |
---|---|
System.Int32 |
Properties
AutoLoadNewValues
Gets or sets a flag specifying if a Save should also load new values that happened in between.
public bool AutoLoadNewValues { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
UseTransaction
Gets or sets a flag specifying if the index map changes should be kept aside instead of being committed immediately.
public bool UseTransaction { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
AddLoaded(T)
Adds a value that has already been saved in the store (saved state).
protected abstract void AddLoaded(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item. |
AddUnsaved(T, Int32)
Adds a value that has not yet been saved in the store (pending state).
protected abstract void AddUnsaved(T item, int transaction)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item. |
System.Int32 | transaction | The transaction index. |
AddValue(T)
Adds a value to the store.
public void AddValue(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item. |
AddValues(IEnumerable<T>)
Adds multiple values to the store
public void AddValues(IEnumerable<T> values)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | values | The values. |
BuildContext(Stream)
protected virtual object BuildContext(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream |
Returns
Type | Description |
---|---|
System.Object |
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. Waits for pending operation to finish, if any. Note that it does not write pending transaction if Save() has not been called before.
public void Dispose()
GetPendingItems(Int32)
Gets the list of pending items for a given transaction index.
protected abstract IEnumerable<T> GetPendingItems(int transaction)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | transaction | The transaction index. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T> |
LoadNewValues()
Refreshes URL to ObjectId mapping from the latest results in the index file.
public bool LoadNewValues()
Returns
Type | Description |
---|---|
System.Boolean | True on success. |
ReadEntries(Stream)
protected virtual List<T> ReadEntries(Stream localStream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | localStream |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<T> |
RemoveUnsaved(T, Int32)
Removes a value that has not yet been saved (pending state).
protected abstract void RemoveUnsaved(T item, int transaction)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item. |
System.Int32 | transaction | The transaction index. |
RemoveUnsaved(IEnumerable<T>, Int32)
Removes values that have not yet been saved (pending state).
protected virtual void RemoveUnsaved(IEnumerable<T> items, int transaction)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | items | The items. |
System.Int32 | transaction | The transaction index. |
Reset()
Resets the store to an empty state.
public void Reset()
ResetInternal()
Resets the store to an empty state, to be implemented by subclasses if necessary.
protected virtual void ResetInternal()
Save()
Saves the newly added mapping (only necessary when UseTransaction is set to true).
public void Save()
WriteEntry(Stream, T)
protected virtual void WriteEntry(Stream stream, T value)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | |
T | value |