KiCad PCB EDA Suite
UTILITY_REGISTRY Class Reference

A class to handle the registration of utility programs. More...

#include <utility_registry.h>

Public Types

using PLUGIN_MAP = std::map< std::string, KI_TEST::UTILITY_PROGRAM >
 

Static Public Member Functions

static bool Register (const KI_TEST::UTILITY_PROGRAM &aProgInfo)
 Register a utility program factory function against an ID string. More...
 
static PLUGIN_MAPGetInfoMap ()
 Accessor for the static registry map. More...
 

Detailed Description

A class to handle the registration of utility programs.

Definition at line 15 of file utility_registry.h.

Member Typedef Documentation

◆ PLUGIN_MAP

Definition at line 18 of file utility_registry.h.

Member Function Documentation

◆ GetInfoMap()

static PLUGIN_MAP& UTILITY_REGISTRY::GetInfoMap ( )
inlinestatic

Accessor for the static registry map.

This is needed to prevent the Static Init Order Fiasco that might occur if we just accessed a static class member.

Definition at line 48 of file utility_registry.h.

49  {
50  static PLUGIN_MAP info_map;
51  return info_map;
52  }
std::map< std::string, KI_TEST::UTILITY_PROGRAM > PLUGIN_MAP

Referenced by KI_TEST::COMBINED_UTILITY::findSubUtility(), Register(), and KI_TEST::COMBINED_UTILITY::showSubUtilityList().

◆ Register()

static bool UTILITY_REGISTRY::Register ( const KI_TEST::UTILITY_PROGRAM aProgInfo)
inlinestatic

Register a utility program factory function against an ID string.

This will be used to create the required utility program if needed.

Parameters
aNamethe name of the utility program
aFactorythe factory function that will construct the plugin
Returns
true if registered OK

Definition at line 29 of file utility_registry.h.

30  {
31  PLUGIN_MAP& map = GetInfoMap();
32 
33  if( map.find( aProgInfo.m_name ) == map.end() )
34  {
35  map[aProgInfo.m_name] = aProgInfo;
36  return true;
37  }
38 
39  // Already exists in map
40  return false;
41  }
std::map< std::string, KI_TEST::UTILITY_PROGRAM > PLUGIN_MAP
std::string m_name
The name of the program (this is used to select one)
static PLUGIN_MAP & GetInfoMap()
Accessor for the static registry map.

References GetInfoMap(), and KI_TEST::UTILITY_PROGRAM::m_name.


The documentation for this class was generated from the following file: