moved all hard coded json keys to platform::jsonkeys namespace and file

This commit is contained in:
amerhifi 2019-05-13 17:45:57 -07:00
parent 95e3eede5f
commit 830f3dc976
4 changed files with 52 additions and 20 deletions

View file

@ -7,7 +7,7 @@
//
#include "MACOSPlatform.h"
#include "platformJsonKeys.h"
#include <thread>
#include <GPUIdent.h>
#include <string>
@ -55,10 +55,10 @@ void MACOSInstance::enumerateCpu() {
}
}
cpu["brand"] = CPUBrandString;
cpu["model"] = CPUModelString;
cpu["clockSpeed"] = CPUClockString;
cpu["numCores"] = std::thread::hardware_concurrency();
cpu[jsonKeys::cpuBrand] = CPUBrandString;
cpu[jsonKeys::cpuModel] = CPUModelString;
cpu[jsonKeys::cpuClockSpeed] = CPUClockString;
cpu[jsonKeys::cpuNumCores] = std::thread::hardware_concurrency();
_cpu.push_back(cpu);
}
@ -66,9 +66,9 @@ void MACOSInstance::enumerateCpu() {
void MACOSInstance::enumerateGpu() {
GPUIdent* ident = GPUIdent::getInstance();
json gpu = {};
gpu["name"] = ident->getName().toUtf8().constData();
gpu["memory"] = ident->getMemory();
gpu["driver"] = ident->getDriver().toUtf8().constData();
gpu[jsonKeys::gpuName] = ident->getName().toUtf8().constData();
gpu[jsonKeys::gpuMemory] = ident->getMemory();
gpu[jsonKeys::gpuDriver] = ident->getDriver().toUtf8().constData();
_gpu.push_back(gpu);
_display = ident->getOutput();
@ -80,7 +80,7 @@ void MACOSInstance::enumerateMemory() {
#ifdef Q_OS_MAC
long pages = sysconf(_SC_PHYS_PAGES);
long page_size = sysconf(_SC_PAGE_SIZE);
ram["totalMem"] = pages * page_size;;
ram[jsonKeys::totalMemory] = pages * page_size;;
#endif
_memory.push_back(ram);
}

View file

@ -7,7 +7,7 @@
//
#include "WINPlatform.h"
#include "platformJsonKeys.h"
#ifdef Q_OS_WINDOWS
#include <intrin.h>
#include <Windows.h>
@ -22,7 +22,7 @@ using namespace platform;
void WINInstance::enumerateCpu() {
json cpu = {};
#ifdef Q_OS_WINDOWS
int CPUInfo[4] = { -1 };
unsigned nExIds;
@ -46,10 +46,10 @@ void WINInstance::enumerateCpu() {
}
}
cpu["brand"] = CPUBrandString;
cpu["model"] = CPUModelString;
cpu["clockSpeed"] = CPUClockString;
cpu["numCores"] = std::thread::hardware_concurrency();
cpu[jsonKeys::cpuBrand] = CPUBrandString;
cpu[jsonKeys::cpuModel] = CPUModelString;
cpu[jsonKeys::cpuClockSpeed] = CPUClockString;
cpu[jsonKeys::cpuNumCores] = std::thread::hardware_concurrency();
#endif
_cpu.push_back(cpu);
@ -60,9 +60,9 @@ void WINInstance::enumerateGpu() {
GPUIdent* ident = GPUIdent::getInstance();
json gpu = {};
gpu["name"] = ident->getName().toUtf8().constData();
gpu["memory"] = ident->getMemory();
gpu["driver"] = ident->getDriver().toUtf8().constData();
gpu[jsonKeys::gpuName] = ident->getName().toUtf8().constData();
gpu[jsonKeys::gpuMemory] = ident->getMemory();
gpu[jsonKeys::gpuDriver] = ident->getDriver().toUtf8().constData();
_gpu.push_back(gpu);
_display = ident->getOutput();
@ -76,7 +76,7 @@ void WINInstance::enumerateMemory() {
statex.dwLength = sizeof(statex);
GlobalMemoryStatusEx(&statex);
int totalRam = statex.ullTotalPhys / 1024 / 1024;
ram["totalMem"] = totalRam;
ram[jsonKeys::totalMemory] = totalRam;
#endif
_memory.push_back(ram);
}

View file

@ -46,4 +46,4 @@ protected:
} // namespace platform
#endif // hifi_platform_h
#endif // hifi_platformInstance_h

View file

@ -0,0 +1,32 @@
//
// Created by Amer Cerkic 05/02/2019
// Copyright 2019 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hifi_PlatformJsonKeys_h
#define hifi_PlatformJsonKeys_h
namespace platform {
namespace jsonKeys{
static const char* cpuBrand= "cpuBrand";
static const char* cpuModel = "cpuModel";
static const char* cpuClockSpeed = "clockSpeed";
static const char* cpuNumCores = "numCores";
static const char* gpuName = "GpuName";
static const char* gpuMemory = "gpuMemory";
static const char* gpuDriver = "gpuDriver";
static const char* totalMemory = "totalMem";
static const char* displayDescription = "description";
static const char* displayName = "deviceName";
static const char* displayCoordsLeft = "coordinatesleft";
static const char* displayCoordsRight = "coordinatesright";
static const char* displayCoordsTop = "coordinatestop";
static const char* displayCoordsBottom = "coordinatesbottom";
}
} // namespace platform
#endif