1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-12-02 21:22:02 +00:00
Ryujinx/Ryujinx.HLE/HOS/Kernel/KAutoObject.cs

42 lines
992 B
C#
Raw Normal View History

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