Started refactoring floating variables in the Classes into dictionaries

for easier indexing.  First example @ sethardwaremanufacturer() in
sethardware.h
This commit is contained in:
ganome 2025-01-29 10:18:17 -07:00
parent d31db70b79
commit 2149ec7092
Signed by untrusted user who does not match committer: Ganome
GPG Key ID: 944DE53336D81B83
4 changed files with 61 additions and 11 deletions

View File

@ -28,8 +28,4 @@ void setCPUthreads(CPU *pCPU, int mthreads) {
pCPU->threads = mthreads; pCPU->threads = mthreads;
// create an IF catch to set threads cores * 2 as a fall back // create an IF catch to set threads cores * 2 as a fall back
} }
void setCPUmanufacturer(CPU *pCPU, std::string mmanufacturer) {
pCPU->manufacturer = mmanufacturer;
}

28
include/sethardware.h Normal file
View File

@ -0,0 +1,28 @@
// void setCPU(){};
/* this function's Incoming arguments are a pointer to the Hardware class
"Hardware *pHardware" and the new mainclock speed
*/
void setHardwaremanufacturer(Hardware *pHardware, string mmanufacturer) {
cout << "Coming from the setHardwaremanufacturer function in setHardware" << endl;
pHardware->manufacturer = mmanufacturer;
cout << "Leaving setHardwaremanufacturer()\n\n";
}
void setHardwarereleasedyear(Hardware *pHardware, int mreleasedyear) {
pHardware->releasedyear = mreleasedyear;
}
void setHardwaremodel(Hardware *pHardware, string mmodel) {
pHardware->model = mmodel;
}
void Hardwaredictadd(CPU *pHardware, string mkey, string mvalue) {
cout << "The incoming key/value is: " << mkey << "/" << mvalue << endl;
cout << "\nThe current manufacturer is: " << pHardware->HardwareSpecs[mkey] << endl;
pHardware->HardwareSpecs[mkey] = mvalue;
cout << "The new manufacturer is: " << pHardware->HardwareSpecs[mkey];
}

View File

@ -1,5 +1,10 @@
#pragma once #pragma once
#include <map>
#include <string>
#include <list>
// #define class struct // Uncomment this line to switch all the classes to structs
using namespace std; using namespace std;
class Hardware { class Hardware {
@ -7,7 +12,17 @@ class Hardware {
public: public:
std::string manufacturer; std::string manufacturer;
std::string model; std::string model;
int ReleasedYear; int releasedyear;
std::map<std::string, std::string> HardwareSpecs = {
{"manufacturer", "The Gnomes"},
{"model", "Honey Bomb"},
{"ReleasedYear", "2025"},
};
std::string myval = HardwareSpecs.at("manufacturer");
// HardwareSpecs.at("manufacturer") = "tester";
}; };
class Mobo: public Hardware { class Mobo: public Hardware {
@ -21,7 +36,7 @@ class Mobo: public Hardware {
Mobo() { Mobo() {
manufacturer = "Forest Gnomes"; manufacturer = "Forest Gnomes";
model = "HoneyJar"; model = "HoneyJar";
ReleasedYear = 2025; releasedyear = 2025;
pciegen = 4; pciegen = 4;
piceslots = 3; piceslots = 3;
dimmslots = 2; dimmslots = 2;
@ -54,7 +69,7 @@ class CPU: public Hardware {
CPU() { CPU() {
manufacturer = "Forest Gnomes"; manufacturer = "Forest Gnomes";
model = "HoneyPot"; model = "HoneyPot";
ReleasedYear = 2025; releasedyear = 2025;
bits64 = true; bits64 = true;
igpu = false; igpu = false;
igpusize = 0; igpusize = 0;
@ -74,3 +89,9 @@ class CPU: public Hardware {
comment = ""; comment = "";
}; };
}; };
class GPU: public Hardware {
public:
map<std::string, GPU> GPUSpecs;
// GPUSpecs["Ram"] = GPU { "Ram", "12Gb" };
};

View File

@ -3,6 +3,7 @@
#include "lists/hardware.h" #include "lists/hardware.h"
#include "lists/cpu.h" #include "lists/cpu.h"
#include "include/setcpu.h" #include "include/setcpu.h"
#include "include/sethardware.h"
void* ptr = &A7800x3d; void* ptr = &A7800x3d;
@ -21,18 +22,22 @@ int main() {
// A7800x3d->manufacturer = "AMD"; // A7800x3d->manufacturer = "AMD";
// Cat out both CPU's that have been created for sanity // Cat out both CPU's that have been created for sanity
cout << "IIi75820k manufacturer is: " << Ii75820k->manufacturer << endl; cout << "i75820k manufacturer is: " << Ii75820k->manufacturer << endl;
cout << "A7800x3d manufacturer is: " << A7800x3d->manufacturer << endl; cout << "A7800x3d manufacturer is: " << A7800x3d->manufacturer << endl;
cout << "Lets try the setCPU function!\n"; cout << "Lets try the setCPU function!\n";
cout << "A7800x3d main clock speed is: " << A7800x3d->mainclock << endl; cout << "A7800x3d main clock speed is: " << A7800x3d->mainclock << endl;
setCPUmanufacturer(A7800x3d, "AMD"); setHardwaremanufacturer(A7800x3d, "AMD");
setCPUcores(A7800x3d, 8); setCPUcores(A7800x3d, 8);
setCPUthreads(A7800x3d, 16); setCPUthreads(A7800x3d, 16);
setCPUclock(A7800x3d, 4.8, 5.1); // clock is base, boost setCPUclock(A7800x3d, 4.8, 5.1); // clock is base, boost
cout << "A7800x3d new main clock speed is: " << A7800x3d->mainclock << endl; cout << "A7800x3d new main clock speed is: " << A7800x3d->mainclock << endl;
cout << "A7800x3d manufacturer is: " << A7800x3d->manufacturer << endl; cout << "A7800x3d manufacturer is: " << A7800x3d->manufacturer << "\n\n\n";
// Start of Hardware Dictionary Test
// Hardwaredictadd(A7800x3d, "manufacturer", "Ganome Himself");
system("sleep 3s"); system("sleep 3s");
return 0; return 0;
} }