Overte C++ Documentation
PlatformInstance.h
1 //
2 // Created by Amer Cerkic 05/02/2019
3 // Copyright 2019 High Fidelity, Inc.
4 //
5 // Distributed under the Apache License, Version 2.0.
6 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
7 //
8 
9 #ifndef hifi_PlatformInstance_h
10 #define hifi_PlatformInstance_h
11 
12 #include <vector>
13 #include <nlohmann/json.hpp>
14 
15 namespace platform {
16  using json = nlohmann::json;
17 
18 class Instance {
19 public:
20  const int NOT_FOUND { -1 };
21 
22  bool virtual enumeratePlatform();
23 
24  int getNumCPUs() { return (int)_cpus.size(); }
25  json getCPU(int index);
26  int getMasterCPU() const { return _masterCPU; }
27 
28  int getNumGPUs() { return (int)_gpus.size(); }
29  json getGPU(int index);
30  int getMasterGPU() const { return _masterGPU; }
31 
32  int getNumDisplays() { return (int)_displays.size(); }
33  json getDisplay(int index);
34  int getMasterDisplay() const { return _masterDisplay; }
35 
36  json getMemory() { return _memory; }
37 
38  json getComputer() { return _computer; }
39 
40  json getAll();
41 
42  void virtual enumerateCpus()=0;
43  void virtual enumerateGpusAndDisplays()=0;
44  void virtual enumerateNics();
45  void virtual enumerateMemory() = 0;
46  void virtual enumerateComputer()=0;
47  virtual void enumerateGraphicsApis();
48 
49  virtual ~Instance();
50 
51  static json listAllKeys();
52 
53  // Helper function to filter the vendor name out of the description of a GPU
54  static const char* findGPUVendorInDescription(const std::string& description);
55 
56 protected:
57  std::vector<json> _cpus;
58  std::vector<json> _gpus;
59  std::vector<json> _displays;
60  std::vector<json> _nics;
61  json _graphicsApis;
62  json _memory;
63  json _computer;
64 
65  int _masterCPU{ -1 };
66  int _masterGPU{ -1 };
67  int _masterDisplay{ -1 };
68 
69  // Traverse the cpus, gpus and displays to update the "master" index in each domain
70  void updateMasterIndices();
71 
72 };
73 
74 } // namespace platform
75 
76 #endif // hifi_platformInstance_h