aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Kernel/KAutoObject.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.HLE/HOS/Kernel/KAutoObject.cs')
-rw-r--r--Ryujinx.HLE/HOS/Kernel/KAutoObject.cs42
1 files changed, 42 insertions, 0 deletions
diff --git a/Ryujinx.HLE/HOS/Kernel/KAutoObject.cs b/Ryujinx.HLE/HOS/Kernel/KAutoObject.cs
new file mode 100644
index 00000000..a91bf9a8
--- /dev/null
+++ b/Ryujinx.HLE/HOS/Kernel/KAutoObject.cs
@@ -0,0 +1,42 @@
+namespace Ryujinx.HLE.HOS.Kernel
+{
+ class KAutoObject
+ {
+ protected Horizon System;
+
+ public KAutoObject(Horizon System)
+ {
+ this.System = System;
+ }
+
+ public virtual KernelResult SetName(string Name)
+ {
+ if (!System.AutoObjectNames.TryAdd(Name, this))
+ {
+ return KernelResult.InvalidState;
+ }
+
+ return KernelResult.Success;
+ }
+
+ public static KernelResult RemoveName(Horizon System, string Name)
+ {
+ if (!System.AutoObjectNames.TryRemove(Name, out _))
+ {
+ return KernelResult.NotFound;
+ }
+
+ return KernelResult.Success;
+ }
+
+ public static KAutoObject FindNamedObject(Horizon System, string Name)
+ {
+ if (System.AutoObjectNames.TryGetValue(Name, out KAutoObject Obj))
+ {
+ return Obj;
+ }
+
+ return null;
+ }
+ }
+} \ No newline at end of file