Ryujinx/Ryujinx.HLE/HOS/Kernel/KAutoObject.cs

42 lines
997 B
C#
Raw Normal View History

namespace Ryujinx.HLE.HOS.Kernel
{
class KAutoObject
{
protected Horizon System;
2018-12-01 21:01:59 +01:00
public KAutoObject(Horizon system)
{
2018-12-01 21:01:59 +01:00
this.System = system;
}
2018-12-01 21:01:59 +01:00
public virtual KernelResult SetName(string name)
{
2018-12-01 21:01:59 +01:00
if (!System.AutoObjectNames.TryAdd(name, this))
{
return KernelResult.InvalidState;
}
return KernelResult.Success;
}
2018-12-01 21:01:59 +01:00
public static KernelResult RemoveName(Horizon system, string name)
{
2018-12-01 21:01:59 +01:00
if (!system.AutoObjectNames.TryRemove(name, out _))
{
return KernelResult.NotFound;
}
return KernelResult.Success;
}
2018-12-01 21:01:59 +01:00
public static KAutoObject FindNamedObject(Horizon system, string name)
{
2018-12-01 21:01:59 +01:00
if (system.AutoObjectNames.TryGetValue(name, out KAutoObject obj))
{
2018-12-01 21:01:59 +01:00
return obj;
}
return null;
}
}
}