code snippet using vectors from brodie's discord - time to learn
vectors!
This commit is contained in:
parent
85d309413e
commit
63815adecc
29
lists/cpu.h
29
lists/cpu.h
@ -1,10 +1,35 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "hardware.h"
|
#include "hardware.h"
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
string line;
|
||||||
|
string& line2 = line;
|
||||||
|
|
||||||
|
void genCPUclasses() {
|
||||||
|
fstream cpuList;
|
||||||
|
cpuList.open("lists/cpulist", ios::in);
|
||||||
|
|
||||||
CPU *A7800x3d = new CPU;
|
if(cpuList.is_open()) {
|
||||||
CPU *Ii75820k = new CPU;
|
cout << "File opened\n";
|
||||||
|
}
|
||||||
|
else { cout << "Failed to open file!" << endl; }
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
cpuList.close();
|
||||||
|
};
|
||||||
|
|
||||||
|
// CPU *A7800x3d = new CPU;
|
||||||
|
// CPU *Ii75820k = new CPU;
|
||||||
|
|
||||||
|
|
||||||
// std::string a7800x3d(std::string man){
|
// std::string a7800x3d(std::string man){
|
||||||
|
|||||||
19
lists/cpu.h.help
Normal file
19
lists/cpu.h.help
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
std::vector<CPU> genCPUclasses() {
|
||||||
|
std::vector<CPU> 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;
|
||||||
|
}
|
||||||
5
lists/cpulist
Normal file
5
lists/cpulist
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
A7800x3d
|
||||||
|
A7900x3d
|
||||||
|
A7900x
|
||||||
|
A7950x
|
||||||
|
Ii75820k
|
||||||
38
main.cpp
38
main.cpp
@ -5,40 +5,24 @@
|
|||||||
#include "include/setcpu.h"
|
#include "include/setcpu.h"
|
||||||
#include "include/sethardware.h"
|
#include "include/sethardware.h"
|
||||||
|
|
||||||
void* ptr = &A7800x3d;
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
/* Error Checking
|
genCPUclasses();
|
||||||
cout << "Main pointer address for A7800x3d: " << &A7800x3d << endl;
|
|
||||||
cout << "A7800x3d pointer before the value set is :" << &A7800x3d->manufacturer << endl;
|
|
||||||
cout << "A7800x3d value before change is: " << A7800x3d->manufacturer << endl;
|
|
||||||
A7800x3d->manufacturer = "AMD";
|
|
||||||
cout << "A7800x3d manufacturer is: " << A7800x3d->manufacturer << endl;
|
|
||||||
cout << "A7800x3d pointer after the change to AMD is: " << &A7800x3d->manufacturer << endl;
|
|
||||||
*/
|
|
||||||
// A7800x3d->manufacturer = "AMD";
|
|
||||||
|
|
||||||
// Cat out both CPU's that have been created for sanity
|
//Testing the new dictionaries
|
||||||
// cout << "i75820k manufacturer is: " << Ii75820k->HardwareSpecs["manufacturer"] << endl;
|
// cout << "Lets try the setCPU function!\n";
|
||||||
// cout << "A7800x3d manufacturer is: " << A7800x3d->HardwareSpecs["manufacturer"] << endl;
|
// cout << "A7800x3d main clock speed is: " << line->HardwareSpecs["mainclock"] << endl;
|
||||||
|
// setHardwaremanufacturer(A7800x3d, "AMD");
|
||||||
cout << "Lets try the setCPU function!\n";
|
// setCPUcores(A7800x3d, "cores", 8);
|
||||||
cout << "A7800x3d main clock speed is: " << A7800x3d->HardwareSpecs["mainclock"] << endl;
|
// setCPUthreads(A7800x3d, "threads", 16);
|
||||||
setHardwaremanufacturer(A7800x3d, "AMD");
|
// setCPUmainclock(A7800x3d, "mainclock", "4.8 Ghz");
|
||||||
setCPUcores(A7800x3d, "cores", 8);
|
// setCPUboostclock(A7800x3d, "boostclock", "5.2 ghz");
|
||||||
setCPUthreads(A7800x3d, "threads", 16);
|
// cout << "\n\nA7800x3d new main/boost speed is: " << A7800x3d->HardwareSpecs["mainclock"] << "/" << A7800x3d->HardwareSpecs["boostclock"] << endl;
|
||||||
setCPUmainclock(A7800x3d, "mainclock", "4.8 Ghz");
|
|
||||||
setCPUboostclock(A7800x3d, "boostclock", "5.2 ghz");
|
|
||||||
cout << "\n\nA7800x3d new main/boost speed is: " << A7800x3d->HardwareSpecs["mainclock"] << "/" << A7800x3d->HardwareSpecs["boostclock"] << endl;
|
|
||||||
// cout << "A7800x3d manufacturer is: " << A7800x3d->HardwareSpecs["manufacturer"] << "\n\n\n";
|
// cout << "A7800x3d manufacturer is: " << A7800x3d->HardwareSpecs["manufacturer"] << "\n\n\n";
|
||||||
|
|
||||||
// Start of Hardware Dictionary Test
|
|
||||||
// Hardwaredictadd(A7800x3d, "manufacturer", "Ganome Himself");
|
|
||||||
// cout << "Parent Hardware() dict manufacturer is: " << A7800x3d->HardwareSpecs["manufacturer"];
|
|
||||||
|
|
||||||
system("sleep 3s");
|
system("sleep 1s");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user