diff --git a/include/setcpu.h b/include/setcpu.h index b6f2928..fa3b1aa 100644 --- a/include/setcpu.h +++ b/include/setcpu.h @@ -3,27 +3,27 @@ /* this function's Incoming arguments are a pointer to the CPU class "CPU *pCPU" and the new mainclock speed */ -void setCPUmainclock(CPU *pCPU, string mkey, string mmainclock) { +void setCPUmainclock(CPU *pCPU, std::string mkey, std::string mmainclock) { pCPU->HardwareSpecs[mkey] = mmainclock; } -void setCPUboostclock(CPU *pCPU, string mkey, string mboostclock) { +void setCPUboostclock(CPU *pCPU, std::string mkey, std::string mboostclock) { pCPU->HardwareSpecs[mkey] = mboostclock; } -void setCPUarch(CPU *pCPU, string mkey, std::string march) { +void setCPUarch(CPU *pCPU, std::string mkey, std::string march) { pCPU->HardwareSpecs[mkey] = march; } -void setCPUbits(CPU *pCPU, string mkey, int mbits) { +void setCPUbits(CPU *pCPU, std::string mkey, int mbits) { pCPU->HardwareSpecs[mkey] = mbits; } -void setCPUcores(CPU *pCPU, string mkey, int mcores) { +void setCPUcores(CPU *pCPU, std::string mkey, int mcores) { pCPU->HardwareSpecs[mkey] = mcores; } -void setCPUthreads(CPU *pCPU, string mkey, int mthreads) { +void setCPUthreads(CPU *pCPU, std::string mkey, int mthreads) { pCPU->HardwareSpecs[mkey] = mthreads; // create an IF catch to set threads cores * 2 as a fall back } diff --git a/include/sethardware.h b/include/sethardware.h index 8c5ac1b..9f229f5 100644 --- a/include/sethardware.h +++ b/include/sethardware.h @@ -3,7 +3,7 @@ /* 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) { +void setHardwaremanufacturer(Hardware *pHardware, std::string mmanufacturer) { // cout << "Coming from the setHardwaremanufacturer function in setHardware" << endl; pHardware->manufacturer = mmanufacturer; @@ -14,11 +14,11 @@ void setHardwarereleasedyear(Hardware *pHardware, int mreleasedyear) { pHardware->releasedyear = mreleasedyear; } -void setHardwaremodel(Hardware *pHardware, string mmodel) { +void setHardwaremodel(Hardware *pHardware, std::string mmodel) { pHardware->model = mmodel; } -void Hardwaredictadd(CPU *pHardware, string mkey, string mvalue) { +void Hardwaredictadd(CPU *pHardware, std::string mkey, std::string mvalue) { // cout << "The incoming key/value is: " << mkey << "/" << mvalue << endl; // cout << "\nThe current manufacturer is: " << pHardware->HardwareSpecs[mkey] << endl; diff --git a/lists/cpu.h b/lists/cpu.h index d419abd..6a921f5 100644 --- a/lists/cpu.h +++ b/lists/cpu.h @@ -1,39 +1,28 @@ #pragma once -#include "hardware.h" +#include #include -using namespace std; -string line; -string& line2 = line; +/* +* THIS PORTION OF CODE WAS DONATED BY szaszmango from brodie's server! +*/ -void genCPUclasses() { - fstream cpuList; - cpuList.open("lists/cpulist", ios::in); +// This magic returns a vector which contain all the objects created using the CPU class +std::vector genCPUclasses() { + std::vector resultCpuList; + std::ifstream cpuList{"lists/cpulist", std::ifstream::in}; if(cpuList.is_open()) { - cout << "File opened\n"; + std::cout << "File opened\n"; } - else { cout << "Failed to open file!" << endl; } + else { std::cout << "Failed to open file!\n"; } - while (getline(cpuList, line)) { - // cout << line << endl; - line2 = line; - CPU *line = new CPU; - // BEGIN troubleshoot - line->HardwareSpecs["model"] = line2; - // cout << line->HardwareSpecs["model"] << endl; - cout << line2 << endl; + std::string line; + while (std::getline(cpuList, line)) { + CPU cpu; + cpu.HardwareSpecs["model"] = line; + resultCpuList.push_back(std::move(cpu)); + std::cout << "Loaded CPU: " << line << std::endl; } - cpuList.close(); -}; - -// CPU *A7800x3d = new CPU; -// CPU *Ii75820k = new CPU; - - -// std::string a7800x3d(std::string man){ - // CPU A7800x3d; - // A7800x3d.manufacturer = "AMD"; - // return man; -// }; + return resultCpuList; +} diff --git a/lists/cpu.h.help b/lists/cpu.h.help deleted file mode 100644 index 412b564..0000000 --- a/lists/cpu.h.help +++ /dev/null @@ -1,19 +0,0 @@ -std::vector genCPUclasses() { - std::vector resultCpuList; - std::ifstream cpuList{"lists/cpulist", std::ifstream::in}; - - if(cpuList.is_open()) { - std::cout << "File opened\n"; - } - else { std::cout << "Failed to open file!\n"; } - - while (std::getline(cpuList, line)) { - CPU cpu; - cpu.HardwareSpecs["model"] = line; - resultCpuList.push_back(std::move(cpu)); - // cout << cpu.HardwareSpecs["model"] << '\n'; - cout << line << endl; - } - - return resultCpuList; -} diff --git a/lists/hardware.h b/lists/hardware.h index 3bc2a1a..bb27284 100644 --- a/lists/hardware.h +++ b/lists/hardware.h @@ -5,7 +5,7 @@ // #define class struct // Uncomment this line to switch all the classes to structs -using namespace std; +// using namespace std; class Hardware { @@ -70,6 +70,6 @@ class CPU: public Hardware { class GPU: public Hardware { public: - map GPUSpecs; + std::map GPUSpecs; // GPUSpecs["Ram"] = GPU { "Ram", "12Gb" }; }; diff --git a/main.cpp b/main.cpp index 3e9bead..265fe3c 100644 --- a/main.cpp +++ b/main.cpp @@ -7,13 +7,19 @@ int main() { - using namespace std; - - genCPUclasses(); + // using namespace std; + int counter= 0; + auto cpus = genCPUclasses(); + for (CPU& cpu: cpus) { + // cpus[counter].HardwareSpecs["model"] = "value"; + std::cout << cpu.HardwareSpecs["model"] << " loaded at index: " << counter << std::endl; + counter++; + } + //Testing the new dictionaries // cout << "Lets try the setCPU function!\n"; - // cout << "A7800x3d main clock speed is: " << line->HardwareSpecs["mainclock"] << endl; + // std::cout << "A7800x3d main clock speed is: " << A7800x3d->HardwareSpecs["mainclock"] << std::endl; // setHardwaremanufacturer(A7800x3d, "AMD"); // setCPUcores(A7800x3d, "cores", 8); // setCPUthreads(A7800x3d, "threads", 16);