aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Horizon/Sdk/Sf/Cmif/ServiceObjectHolder.cs
blob: 4dd435377395dc71ca655980a76970a76dcb3280 (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);
        }
    }
}