Fixed the CPU class to work with a dictionary - also switched over all
the setCPU functions.
This commit is contained in:
parent
2149ec7092
commit
85d309413e
@ -3,29 +3,28 @@
|
|||||||
/* this function's Incoming arguments are a pointer to the CPU class
|
/* this function's Incoming arguments are a pointer to the CPU class
|
||||||
"CPU *pCPU" and the new mainclock speed
|
"CPU *pCPU" and the new mainclock speed
|
||||||
*/
|
*/
|
||||||
void setCPUclock(CPU *pCPU, float mmainclock, float mboostclock) {
|
void setCPUmainclock(CPU *pCPU, string mkey, string mmainclock) {
|
||||||
cout << "Coming from the setCPUclock function in setcpu.h" << endl;
|
pCPU->HardwareSpecs[mkey] = mmainclock;
|
||||||
|
|
||||||
pCPU->mainclock = mmainclock;
|
|
||||||
pCPU->boostclock = mboostclock;
|
|
||||||
cout << "Incoming main clock variable was: " << mmainclock << endl;
|
|
||||||
cout << "Leaving setCPUclock()\n\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCPUarch(CPU *pCPU, std::string march) {
|
void setCPUboostclock(CPU *pCPU, string mkey, string mboostclock) {
|
||||||
pCPU->architecture = march;
|
pCPU->HardwareSpecs[mkey] = mboostclock;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCPUbits(CPU *pCPU, int mbits) {
|
void setCPUarch(CPU *pCPU, string mkey, std::string march) {
|
||||||
pCPU->bits64 = mbits;
|
pCPU->HardwareSpecs[mkey] = march;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCPUcores(CPU *pCPU, int mcores) {
|
void setCPUbits(CPU *pCPU, string mkey, int mbits) {
|
||||||
pCPU->cores = mcores;
|
pCPU->HardwareSpecs[mkey] = mbits;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCPUthreads(CPU *pCPU, int mthreads) {
|
void setCPUcores(CPU *pCPU, string mkey, int mcores) {
|
||||||
pCPU->threads = mthreads;
|
pCPU->HardwareSpecs[mkey] = mcores;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setCPUthreads(CPU *pCPU, string mkey, int mthreads) {
|
||||||
|
pCPU->HardwareSpecs[mkey] = 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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,10 +4,10 @@
|
|||||||
"Hardware *pHardware" and the new mainclock speed
|
"Hardware *pHardware" and the new mainclock speed
|
||||||
*/
|
*/
|
||||||
void setHardwaremanufacturer(Hardware *pHardware, string mmanufacturer) {
|
void setHardwaremanufacturer(Hardware *pHardware, string mmanufacturer) {
|
||||||
cout << "Coming from the setHardwaremanufacturer function in setHardware" << endl;
|
// cout << "Coming from the setHardwaremanufacturer function in setHardware" << endl;
|
||||||
|
|
||||||
pHardware->manufacturer = mmanufacturer;
|
pHardware->manufacturer = mmanufacturer;
|
||||||
cout << "Leaving setHardwaremanufacturer()\n\n";
|
// cout << "Leaving setHardwaremanufacturer()\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void setHardwarereleasedyear(Hardware *pHardware, int mreleasedyear) {
|
void setHardwarereleasedyear(Hardware *pHardware, int mreleasedyear) {
|
||||||
@ -20,9 +20,9 @@ void setHardwaremodel(Hardware *pHardware, string mmodel) {
|
|||||||
|
|
||||||
void Hardwaredictadd(CPU *pHardware, string mkey, string mvalue) {
|
void Hardwaredictadd(CPU *pHardware, string mkey, string mvalue) {
|
||||||
|
|
||||||
cout << "The incoming key/value is: " << mkey << "/" << mvalue << endl;
|
// cout << "The incoming key/value is: " << mkey << "/" << mvalue << endl;
|
||||||
cout << "\nThe current manufacturer is: " << pHardware->HardwareSpecs[mkey] << endl;
|
// cout << "\nThe current manufacturer is: " << pHardware->HardwareSpecs[mkey] << endl;
|
||||||
pHardware->HardwareSpecs[mkey] = mvalue;
|
pHardware->HardwareSpecs[mkey] = mvalue;
|
||||||
cout << "The new manufacturer is: " << pHardware->HardwareSpecs[mkey];
|
// cout << "The new manufacturer is: " << pHardware->HardwareSpecs[mkey];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,14 +14,8 @@ class Hardware {
|
|||||||
std::string model;
|
std::string model;
|
||||||
int releasedyear;
|
int releasedyear;
|
||||||
|
|
||||||
std::map<std::string, std::string> HardwareSpecs = {
|
// example of how to set a dictionary item
|
||||||
{"manufacturer", "The Gnomes"},
|
// std::string myval = HardwareSpecs.at("manufacturer");
|
||||||
{"model", "Honey Bomb"},
|
|
||||||
{"ReleasedYear", "2025"},
|
|
||||||
};
|
|
||||||
|
|
||||||
std::string myval = HardwareSpecs.at("manufacturer");
|
|
||||||
// HardwareSpecs.at("manufacturer") = "tester";
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -33,61 +27,45 @@ class Mobo: public Hardware {
|
|||||||
int dualchannel; // This is an int so 1 = dualchannel and 2 = quad channel
|
int dualchannel; // This is an int so 1 = dualchannel and 2 = quad channel
|
||||||
int ramspeed;
|
int ramspeed;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
Mobo() {
|
|
||||||
manufacturer = "Forest Gnomes";
|
std::map<std::string, std::string> HardwareSpecs = {
|
||||||
model = "HoneyJar";
|
{"manufacturer", "The Gnomes part 2"},
|
||||||
releasedyear = 2025;
|
{"model", "Honey Bomb"},
|
||||||
pciegen = 4;
|
{"ReleasedYear", "2025"},
|
||||||
piceslots = 3;
|
{"pciegen", "4"},
|
||||||
dimmslots = 2;
|
{"pcieslots", "3"},
|
||||||
dualchannel = 1;
|
{"dimmslots", "2"},
|
||||||
ramspeed = 6000;
|
{"ramchannels", "2"},
|
||||||
comment = "If on AM5 platform - update BIOS before booting!";
|
{"ramspeed", "6000"},
|
||||||
|
{"comment", "If on AM5 platform - update BIOS before booting!"},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
class CPU: public Hardware {
|
class CPU: public Hardware {
|
||||||
public:
|
public:
|
||||||
bool bits64;
|
|
||||||
bool igpu;
|
|
||||||
int igpusize;
|
|
||||||
int cores;
|
|
||||||
int threads;
|
|
||||||
int l1cache;
|
|
||||||
int l2cache;
|
|
||||||
int l3cache;
|
|
||||||
int pcielanes;
|
|
||||||
int maxram;
|
|
||||||
float mainclock;
|
|
||||||
float boostclock;
|
|
||||||
std::string architecture;
|
|
||||||
std::string memoryrange;
|
|
||||||
std::string microcode;
|
|
||||||
std::string kerneldriver;
|
|
||||||
std::string comment; // This shoule be used to warn the user about updating BIOS on AM5 before booting
|
|
||||||
|
|
||||||
CPU() {
|
std::map<std::string, std::string> HardwareSpecs = {
|
||||||
manufacturer = "Forest Gnomes";
|
{"manufacturer", "The Gnomes part 2"},
|
||||||
model = "HoneyPot";
|
{"model", "Honey Bomb"},
|
||||||
releasedyear = 2025;
|
{"ReleasedYear", "2025"},
|
||||||
bits64 = true;
|
{"bits", "64"},
|
||||||
igpu = false;
|
{"igpu", "false"},
|
||||||
igpusize = 0;
|
{"igpusize", "N/A"},
|
||||||
cores = 4;
|
{"cores", "4"},
|
||||||
threads = 2;
|
{"threads", "8"},
|
||||||
l1cache = 32;
|
{"l1cache", "32Mb"},
|
||||||
l2cache = 32;
|
{"l2cache", "32Mb"},
|
||||||
l3cache = 32;
|
{"l3cache", "32Mb"},
|
||||||
pcielanes = 24;
|
{"pcielanes", "24"},
|
||||||
maxram = 128;
|
{"maxram", "256Gb"},
|
||||||
mainclock = 2;
|
{"mainclock", "3Ghz"},
|
||||||
boostclock = 2.2;
|
{"boostclock", "3.2Ghz"},
|
||||||
architecture = "x86_64";
|
{"architecture", "x86_64"},
|
||||||
memoryrange = "00:00";
|
{"memoryrange", "00:00 - set me!"},
|
||||||
microcode = "acorns";
|
{"microcode", "unchanged"},
|
||||||
kerneldriver = "Forest Gnome Special";
|
{"kerneldriver", "intel"},
|
||||||
comment = "";
|
{"comment", "If on AM5 platform - update BIOS before booting!"},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
class GPU: public Hardware {
|
class GPU: public Hardware {
|
||||||
|
|||||||
21
main.cpp
21
main.cpp
@ -22,21 +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 << "i75820k manufacturer is: " << Ii75820k->manufacturer << endl;
|
// cout << "i75820k manufacturer is: " << Ii75820k->HardwareSpecs["manufacturer"] << endl;
|
||||||
cout << "A7800x3d manufacturer is: " << A7800x3d->manufacturer << endl;
|
// cout << "A7800x3d manufacturer is: " << A7800x3d->HardwareSpecs["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->HardwareSpecs["mainclock"] << endl;
|
||||||
setHardwaremanufacturer(A7800x3d, "AMD");
|
setHardwaremanufacturer(A7800x3d, "AMD");
|
||||||
setCPUcores(A7800x3d, 8);
|
setCPUcores(A7800x3d, "cores", 8);
|
||||||
setCPUthreads(A7800x3d, 16);
|
setCPUthreads(A7800x3d, "threads", 16);
|
||||||
setCPUclock(A7800x3d, 4.8, 5.1); // clock is base, boost
|
setCPUmainclock(A7800x3d, "mainclock", "4.8 Ghz");
|
||||||
|
setCPUboostclock(A7800x3d, "boostclock", "5.2 ghz");
|
||||||
cout << "A7800x3d new main clock speed is: " << A7800x3d->mainclock << endl;
|
cout << "\n\nA7800x3d new main/boost speed is: " << A7800x3d->HardwareSpecs["mainclock"] << "/" << A7800x3d->HardwareSpecs["boostclock"] << endl;
|
||||||
cout << "A7800x3d manufacturer is: " << A7800x3d->manufacturer << "\n\n\n";
|
// cout << "A7800x3d manufacturer is: " << A7800x3d->HardwareSpecs["manufacturer"] << "\n\n\n";
|
||||||
|
|
||||||
// Start of Hardware Dictionary Test
|
// Start of Hardware Dictionary Test
|
||||||
// Hardwaredictadd(A7800x3d, "manufacturer", "Ganome Himself");
|
// Hardwaredictadd(A7800x3d, "manufacturer", "Ganome Himself");
|
||||||
|
// cout << "Parent Hardware() dict manufacturer is: " << A7800x3d->HardwareSpecs["manufacturer"];
|
||||||
|
|
||||||
system("sleep 3s");
|
system("sleep 3s");
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user