1 //
2 // Copyright (c) 2010-2024 Antmicro
3 // Copyright (c) 2011-2015 Realtime Embedded
4 //
5 // This file is licensed under the MIT License.
6 // Full license text is available in 'licenses/MIT.txt'.
7 //
8 using Antmicro.Renode.Debugging;
9 using Antmicro.Renode.Peripherals;
10 
11 namespace Antmicro.Renode.Core
12 {
13     public class PeripheralsChangedEventArgs
14     {
15         // This can't be a public constructor cause the arguments are the same as the protected
16         // constructor and adding a fake argument to make it possible seems... fake.
17         //
18         // Constructing `PeripheralsChangedEventArgs` with `PeripheralChangeType.Addition` isn't
19         // allowed. It makes `PeripheralsAddedEventArgs`, which includes `IRegistrationPoint`,
20         // always used for addition.
Create(IPeripheral peripheral, PeripheralChangeType operation)21         public static PeripheralsChangedEventArgs Create(IPeripheral peripheral, PeripheralChangeType operation)
22         {
23             DebugHelper.Assert(operation != PeripheralChangeType.Addition);
24             return new PeripheralsChangedEventArgs(peripheral, operation);
25         }
26 
27         public IPeripheral Peripheral { get; private set; }
28         public PeripheralChangeType Operation { get; private set; }
29 
PeripheralsChangedEventArgs(IPeripheral peripheral, PeripheralChangeType operation)30         protected PeripheralsChangedEventArgs(IPeripheral peripheral, PeripheralChangeType operation)
31         {
32             Peripheral = peripheral;
33             Operation = operation;
34         }
35 
36         public enum PeripheralChangeType
37         {
38             Addition,
39             Removal,
40             Moved,
41             CompleteRemoval,
42             NameChanged
43         }
44     }
45 }
46