File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
SerialPrograms/Source/Controllers Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -21,14 +21,17 @@ namespace PokemonAutomation{
2121//
2222// Here we store a map of all controller types in the program.
2323//
24- std::map<ControllerInterface, std::unique_ptr<InterfaceType>> ALL_CONTROLLER_INTERFACES;
24+ static std::map<ControllerInterface, std::unique_ptr<InterfaceType>>& all_controller_interfaces (){
25+ static std::map<ControllerInterface, std::unique_ptr<InterfaceType>> instance;
26+ return instance;
27+ }
2528
2629
2730void InterfaceType::register_factory (
2831 ControllerInterface controller_interface,
2932 std::unique_ptr<InterfaceType> factory
3033){
31- auto ret = ALL_CONTROLLER_INTERFACES .emplace (controller_interface, std::move (factory));
34+ auto ret = all_controller_interfaces () .emplace (controller_interface, std::move (factory));
3235 if (!ret.second ){
3336 throw InternalProgramError (
3437 nullptr , PA_CURRENT_FUNCTION,
@@ -76,7 +79,7 @@ void ControllerOption::load_json(const JsonValue& json){
7679 break ;
7780 }
7881
79- for (const auto & item : ALL_CONTROLLER_INTERFACES ){
82+ for (const auto & item : all_controller_interfaces () ){
8083 const JsonValue* params = obj->get_value (CONTROLLER_INTERFACE_STRINGS.get_string (item.first ));
8184 if (params == nullptr ){
8285 continue ;
You can’t perform that action at this time.
0 commit comments