You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
50 lines
1.2 KiB
C#
50 lines
1.2 KiB
C#
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using EpicGames.Core;
|
|
using EpicGames.Serialization;
|
|
|
|
namespace EpicGames.Perforce.Managed
|
|
{
|
|
/// <summary>
|
|
/// Interface for
|
|
/// </summary>
|
|
public abstract class StreamTreeReader
|
|
{
|
|
/// <summary>
|
|
/// Reads a node of the tree
|
|
/// </summary>
|
|
/// <param name="ref"></param>
|
|
/// <returns></returns>
|
|
public abstract Task<StreamTree> ReadAsync(StreamTreeRef @ref);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Implements a <see cref="StreamTreeReader"/> using a contiguous block of memory
|
|
/// </summary>
|
|
public class StreamTreeMemoryReader : StreamTreeReader
|
|
{
|
|
/// <summary>
|
|
/// Map from hash to encoded CB tree object
|
|
/// </summary>
|
|
readonly Dictionary<IoHash, CbObject> _hashToTree;
|
|
|
|
/// <summary>
|
|
/// Constructor
|
|
/// </summary>
|
|
/// <param name="Root"></param>
|
|
/// <param name="hashToTree"></param>
|
|
public StreamTreeMemoryReader(Dictionary<IoHash, CbObject> hashToTree)
|
|
{
|
|
_hashToTree = hashToTree;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public override Task<StreamTree> ReadAsync(StreamTreeRef @ref)
|
|
{
|
|
return Task.FromResult(new StreamTree(@ref.Path, _hashToTree[@ref.Hash]));
|
|
}
|
|
}
|
|
}
|