37 return m_name == className;
42 return testClass->GetFullName() == className;
50 return wxT(
"<None>" );
88 m_noneClass = std::make_unique<COMPONENT_CLASS>( wxEmptyString );
95 if( classNames.size() == 0 )
101 auto getOrCreateClass = [
this](
const wxString& className )
106 m_classes.insert( std::move( existingClass ) );
110 std::unique_ptr<COMPONENT_CLASS> newClass =
111 std::make_unique<COMPONENT_CLASS>( className );
112 newClass->AddConstituentClass( newClass.get() );
113 m_classes[className] = std::move( newClass );
120 if( classNames.size() == 1 )
121 return getOrCreateClass( *classNames.begin() );
124 std::vector<wxString> sortedClassNames( classNames.begin(), classNames.end() );
126 std::sort( sortedClassNames.begin(), sortedClassNames.end(),
127 [](
const wxString& str1,
const wxString& str2 )
129 return str1.Cmp( str2 ) < 0;
146 auto constClassNode =
m_classesCache.extract( constClass->GetFullName() );
147 m_classes.insert( std::move( constClassNode ) );
154 std::unique_ptr<COMPONENT_CLASS> effClass = std::make_unique<COMPONENT_CLASS>( fullName );
156 for(
const wxString& className : sortedClassNames )
157 effClass->AddConstituentClass( getOrCreateClass( className ) );
183 std::vector<wxString> sortedClassNames( classNames.begin(), classNames.end() );
185 std::sort( sortedClassNames.begin(), sortedClassNames.end(),
186 [](
const wxString& str1,
const wxString& str2 )
188 return str1.Cmp( str2 ) < 0;
198 if( classNames.size() == 0 )
199 return wxEmptyString;
201 wxString fullName = classNames[0];
203 for( std::size_t i = 1; i < classNames.size(); ++i )
206 fullName += classNames[i];
std::unique_ptr< COMPONENT_CLASS > m_noneClass
The class to represent an unassigned component class.
std::unordered_map< wxString, std::unique_ptr< COMPONENT_CLASS > > m_classes
All individual component classes.
std::unordered_map< wxString, std::unique_ptr< COMPONENT_CLASS > > m_classesCache
Cache of all individual component classes (for netlist updating)
COMPONENT_CLASS_MANAGER()
void FinishNetlistUpdate()
Cleans up the manager after a board update Must be called after updating the PCB from the netlist.
static wxString GetFullClassNameForConstituents(std::unordered_set< wxString > &classNames)
Gets the full effective class name for the given set of constituent classes.
std::unordered_map< wxString, std::unique_ptr< COMPONENT_CLASS > > m_effectiveClassesCache
Cache of all generated effective component classes (for netlist updating)
std::unordered_map< wxString, std::unique_ptr< COMPONENT_CLASS > > m_effectiveClasses
Generated effective component classes.
void InitNetlistUpdate()
Prepare the manager for a board update Must be called prior to updating the PCB from the netlist.
COMPONENT_CLASS * GetEffectiveComponentClass(std::unordered_set< wxString > &classNames)
Gets an effective component class for the given constituent class names.
void AddConstituentClass(COMPONENT_CLASS *componentClass)
Adds a constituent component class to an effective component class.
bool ContainsClassName(const wxString &className) const
Determines if this (effective) component class contains a specific sub-class.
std::vector< COMPONENT_CLASS * > m_constituentClasses
The COMPONENT_CLASS objects contributing to this complete component class.
const std::vector< COMPONENT_CLASS * > & GetConstituentClasses() const
Fetches a vector of the constituent classes for this (effective) class.
wxString m_name
The full name of the component class.
wxString GetName() const
Fetches the display name of this component class.
bool IsEmpty() const
Determines if this (effective) component class is empty (i.e. no classes defined)