fixed a bunch of pr comments

This commit is contained in:
amerhifi 2019-05-13 16:38:11 -07:00
parent 9652d412ac
commit 804d171102
7 changed files with 54 additions and 63 deletions

View file

@ -41,7 +41,7 @@ static void getCpuId( uint32_t* p, uint32_t ax )
}
void MACOSInstance::enumerateCpu() {
json cpu = {};
json cpu = {};
uint32_t cpuInfo[4]={0,0,0,0};
char CPUBrandString[16];
char CPUModelString[16];
@ -75,10 +75,8 @@ unsigned int MACOSInstance::getNumLogicalCores() {
}
void MACOSInstance::enumerateGpu() {
GPUIdent* ident = GPUIdent::getInstance();
json gpu = {};
GPUIdent* ident = GPUIdent::getInstance();
json gpu = {};
gpu["name"] = ident->getName().toUtf8().constData();
gpu["memory"] = ident->getMemory();
gpu["driver"] = ident->getDriver().toUtf8().constData();
@ -88,11 +86,11 @@ void MACOSInstance::enumerateGpu() {
}
void MACOSInstance::enumerateRam() {
json ram = {};
json ram = {};
#ifdef Q_OS_MAC
long pages = sysconf(_SC_PHYS_PAGES);
long pages = sysconf(_SC_PHYS_PAGES);
long page_size = sysconf(_SC_PAGE_SIZE);
ram["totalMem"] = pages * page_size;;
#endif
_memory.push_back(ram);

View file

@ -28,8 +28,7 @@ bool WINInstance::enumeratePlatform() {
}
void WINInstance::enumerateCpu() {
json cpu = {};
json cpu = {};
#ifdef Q_OS_WINDOWS
int CPUInfo[4] = { -1 };
@ -59,6 +58,7 @@ void WINInstance::enumerateCpu() {
cpu["clockSpeed"] = CPUClockString;
cpu["numCores"] = getNumLogicalCores();
#endif
_cpu.push_back(cpu);
}
@ -68,9 +68,9 @@ unsigned int WINInstance::getNumLogicalCores() {
void WINInstance::enumerateGpu() {
GPUIdent* ident = GPUIdent::getInstance();
GPUIdent* ident = GPUIdent::getInstance();
json gpu = {};
json gpu = {};
gpu["name"] = ident->getName().toUtf8().constData();
gpu["memory"] = ident->getMemory();
gpu["driver"] = ident->getDriver().toUtf8().constData();
@ -80,7 +80,7 @@ void WINInstance::enumerateGpu() {
}
void WINInstance::enumerateRam() {
json ram = {};
json ram = {};
#ifdef Q_OS_WINDOWS
MEMORYSTATUSEX statex;
statex.dwLength = sizeof(statex);
@ -88,5 +88,6 @@ void WINInstance::enumerateRam() {
int totalRam = statex.ullTotalPhys / 1024 / 1024;
ram["totalMem"] = totalRam;
#endif
_memory.push_back(ram);
}

View file

@ -23,7 +23,6 @@ namespace platform {
void enumerateRam();
void enumerateGpu();
};
} // namespace platform
#endif //hifi_winplatform_h

View file

@ -42,10 +42,10 @@ void platform::destroy() {
delete _instance;
}
json Instance::getCPU(int index) {
json Instance::getCPU(int index) {
assert(index <(int) _cpu.size());
if (index >= (int)_cpu.size())
return NULL;
return json();
return _cpu.at(index);
}
@ -55,74 +55,74 @@ void platform::destroy() {
json Instance::getMemory(int index) {
assert(index <(int) _memory.size());
if(index >= (int)_memory.size())
return NULL;
return json();
return _memory.at(index);
}
json Instance::getGPU(int index) {
assert(index <(int) _gpu.size());
if (index >=(int) _gpu.size())
return NULL;
if (index >=(int) _gpu.size())
return json();
return _gpu.at(index);
}
json Instance::getDisplay(int index) {
assert(index <(int) _display.size());
assert(index <(int) _display.size());
if (index >=(int) _display.size())
return NULL;
if (index >=(int) _display.size())
return json();
return _display.at(index);
return _display.at(index);
}
Instance::~Instance() {
if (_cpu.size() > 0) {
if (_cpu.size() > 0) {
_cpu.clear();
}
_cpu.clear();
}
if (_memory.size() > 0) {
_memory.clear();
}
if (_memory.size() > 0) {
_memory.clear();
}
if (_gpu.size() > 0) {
if (_gpu.size() > 0) {
_gpu.clear();
}
}
if (_display.size() > 0) {
_display.clear();
}
if (_display.size() > 0) {
_display.clear();
}
}
bool platform::enumeratePlatform() {
return _instance->enumeratePlatform();
}
int platform::getNumProcessor() {
return _instance->getNumCPU();
int platform::getNumCPU() {
return _instance->getNumCPU();
}
json platform::getProcessor(int index) {
json platform::getCPU(int index) {
return _instance->getCPU(index);
}
int platform::getNumGraphics() {
return _instance->getNumGPU();
int platform::getNumGPU() {
return _instance->getNumGPU();
}
json platform::getGraphics(int index) {
return _instance->getGPU(index);
json platform::getGPU(int index) {
return _instance->getGPU(index);
}
int platform::getNumDisplay() {
return _instance->getNumDisplay();
return _instance->getNumDisplay();
}
json platform::getDisplay(int index) {
return _instance->getDisplay(index);
return _instance->getDisplay(index);
}
int platform::getNumMemory() {
@ -132,6 +132,3 @@ int platform::getNumMemory() {
json platform::getMemory(int index) {
return _instance->getMemory(index);
}

View file

@ -37,7 +37,7 @@ protected:
std::vector<json> _cpu;
std::vector<json> _memory;
std::vector<json> _gpu;
std::vector<json> _display;
std::vector<json> _display;
};
//Platform level functions
@ -46,16 +46,15 @@ void destroy();
bool enumeratePlatform();
int getNumProcessor();
json getProcessor(int index);
int getNumCPU();
json getCPU(int index);
int getNumGraphics();
json getGraphics(int index);
int getNumGPU();
json getGPU(int index);
int getNumDisplay();
json getDisplay(int index);
int getNumMemory();
json getMemory(int index);

View file

@ -251,15 +251,12 @@ GPUIdent* GPUIdent::ensureQuery(const QString& vendor, const QString& renderer)
*/
if (!validAdapterList.empty()) {
for (auto outy = adapterToOutputs.begin(); outy != adapterToOutputs.end(); outy++) {
for (auto outy = adapterToOutputs.begin(); outy != adapterToOutputs.end(); outy++) {
AdapterEntry entry = *outy;
entry.first.first.Description;
for (auto test = entry.second.begin(); test != entry.second.end(); test++) {
nlohmann::json output = {};
for (auto test = entry.second.begin(); test != entry.second.end(); ++test) {
nlohmann::json output = {};
output["description"] = entry.first.first.Description;
output["deviceName"]= test->DeviceName;
output["coordinatesleft"] = test->DesktopCoordinates.left;
@ -267,8 +264,8 @@ GPUIdent* GPUIdent::ensureQuery(const QString& vendor, const QString& renderer)
output["coordinatestop"] = test->DesktopCoordinates.top;
output["coordinatesbottom"] = test->DesktopCoordinates.bottom;
_output.push_back(output);
}
}
}
}
auto& adapterEntry = adapterToOutputs[validAdapterList.front()];

View file

@ -28,7 +28,7 @@ public:
QString getName() { return _name; }
QString getDriver() { return _driver; }
bool isValid() { return _isValid; }
std::vector<nlohmann::json> getOutput() { return _output; }
const std::vector<nlohmann::json>& getOutput() { return _output; }
// E.g., GPUIdent::getInstance()->getMemory();
static GPUIdent* getInstance(const QString& vendor = "", const QString& renderer = "") { return _instance.ensureQuery(vendor, renderer); }