Add get_comp_by_name_optional.
This commit is contained in:
parent
78020c4794
commit
23903a969d
|
@ -58,6 +58,14 @@ HWComponent* MachineBase::get_comp_by_name(std::string name) {
|
|||
}
|
||||
}
|
||||
|
||||
HWComponent* MachineBase::get_comp_by_name_optional(std::string name) {
|
||||
if (this->device_map.count(name)) {
|
||||
return this->device_map[name].get();
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
HWComponent* MachineBase::get_comp_by_type(HWCompType type) {
|
||||
std::string comp_name;
|
||||
bool found = false;
|
||||
|
|
|
@ -41,6 +41,7 @@ public:
|
|||
|
||||
void add_device(std::string name, std::unique_ptr<HWComponent> dev_obj);
|
||||
HWComponent* get_comp_by_name(std::string name);
|
||||
HWComponent* get_comp_by_name_optional(std::string name);
|
||||
HWComponent* get_comp_by_type(HWCompType type);
|
||||
int postinit_devices();
|
||||
|
||||
|
|
Loading…
Reference in New Issue