24 #ifndef PROPERTY_MGR_H 25 #define PROPERTY_MGR_H 27 #include <wx/string.h> 30 #include <unordered_map> 122 return const_cast<void*>(
TypeCast( (
const void*) aSource, aBase, aTarget ) );
211 std::vector<std::reference_wrapper<CLASS_DESC>>
m_bases;
249 #define REGISTER_TYPE(x) PROPERTY_MANAGER::Instance().RegisterType(TYPE_HASH(x), TYPE_NAME(x)) void Rebuild()
Rebuild the list of all registered properties.
const PROPERTY_LIST & GetProperties(TYPE_ID aType) const
Return all properties for a specific type.
std::vector< TYPE_ID > GetMatchingClasses(PROPERTY_BASE *aProperty)
static PROPERTY_MANAGER & Instance()
PROPERTY_SET m_replaced
Recreates the list of properties.
void SetUnits(EDA_UNITS aUnits)
void * TypeCast(void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
std::vector< PROPERTY_BASE * > properties
size_t TYPE_ID
Unique type identifier.
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Cast a type to another type.
bool m_dirty
Flag indicating that the list of properties needs to be rebuild (RebuildProperties())
const TYPE_ID m_id
Types after which this type inherits.
std::map< TYPE_ID, std::unique_ptr< TYPE_CAST_BASE > > m_typeCasts
All properties (both unique to the type and inherited)
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Return a property for a specific type.
std::unordered_map< TYPE_ID, CLASS_DESC > m_classes
void collectPropsRecur(PROPERTY_LIST &aResult, PROPERTY_SET &aReplaced) const
void rebuild()
Traverses the class inheritance hierarchy bottom-to-top, gathering all properties available to a type...
Returns metadata for a specific type.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
const wxString & ResolveType(TYPE_ID aType) const
Return name of a type.
CLASS_DESC & getClass(TYPE_ID aTypeId)
CLASS_DESC(TYPE_ID aId)
Unique type identifier (obtained using TYPE_HASH)
void RegisterType(TYPE_ID aType, const wxString &aName)
Associate a name with a type.
std::unordered_map< TYPE_ID, wxString > m_classNames
Map of all available types.
bool IsOfType(TYPE_ID aDerived, TYPE_ID aBase) const
Return true if aDerived is inherited from aBase.
std::vector< CLASS_INFO > CLASSES_INFO
std::vector< std::reference_wrapper< CLASS_DESC > > m_bases
Properties unique to this type (i.e. not inherited)
std::vector< PROPERTY_BASE * > PROPERTY_LIST
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
void AddProperty(PROPERTY_BASE *aProperty)
Register a property.
PROPERTY_MANAGER()
Structure holding type meta-data.
void ReplaceProperty(size_t aBase, const wxString &aName, PROPERTY_BASE *aNew)
Replace an existing property for a specific type.
CLASSES_INFO GetAllClasses()
Provide class metadata.Helper macro to map type hashes to names.
std::set< std::pair< size_t, wxString > > PROPERTY_SET
EDA_UNITS GetUnits() const
std::map< wxString, std::unique_ptr< PROPERTY_BASE > > m_ownProperties
Type converters available for this type.
std::vector< PROPERTY_BASE * > m_allProperties
Replaced properties (TYPE_ID / name)