Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions SerialPrograms/Source/Controllers/ControllerDescriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ namespace PokemonAutomation{
//
// Here we store a map of all controller types in the program.
//
std::map<ControllerInterface, std::unique_ptr<InterfaceType>> ALL_CONTROLLER_INTERFACES;
static std::map<ControllerInterface, std::unique_ptr<InterfaceType>>& all_controller_interfaces(){
static std::map<ControllerInterface, std::unique_ptr<InterfaceType>> instance;
return instance;
}


void InterfaceType::register_factory(
ControllerInterface controller_interface,
std::unique_ptr<InterfaceType> factory
){
auto ret = ALL_CONTROLLER_INTERFACES.emplace(controller_interface, std::move(factory));
auto ret = all_controller_interfaces().emplace(controller_interface, std::move(factory));
if (!ret.second){
throw InternalProgramError(
nullptr, PA_CURRENT_FUNCTION,
Expand Down Expand Up @@ -76,7 +79,7 @@ void ControllerOption::load_json(const JsonValue& json){
break;
}

for (const auto& item : ALL_CONTROLLER_INTERFACES){
for (const auto& item : all_controller_interfaces()){
const JsonValue* params = obj->get_value(CONTROLLER_INTERFACE_STRINGS.get_string(item.first));
if (params == nullptr){
continue;
Expand Down