aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Horizon/Sdk/Sf/Cmif/ServiceObjectHolder.cs
blob: 6e87e3405f1a5a4ef41745cc2fd441c2781b418f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using Ryujinx.Horizon.Common;
using System;

namespace Ryujinx.Horizon.Sdk.Sf.Cmif
{
    class ServiceObjectHolder
    {
        public IServiceObject ServiceObject { get; }

        private readonly ServiceDispatchMeta _dispatchMeta;

        public ServiceObjectHolder(ServiceObjectHolder objectHolder)
        {
            ServiceObject = objectHolder.ServiceObject;
            _dispatchMeta = objectHolder._dispatchMeta;
        }

        public ServiceObjectHolder(IServiceObject serviceImpl)
        {
            ServiceObject = serviceImpl;
            _dispatchMeta = new ServiceDispatchMeta(ServiceDispatchTable.Create(serviceImpl));
        }

        public ServiceObjectHolder Clone()
        {
            return new ServiceObjectHolder(this);
        }

        public Result ProcessMessage(ref ServiceDispatchContext context, ReadOnlySpan<byte> inRawData)
        {
            return _dispatchMeta.DispatchTable.ProcessMessage(ref context, inRawData);
        }
    }
}