KiCad PCB EDA Suite
PROPERTY_MANAGER Class Reference

Provide class metadata.Helper macro to map type hashes to names. More...

#include <property_mgr.h>

Classes

struct  CLASS_DESC
 Returns metadata for a specific type. More...
 
struct  CLASS_INFO
 

Public Types

typedef std::vector< CLASS_INFOCLASSES_INFO
 

Public Member Functions

void RegisterType (TYPE_ID aType, const wxString &aName)
 Associate a name with a type. More...
 
const wxString & ResolveType (TYPE_ID aType) const
 Return name of a type. More...
 
PROPERTY_BASEGetProperty (TYPE_ID aType, const wxString &aProperty) const
 Return a property for a specific type. More...
 
const PROPERTY_LISTGetProperties (TYPE_ID aType) const
 Return all properties for a specific type. More...
 
const PROPERTY_DISPLAY_ORDERGetDisplayOrder (TYPE_ID aType) const
 
const std::vector< wxString > & GetGroupDisplayOrder (TYPE_ID aType) const
 
const void * TypeCast (const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
 Cast a type to another type. More...
 
void * TypeCast (void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
 
void AddProperty (PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
 Register a property. More...
 
void ReplaceProperty (size_t aBase, const wxString &aName, PROPERTY_BASE *aNew, const wxString &aGroup=wxEmptyString)
 Replace an existing property for a specific type. More...
 
void AddTypeCast (TYPE_CAST_BASE *aCast)
 Register a type converter. More...
 
void InheritsAfter (TYPE_ID aDerived, TYPE_ID aBase)
 Declare an inheritance relationship between types. More...
 
void Mask (TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName)
 Sets a base class property as masked in a derived class. More...
 
void OverrideAvailability (TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName, std::function< bool(INSPECTABLE *)> aFunc)
 Sets an override availability functor for a base class property of a given derived class. More...
 
bool IsAvailableFor (TYPE_ID aItemClass, PROPERTY_BASE *aProp, INSPECTABLE *aItem)
 Checks overriden availability and original availability of a property, returns false if the property is unavailable in either case. More...
 
bool IsOfType (TYPE_ID aDerived, TYPE_ID aBase) const
 Return true if aDerived is inherited from aBase. More...
 
EDA_UNITS GetUnits () const
 
void SetUnits (EDA_UNITS aUnits)
 
ORIGIN_TRANSFORMSGetTransforms () const
 
void SetTransforms (ORIGIN_TRANSFORMS *aTransforms)
 
void Rebuild ()
 Rebuild the list of all registered properties. More...
 
CLASSES_INFO GetAllClasses ()
 
std::vector< TYPE_IDGetMatchingClasses (PROPERTY_BASE *aProperty)
 

Static Public Member Functions

static PROPERTY_MANAGERInstance ()
 

Private Member Functions

 PROPERTY_MANAGER ()
 Structure holding type meta-data. More...
 
CLASS_DESCgetClass (TYPE_ID aTypeId)
 

Private Attributes

std::unordered_map< TYPE_ID, wxString > m_classNames
 Map of all available types. More...
 
std::unordered_map< TYPE_ID, CLASS_DESCm_classes
 
bool m_dirty
 Flag indicating that the list of properties needs to be rebuild (RebuildProperties()) More...
 
EDA_UNITS m_units
 
ORIGIN_TRANSFORMSm_originTransforms
 

Detailed Description

Provide class metadata.Helper macro to map type hashes to names.

Each class handled by PROPERTY_MANAGER needs to be described using AddProperty(), AddTypeCast() and InheritsAfter() methods.

Enum types use a dedicated property type (PROPERTY_ENUM), define its possible values with ENUM_MAP class, then describe the type using macros:

  • DECLARE_ENUM_TO_WXANY (in header files)
  • IMPLEMENT_ENUM_TO_WXANY (in source files)
  • ENUM_TO_WXANY (most often used; combines DECLARE and IMPLEMENT macros, if there is no need to share the description using header files)

Once all classes are described, the property list must be build using Rebuild() method.

Definition at line 73 of file property_mgr.h.

Member Typedef Documentation

◆ CLASSES_INFO

Definition at line 240 of file property_mgr.h.

Constructor & Destructor Documentation

◆ PROPERTY_MANAGER()

PROPERTY_MANAGER::PROPERTY_MANAGER ( )
inlineprivate

Structure holding type meta-data.

Definition at line 247 of file property_mgr.h.

Member Function Documentation

◆ AddProperty()

void PROPERTY_MANAGER::AddProperty ( PROPERTY_BASE aProperty,
const wxString &  aGroup = wxEmptyString 
)

Register a property.

Properties for a given item will be shown in the order they are added. If a group name is supplied, the group will be created if it does not yet exists. Groups will likewise be shown in the order they are added (so, groups first added by a base class will appear before those of a child class).

Parameters
aPropertyis the property to register.
aGroupis an optional grouping key for the property

Definition at line 133 of file property_mgr.cpp.

134{
135 const wxString& name = aProperty->Name();
136 TYPE_ID hash = aProperty->OwnerHash();
137 CLASS_DESC& classDesc = getClass( hash );
138 classDesc.m_ownProperties.emplace( name, aProperty );
139 classDesc.m_ownDisplayOrder.emplace_back( aProperty );
140
141 aProperty->SetGroup( aGroup );
142
143 if( !classDesc.m_groups.count( aGroup ) )
144 {
145 classDesc.m_groupDisplayOrder.emplace_back( aGroup );
146 classDesc.m_groups.insert( aGroup );
147 }
148
149 m_dirty = true;
150}
const char * name
Definition: DXF_plotter.cpp:56
void SetGroup(const wxString &aGroup)
Definition: property.h:285
const wxString & Name() const
Definition: property.h:198
virtual size_t OwnerHash() const =0
Return type-id of the Owner class.
bool m_dirty
Flag indicating that the list of properties needs to be rebuild (RebuildProperties())
Definition: property_mgr.h:319
CLASS_DESC & getClass(TYPE_ID aTypeId)
size_t TYPE_ID
Unique type identifier.
Definition: property_mgr.h:46

References getClass(), m_dirty, PROPERTY_MANAGER::CLASS_DESC::m_groupDisplayOrder, PROPERTY_MANAGER::CLASS_DESC::m_groups, PROPERTY_MANAGER::CLASS_DESC::m_ownDisplayOrder, PROPERTY_MANAGER::CLASS_DESC::m_ownProperties, name, PROPERTY_BASE::Name(), PROPERTY_BASE::OwnerHash(), and PROPERTY_BASE::SetGroup().

Referenced by BOARD_CONNECTED_ITEM_DESC::BOARD_CONNECTED_ITEM_DESC(), BOARD_ITEM_DESC::BOARD_ITEM_DESC(), CLASS_A_DESC::CLASS_A_DESC(), CLASS_B_DESC::CLASS_B_DESC(), CLASS_C_DESC::CLASS_C_DESC(), CLASS_D_DESC::CLASS_D_DESC(), DIMENSION_DESC::DIMENSION_DESC(), EDA_ITEM_DESC::EDA_ITEM_DESC(), EDA_SHAPE_DESC::EDA_SHAPE_DESC(), EDA_TEXT_DESC::EDA_TEXT_DESC(), FOOTPRINT_DESC::FOOTPRINT_DESC(), FP_SHAPE_DESC::FP_SHAPE_DESC(), FP_TEXT_DESC::FP_TEXT_DESC(), FP_TEXTBOX_DESC::FP_TEXTBOX_DESC(), PAD_DESC::PAD_DESC(), PCB_BITMAP_DESC::PCB_BITMAP_DESC(), PCB_TARGET_DESC::PCB_TARGET_DESC(), PCB_TEXT_DESC::PCB_TEXT_DESC(), ReplaceProperty(), TRACK_VIA_DESC::TRACK_VIA_DESC(), and ZONE_DESC::ZONE_DESC().

◆ AddTypeCast()

void PROPERTY_MANAGER::AddTypeCast ( TYPE_CAST_BASE aCast)

Register a type converter.

Required prior TypeCast() usage.

Parameters
aCastis the type converter to register.

Definition at line 162 of file property_mgr.cpp.

163{
164 TYPE_ID derivedHash = aCast->DerivedHash();
165 CLASS_DESC& classDesc = getClass( aCast->BaseHash() );
166 auto& typeCasts = classDesc.m_typeCasts;
167 wxASSERT_MSG( typeCasts.count( derivedHash ) == 0, "Such converter already exists" );
168 typeCasts.emplace( derivedHash, aCast );
169}
virtual size_t BaseHash() const =0
virtual size_t DerivedHash() const =0

References TYPE_CAST_BASE::BaseHash(), TYPE_CAST_BASE::DerivedHash(), getClass(), and PROPERTY_MANAGER::CLASS_DESC::m_typeCasts.

Referenced by CLASS_D_DESC::CLASS_D_DESC(), FOOTPRINT_DESC::FOOTPRINT_DESC(), FP_SHAPE_DESC::FP_SHAPE_DESC(), FP_TEXT_DESC::FP_TEXT_DESC(), FP_TEXTBOX_DESC::FP_TEXTBOX_DESC(), PCB_MARKER_DESC::PCB_MARKER_DESC(), PCB_SHAPE_DESC::PCB_SHAPE_DESC(), PCB_TEXT_DESC::PCB_TEXT_DESC(), and PCB_TEXTBOX_DESC::PCB_TEXTBOX_DESC().

◆ GetAllClasses()

PROPERTY_MANAGER::CLASSES_INFO PROPERTY_MANAGER::GetAllClasses ( )

Definition at line 375 of file property_mgr.cpp.

376{
377 CLASSES_INFO rv;
378
379 for( std::pair<const TYPE_ID, CLASS_DESC>& classEntry : m_classes )
380 {
381 CLASS_INFO info;
382
383 info.type = classEntry.first;
384 info.name = m_classNames[classEntry.first];
385
386 for( PROPERTY_BASE* prop : classEntry.second.m_allProperties )
387 info.properties.push_back( prop );
388
389 rv.push_back( info );
390 }
391
392 return rv;
393}
std::vector< CLASS_INFO > CLASSES_INFO
Definition: property_mgr.h:240
std::unordered_map< TYPE_ID, CLASS_DESC > m_classes
Definition: property_mgr.h:316
std::unordered_map< TYPE_ID, wxString > m_classNames
Map of all available types.
Definition: property_mgr.h:313

References info, m_classes, and m_classNames.

Referenced by PCB_EXPR_UCODE::CreateVarRef(), and PANEL_SETUP_RULES::onScintillaCharAdded().

◆ getClass()

PROPERTY_MANAGER::CLASS_DESC & PROPERTY_MANAGER::getClass ( TYPE_ID  aTypeId)
private

Definition at line 254 of file property_mgr.cpp.

255{
256 auto it = m_classes.find( aTypeId );
257
258 if( it == m_classes.end() )
259 tie( it, std::ignore ) = m_classes.emplace( aTypeId, CLASS_DESC( aTypeId ) );
260
261 return it->second;
262}

References m_classes.

Referenced by AddProperty(), AddTypeCast(), InheritsAfter(), IsAvailableFor(), Mask(), OverrideAvailability(), and ReplaceProperty().

◆ GetDisplayOrder()

const PROPERTY_DISPLAY_ORDER & PROPERTY_MANAGER::GetDisplayOrder ( TYPE_ID  aType) const

Definition at line 83 of file property_mgr.cpp.

84{
85 if( m_dirty )
86 const_cast<PROPERTY_MANAGER*>( this )->Rebuild();
87
88 static const PROPERTY_DISPLAY_ORDER empty;
89 auto it = m_classes.find( aType );
90
91 if( it == m_classes.end() )
92 return empty;
93
94 return it->second.m_displayOrder;
95}
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:74
void Rebuild()
Rebuild the list of all registered properties.
static bool empty(const wxTextEntryBase *aCtrl)
std::map< PROPERTY_BASE *, int > PROPERTY_DISPLAY_ORDER
Definition: property_mgr.h:57

References empty(), m_classes, m_dirty, and Rebuild().

Referenced by PROPERTIES_PANEL::rebuildProperties().

◆ GetGroupDisplayOrder()

const std::vector< wxString > & PROPERTY_MANAGER::GetGroupDisplayOrder ( TYPE_ID  aType) const

Definition at line 98 of file property_mgr.cpp.

99{
100 if( m_dirty )
101 const_cast<PROPERTY_MANAGER*>( this )->Rebuild();
102
103 static const std::vector<wxString> empty;
104 auto it = m_classes.find( aType );
105
106 if( it == m_classes.end() )
107 return empty;
108
109 return it->second.m_groupDisplayOrder;
110}

References empty(), m_classes, m_dirty, and Rebuild().

Referenced by PROPERTIES_PANEL::rebuildProperties().

◆ GetMatchingClasses()

std::vector< TYPE_ID > PROPERTY_MANAGER::GetMatchingClasses ( PROPERTY_BASE aProperty)

Definition at line 355 of file property_mgr.cpp.

356{
357 std::vector<TYPE_ID> ids;
358
359/*
360 for( auto& cls : m_classes )
361 {
362 CLASS_INFO info;
363
364 for( auto prop : cls.second.m_allProperties )
365 info.properties.push_back(prop);
366
367
368 }
369 */
370
371 return ids;
372}

◆ GetProperties()

const PROPERTY_LIST & PROPERTY_MANAGER::GetProperties ( TYPE_ID  aType) const

Return all properties for a specific type.

Parameters
aTypeis the type identifier (obtained using TYPE_HASH()).
Returns
Vector storing all properties of the requested type.

Definition at line 68 of file property_mgr.cpp.

69{
70 if( m_dirty )
71 const_cast<PROPERTY_MANAGER*>( this )->Rebuild();
72
73 static const PROPERTY_LIST empty;
74 auto it = m_classes.find( aType );
75
76 if( it == m_classes.end() )
77 return empty;
78
79 return it->second.m_allProperties;
80}
std::vector< PROPERTY_BASE * > PROPERTY_LIST
Definition: property_mgr.h:48

References empty(), m_classes, m_dirty, and Rebuild().

Referenced by PANEL_SETUP_RULES::onScintillaCharAdded(), and PROPERTIES_PANEL::rebuildProperties().

◆ GetProperty()

PROPERTY_BASE * PROPERTY_MANAGER::GetProperty ( TYPE_ID  aType,
const wxString &  aProperty 
) const

Return a property for a specific type.

Parameters
aTypeis the type identifier (obtained using TYPE_HASH()).
aPropertyis the property name used during class registration.
Returns
Requested property or null pointer if requested property does not exist.

Definition at line 46 of file property_mgr.cpp.

47{
48 if( m_dirty )
49 const_cast<PROPERTY_MANAGER*>( this )->Rebuild();
50
51 auto it = m_classes.find( aType );
52
53 if( it == m_classes.end() )
54 return nullptr;
55
56 const CLASS_DESC& classDesc = it->second;
57
58 for( PROPERTY_BASE* property : classDesc.m_allProperties )
59 {
60 if( !aProperty.CmpNoCase( property->Name() ) )
61 return property;
62 }
63
64 return nullptr;
65}

References PROPERTY_MANAGER::CLASS_DESC::m_allProperties, m_classes, m_dirty, PROPERTY_BASE::Name(), and Rebuild().

Referenced by PCB_EXPR_UCODE::CreateVarRef(), INSPECTABLE::Get(), INSPECTABLE::Set(), PCB_PROPERTIES_PANEL::updateLists(), PCB_PROPERTIES_PANEL::updatePropertyValues(), and PCB_PROPERTIES_PANEL::valueChanged().

◆ GetTransforms()

ORIGIN_TRANSFORMS * PROPERTY_MANAGER::GetTransforms ( ) const
inline

Definition at line 224 of file property_mgr.h.

224{ return m_originTransforms; }
ORIGIN_TRANSFORMS * m_originTransforms
Definition: property_mgr.h:323

References m_originTransforms.

Referenced by PGPROPERTY_DISTANCE::DistanceToString().

◆ GetUnits()

EDA_UNITS PROPERTY_MANAGER::GetUnits ( ) const
inline

Definition at line 214 of file property_mgr.h.

215 {
216 return m_units;
217 }
EDA_UNITS m_units
Definition: property_mgr.h:321

References m_units.

◆ InheritsAfter()

void PROPERTY_MANAGER::InheritsAfter ( TYPE_ID  aDerived,
TYPE_ID  aBase 
)

Declare an inheritance relationship between types.

Parameters
aBaseis the base type identifier (obtained using TYPE_HASH()).
aDerivedis the derived type identifier (obtained using TYPE_HASH()).

Definition at line 172 of file property_mgr.cpp.

173{
174 wxASSERT_MSG( aDerived != aBase, "Class cannot inherit from itself" );
175
176 CLASS_DESC& derived = getClass( aDerived );
177 CLASS_DESC& base = getClass( aBase );
178 derived.m_bases.push_back( base );
179 m_dirty = true;
180
181 wxASSERT_MSG( derived.m_bases.size() == 1 || derived.m_typeCasts.count( aBase ) == 1,
182 "You need to add a TYPE_CAST for classes inheriting from multiple bases" );
183}

References getClass(), PROPERTY_MANAGER::CLASS_DESC::m_bases, m_dirty, and PROPERTY_MANAGER::CLASS_DESC::m_typeCasts.

Referenced by BOARD_CONNECTED_ITEM_DESC::BOARD_CONNECTED_ITEM_DESC(), BOARD_ITEM_DESC::BOARD_ITEM_DESC(), CLASS_B_DESC::CLASS_B_DESC(), CLASS_D_DESC::CLASS_D_DESC(), DIMENSION_DESC::DIMENSION_DESC(), FOOTPRINT_DESC::FOOTPRINT_DESC(), FP_SHAPE_DESC::FP_SHAPE_DESC(), FP_TEXT_DESC::FP_TEXT_DESC(), FP_TEXTBOX_DESC::FP_TEXTBOX_DESC(), PAD_DESC::PAD_DESC(), PCB_BITMAP_DESC::PCB_BITMAP_DESC(), PCB_MARKER_DESC::PCB_MARKER_DESC(), PCB_SHAPE_DESC::PCB_SHAPE_DESC(), PCB_TARGET_DESC::PCB_TARGET_DESC(), PCB_TEXT_DESC::PCB_TEXT_DESC(), PCB_TEXTBOX_DESC::PCB_TEXTBOX_DESC(), TRACK_VIA_DESC::TRACK_VIA_DESC(), and ZONE_DESC::ZONE_DESC().

◆ Instance()

◆ IsAvailableFor()

bool PROPERTY_MANAGER::IsAvailableFor ( TYPE_ID  aItemClass,
PROPERTY_BASE aProp,
INSPECTABLE aItem 
)

Checks overriden availability and original availability of a property, returns false if the property is unavailable in either case.

TODO: This isn't the cleanest API, consider how to merge with PROPERTY_BASE::Available

Definition at line 208 of file property_mgr.cpp.

210{
211 if( !aProp->Available( aItem ) )
212 return false;
213
214 CLASS_DESC& derived = getClass( aItemClass );
215
216 auto it = derived.m_availabilityOverrides.find( std::make_pair( aProp->BaseHash(),
217 aProp->Name() ) );
218
219 if( it != derived.m_availabilityOverrides.end() )
220 return it->second( aItem );
221
222 return true;
223}
virtual size_t BaseHash() const =0
Return type-id of the Base class.
bool Available(INSPECTABLE *aObject) const
Return true if aObject offers this PROPERTY.
Definition: property.h:233

References PROPERTY_BASE::Available(), PROPERTY_BASE::BaseHash(), getClass(), PROPERTY_MANAGER::CLASS_DESC::m_availabilityOverrides, and PROPERTY_BASE::Name().

Referenced by PROPERTIES_PANEL::extractValueAndWritability(), and PROPERTIES_PANEL::rebuildProperties().

◆ IsOfType()

bool PROPERTY_MANAGER::IsOfType ( TYPE_ID  aDerived,
TYPE_ID  aBase 
) const

Return true if aDerived is inherited from aBase.

Definition at line 226 of file property_mgr.cpp.

227{
228 if( aDerived == aBase )
229 return true;
230
231 auto derived = m_classes.find( aDerived );
232 wxCHECK( derived != m_classes.end(), false ); // missing class description
233
234 // traverse the hierarchy seeking for the base class
235 for( auto& base : derived->second.m_bases )
236 {
237 if( IsOfType( base.get().m_id, aBase ) )
238 return true;
239 }
240
241 return false;
242}
bool IsOfType(TYPE_ID aDerived, TYPE_ID aBase) const
Return true if aDerived is inherited from aBase.

References IsOfType(), and m_classes.

Referenced by PCB_EXPR_UCODE::CreateVarRef(), IsOfType(), and TypeCast().

◆ Mask()

void PROPERTY_MANAGER::Mask ( TYPE_ID  aDerived,
TYPE_ID  aBase,
const wxString &  aName 
)

Sets a base class property as masked in a derived class.

Masked properties are hidden from the list of editable properties for this class.

Parameters
aDerivedis the type to apply the mask for.
aBaseis the type that aName belongs to.
aNameis the name of a property on the base class.

Definition at line 186 of file property_mgr.cpp.

187{
188 wxASSERT_MSG( aDerived != aBase, "Class cannot mask from itself" );
189
190 CLASS_DESC& derived = getClass( aDerived );
191 derived.m_maskedBaseProperties.insert( std::make_pair( aBase, aName ) );
192 m_dirty = true;
193}

References getClass(), m_dirty, and PROPERTY_MANAGER::CLASS_DESC::m_maskedBaseProperties.

Referenced by PAD_DESC::PAD_DESC(), PCB_TEXTBOX_DESC::PCB_TEXTBOX_DESC(), and TRACK_VIA_DESC::TRACK_VIA_DESC().

◆ OverrideAvailability()

void PROPERTY_MANAGER::OverrideAvailability ( TYPE_ID  aDerived,
TYPE_ID  aBase,
const wxString &  aName,
std::function< bool(INSPECTABLE *)>  aFunc 
)

Sets an override availability functor for a base class property of a given derived class.

Parameters
aDerivedis the type to apply the mask for.
aBaseis the type that aName belongs to.
aNameis the name of a property on the base class.
aFuncis the new availability functor to apply.

Definition at line 196 of file property_mgr.cpp.

199{
200 wxASSERT_MSG( aDerived != aBase, "Class cannot override from itself" );
201
202 CLASS_DESC& derived = getClass( aDerived );
203 derived.m_availabilityOverrides[std::make_pair( aBase, aName )] = aFunc;
204 m_dirty = true;
205}

References getClass(), PROPERTY_MANAGER::CLASS_DESC::m_availabilityOverrides, and m_dirty.

Referenced by PAD_DESC::PAD_DESC(), PCB_MARKER_DESC::PCB_MARKER_DESC(), PCB_TEXT_DESC::PCB_TEXT_DESC(), and ZONE_DESC::ZONE_DESC().

◆ Rebuild()

void PROPERTY_MANAGER::Rebuild ( )

Rebuild the list of all registered properties.

Needs to be called once before GetProperty()/GetProperties() are used.

Definition at line 245 of file property_mgr.cpp.

246{
247 for( std::pair<const TYPE_ID, CLASS_DESC>& classEntry : m_classes )
248 classEntry.second.rebuild();
249
250 m_dirty = false;
251}

References m_classes, and m_dirty.

Referenced by BOOST_AUTO_TEST_CASE(), GetDisplayOrder(), GetGroupDisplayOrder(), GetProperties(), GetProperty(), main(), and PCB_PROPERTIES_PANEL::PCB_PROPERTIES_PANEL().

◆ RegisterType()

void PROPERTY_MANAGER::RegisterType ( TYPE_ID  aType,
const wxString &  aName 
)

Associate a name with a type.

Build a map to provide faster type look-up.

Parameters
aTypeis the type identifier (obtained using TYPE_HASH()).
aNameis the type name.

Definition at line 32 of file property_mgr.cpp.

33{
34 wxASSERT( m_classNames.count( aType ) == 0 );
35 m_classNames.emplace( aType, aName );
36}

References m_classNames.

◆ ReplaceProperty()

void PROPERTY_MANAGER::ReplaceProperty ( size_t  aBase,
const wxString &  aName,
PROPERTY_BASE aNew,
const wxString &  aGroup = wxEmptyString 
)

Replace an existing property for a specific type.

It is used to modify a property that has been inherited from a base class. This method is used instead of AddProperty().

Parameters
aBaseis the base class type the delivers the original property.
aNameis the name of the replaced property.
aNewis the property replacing the inherited one.
aGroupis the group to set for the replaced property.

Definition at line 153 of file property_mgr.cpp.

155{
156 CLASS_DESC& classDesc = getClass( aNew->OwnerHash() );
157 classDesc.m_replaced.insert( std::make_pair( aBase, aName ) );
158 AddProperty( aNew, aGroup );
159}
void AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.

References AddProperty(), getClass(), PROPERTY_MANAGER::CLASS_DESC::m_replaced, and PROPERTY_BASE::OwnerHash().

Referenced by BOARD_CONNECTED_ITEM_DESC::BOARD_CONNECTED_ITEM_DESC(), CLASS_D_DESC::CLASS_D_DESC(), CLASS_E_DESC::CLASS_E_DESC(), FOOTPRINT_DESC::FOOTPRINT_DESC(), PCB_SHAPE_DESC::PCB_SHAPE_DESC(), TRACK_VIA_DESC::TRACK_VIA_DESC(), and ZONE_DESC::ZONE_DESC().

◆ ResolveType()

const wxString & PROPERTY_MANAGER::ResolveType ( TYPE_ID  aType) const

Return name of a type.

Parameters
aTypeis the type identifier (obtained using TYPE_HASH()).
Returns
Name of the type or empty string, if not available.

Definition at line 39 of file property_mgr.cpp.

40{
41 auto it = m_classNames.find( aType );
42 return it != m_classNames.end() ? it->second : EMPTY_STRING;
43}
static wxString EMPTY_STRING(wxEmptyString)

References EMPTY_STRING(), and m_classNames.

◆ SetTransforms()

void PROPERTY_MANAGER::SetTransforms ( ORIGIN_TRANSFORMS aTransforms)
inline

◆ SetUnits()

void PROPERTY_MANAGER::SetUnits ( EDA_UNITS  aUnits)
inline

Definition at line 219 of file property_mgr.h.

220 {
221 m_units = aUnits;
222 }

References m_units.

Referenced by PROPERTIES_PANEL::extractValueAndWritability(), and PROPERTIES_PANEL::rebuildProperties().

◆ TypeCast() [1/2]

const void * PROPERTY_MANAGER::TypeCast ( const void *  aSource,
TYPE_ID  aBase,
TYPE_ID  aTarget 
) const

Cast a type to another type.

Used for correct type-casting of types with multi-inheritance. Requires registration of an appropriate converter (AddTypeCast).

Parameters
aSourceis a pointer to the casted object.
aBaseis aSource type identifier (obtained using TYPE_HASH()).
aTargetis the desired type identifier (obtained using TYPE_HASH()).
Returns
Properly casted pointer of aTarget type. *
See also
AddTypeCast

Definition at line 113 of file property_mgr.cpp.

114{
115 if( aBase == aTarget )
116 return aSource;
117
118 auto classDesc = m_classes.find( aBase );
119
120 if( classDesc == m_classes.end() )
121 return aSource;
122
123 auto& converters = classDesc->second.m_typeCasts;
124 auto converter = converters.find( aTarget );
125
126 if( converter == converters.end() ) // explicit type cast not found
127 return IsOfType( aBase, aTarget ) ? aSource : nullptr;
128
129 return (*converter->second)( aSource );
130}

References IsOfType(), and m_classes.

Referenced by INSPECTABLE::Get(), INSPECTABLE::Set(), and TypeCast().

◆ TypeCast() [2/2]

void * PROPERTY_MANAGER::TypeCast ( void *  aSource,
TYPE_ID  aBase,
TYPE_ID  aTarget 
) const
inline

Definition at line 134 of file property_mgr.h.

135 {
136 return const_cast<void*>( TypeCast( (const void*) aSource, aBase, aTarget ) );
137 }
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Cast a type to another type.

References TypeCast().

Member Data Documentation

◆ m_classes

std::unordered_map<TYPE_ID, CLASS_DESC> PROPERTY_MANAGER::m_classes
private

◆ m_classNames

std::unordered_map<TYPE_ID, wxString> PROPERTY_MANAGER::m_classNames
private

Map of all available types.

Definition at line 313 of file property_mgr.h.

Referenced by GetAllClasses(), RegisterType(), and ResolveType().

◆ m_dirty

bool PROPERTY_MANAGER::m_dirty
private

Flag indicating that the list of properties needs to be rebuild (RebuildProperties())

Definition at line 319 of file property_mgr.h.

Referenced by AddProperty(), GetDisplayOrder(), GetGroupDisplayOrder(), GetProperties(), GetProperty(), InheritsAfter(), Mask(), OverrideAvailability(), and Rebuild().

◆ m_originTransforms

ORIGIN_TRANSFORMS* PROPERTY_MANAGER::m_originTransforms
private

Definition at line 323 of file property_mgr.h.

Referenced by GetTransforms(), and SetTransforms().

◆ m_units

EDA_UNITS PROPERTY_MANAGER::m_units
private

Definition at line 321 of file property_mgr.h.

Referenced by GetUnits(), and SetUnits().


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