Skip to content

Commit

Permalink
📄doc comment updates
Browse files Browse the repository at this point in the history
  • Loading branch information
codeimpossible committed Aug 27, 2021
1 parent edcaa1a commit bbc56a6
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 2 deletions.
17 changes: 17 additions & 0 deletions src/Chonks/IRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,27 @@
public delegate void ItemRegistered<T>(T item);

public interface IRegistry<T> {
/// <summary>
/// Occurs when a new item is registered.
/// </summary>
event ItemRegistered<T> OnItemRegistered;

/// <summary>
/// Lists all the registered items.
/// </summary>
/// <returns></returns>
T[] List();

/// <summary>
/// Registers the specified instance.
/// </summary>
/// <param name="instance">The instance.</param>
void Register(T instance);

/// <summary>
/// Unregisters the specified instance.
/// </summary>
/// <param name="instance">The instance.</param>
void Unregister(T instance);
}
}
20 changes: 20 additions & 0 deletions src/Chonks/ISaveDepot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,28 @@

namespace Chonks {
public interface ISaveDepot {
/// <summary>
/// Lists the saves.
/// </summary>
/// <returns></returns>
SaveContainer[] ListSaves();

/// <summary>
/// Tries to load a save.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="chunks">The chunks.</param>
/// <param name="ex">The ex.</param>
/// <returns></returns>
bool TryLoadSave(string name, out SaveChunk[] chunks, out Exception ex);

/// <summary>
/// Tries to write a save.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="chunks">The chunks.</param>
/// <param name="ex">The ex.</param>
/// <returns></returns>
bool TryWriteSave(string name, SaveChunk[] chunks, out Exception ex);
}
}
17 changes: 17 additions & 0 deletions src/Chonks/ISaveInterpreter.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
namespace Chonks {
public interface ISaveInterpreter {
/// <summary>
/// Processes chunks from a save file.
/// </summary>
/// <param name="chunks">The chunks.</param>
void ProcessChunks(SaveChunk[] chunks);

/// <summary>
/// Applies any modifications made to the chunks.
/// </summary>
/// <param name="chunks">The chunks.</param>
/// <returns></returns>
SaveChunk[] ApplyModifications(SaveChunk[] chunks);

/// <summary>
/// Determines whether this instance is dirty.
/// </summary>
/// <returns>
/// <c>true</c> if this instance is dirty; otherwise, <c>false</c>.
/// </returns>
bool IsDirty();
}
}
13 changes: 13 additions & 0 deletions src/Chonks/ISaveManager.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
namespace Chonks {
public interface ISaveManager {
/// <summary>
/// Makes a new snapshot.
/// </summary>
void MakeSnapshot();

/// <summary>
/// Applies the most recently created snapshot to a container.
/// </summary>
/// <param name="container">The container.</param>
void ApplySnapshot(SaveContainer container);

/// <summary>
/// Loads a snapshot from a container.
/// </summary>
/// <param name="container">The container.</param>
void LoadSnapshot(SaveContainer container);
}
}
34 changes: 32 additions & 2 deletions src/Chonks/ISaveStore.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,44 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;

namespace Chonks {
[Serializable]
public class SaveState {
/// <summary>
/// Gets or sets the name of the chunk.
/// </summary>
/// <value>
/// The name of the chunk.
/// </value>
public string ChunkName { get; set; }

/// <summary>
/// Gets or sets the data.
/// </summary>
/// <value>
/// The data.
/// </value>
public object Data { get; set; }
}

public interface ISaveStore {
/// <summary>
/// Gets the store identifier.
/// </summary>
/// <returns></returns>
string GetStoreIdentifier();

/// <summary>
/// Gets the save states for each chunk.
/// </summary>
/// <returns></returns>
List<SaveState> GetSaveStates();
void LoadChunkData(string chunkName, ChunkDataSegment data);
/// <summary>
/// Loads the chunk data.
/// </summary>
/// <param name="chunkName">Name of the chunk.</param>
/// <param name="data">The data.</param>
/// <param name="onAllChunksLoadedCallback">The callback (if any) to call when all chunks have been loaded. Note: this is not called if the store is recieving chunk data outside of a snapshot creation.</param>
void LoadChunkData(string chunkName, ChunkDataSegment data, out Action onAllChunksLoadedCallback);
}
}
30 changes: 30 additions & 0 deletions src/Chonks/SaveChunk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,34 @@ namespace Chonks {

[Serializable]
public class SaveChunk {
/// <summary>
/// Gets or sets the identifier.
/// </summary>
/// <value>
/// The identifier.
/// </value>
public Guid Id { get; set; } = Guid.NewGuid();

/// <summary>
/// Gets or sets the name.
/// </summary>
/// <value>
/// The name.
/// </value>
public string Name { get; set; }

/// <summary>
/// Gets or sets the data.
/// </summary>
/// <value>
/// The data.
/// </value>
public Dictionary<string, string> Data { get; set; } = new Dictionary<string, string>();

/// <summary>
/// Initializes a new instance of the <see cref="SaveChunk"/> class.
/// </summary>
/// <param name="name">The name.</param>
public SaveChunk(string name = "") {
Name = name;
}
Expand All @@ -17,6 +41,12 @@ public class SaveChunk {
return $"{Id}-{Name}".GetHashCode();
}


/// <summary>
/// Adds the data to the chunk.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="data">The data.</param>
public void AddToChunk(string key, object data) {
var json = SerializationUtility.SerializeObject(data);
Data.Add(key, json);
Expand Down
20 changes: 20 additions & 0 deletions src/Chonks/SaveContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,28 @@

namespace Chonks {
public struct SaveContainer {
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <value>
/// The name.
/// </value>
public string Name { get; set; }

/// <summary>
/// Gets or sets the created at date.
/// </summary>
/// <value>
/// The created at.
/// </value>
public DateTime CreatedAt { get; set; }

/// <summary>
/// Gets or sets the last updated at date.
/// </summary>
/// <value>
/// The last updated at.
/// </value>
public DateTime LastUpdatedAt { get; set; }
}
}

0 comments on commit bbc56a6

Please sign in to comment.