View Javadoc
1   /*
2    * Copyright 2020-2022 The OSHI Project Contributors
3    * SPDX-License-Identifier: MIT
4    */
5   package oshi.hardware.platform.unix.aix;
6   
7   import static oshi.util.Memoizer.defaultExpiration;
8   import static oshi.util.Memoizer.memoize;
9   
10  import java.util.List;
11  import java.util.function.Supplier;
12  
13  import com.sun.jna.platform.unix.aix.Perfstat.perfstat_disk_t;
14  
15  import oshi.annotation.concurrent.ThreadSafe;
16  import oshi.driver.unix.aix.Lscfg;
17  import oshi.driver.unix.aix.perfstat.PerfstatDisk;
18  import oshi.hardware.CentralProcessor;
19  import oshi.hardware.ComputerSystem;
20  import oshi.hardware.Display;
21  import oshi.hardware.GlobalMemory;
22  import oshi.hardware.GraphicsCard;
23  import oshi.hardware.HWDiskStore;
24  import oshi.hardware.NetworkIF;
25  import oshi.hardware.PowerSource;
26  import oshi.hardware.Sensors;
27  import oshi.hardware.SoundCard;
28  import oshi.hardware.UsbDevice;
29  import oshi.hardware.common.AbstractHardwareAbstractionLayer;
30  import oshi.hardware.platform.unix.UnixDisplay;
31  
32  /**
33   * AIXHardwareAbstractionLayer class.
34   */
35  @ThreadSafe
36  public final class AixHardwareAbstractionLayer extends AbstractHardwareAbstractionLayer {
37  
38      // Memoized hardware listing
39      private final Supplier<List<String>> lscfg = memoize(Lscfg::queryAllDevices, defaultExpiration());
40      // Memoized disk stats to pass to disk object(s)
41      private final Supplier<perfstat_disk_t[]> diskStats = memoize(PerfstatDisk::queryDiskStats, defaultExpiration());
42  
43      @Override
44      public ComputerSystem createComputerSystem() {
45          return new AixComputerSystem(lscfg);
46      }
47  
48      @Override
49      public GlobalMemory createMemory() {
50          return new AixGlobalMemory(lscfg);
51      }
52  
53      @Override
54      public CentralProcessor createProcessor() {
55          return new AixCentralProcessor();
56      }
57  
58      @Override
59      public Sensors createSensors() {
60          return new AixSensors(lscfg);
61      }
62  
63      @Override
64      public List<PowerSource> getPowerSources() {
65          return AixPowerSource.getPowerSources();
66      }
67  
68      @Override
69      public List<HWDiskStore> getDiskStores() {
70          return AixHWDiskStore.getDisks(diskStats);
71      }
72  
73      @Override
74      public List<Display> getDisplays() {
75          return UnixDisplay.getDisplays();
76      }
77  
78      @Override
79      public List<NetworkIF> getNetworkIFs(boolean includeLocalInterfaces) {
80          return AixNetworkIF.getNetworks(includeLocalInterfaces);
81      }
82  
83      @Override
84      public List<UsbDevice> getUsbDevices(boolean tree) {
85          return AixUsbDevice.getUsbDevices(tree, lscfg);
86      }
87  
88      @Override
89      public List<SoundCard> getSoundCards() {
90          return AixSoundCard.getSoundCards(lscfg);
91      }
92  
93      @Override
94      public List<GraphicsCard> getGraphicsCards() {
95          return AixGraphicsCard.getGraphicsCards(lscfg);
96      }
97  }