KiCad PCB EDA Suite
PROPERTY_BASE Class Referenceabstract

#include <property.h>

Inheritance diagram for PROPERTY_BASE:
PROPERTY< Owner, T, Owner > PROPERTY< Owner, T, Base > PROPERTY_ENUM< Owner, T, Base >

Public Member Functions

 PROPERTY_BASE (const wxString &aName, PROPERTY_DISPLAY aDisplay=PT_DEFAULT, ORIGIN_TRANSFORMS::COORD_TYPES_T aCoordType=ORIGIN_TRANSFORMS::NOT_A_COORD)
 < Used to generate unique IDs. Must come up front so it's initialized before ctor. More...
 
virtual ~PROPERTY_BASE ()
 
const wxString & Name () const
 
virtual const wxPGChoices & Choices () const
 Return a limited set of possible values (e.g. More...
 
virtual void SetChoices (const wxPGChoices &aChoices)
 Set the possible values for for the property. More...
 
virtual bool HasChoices () const
 Return true if this PROPERTY has a limited set of possible values. More...
 
bool Available (INSPECTABLE *aObject) const
 Return true if aObject offers this PROPERTY. More...
 
PROPERTY_BASESetAvailableFunc (std::function< bool(INSPECTABLE *)> aFunc)
 Set a callback function to determine whether an object provides this property. More...
 
virtual bool Writeable (INSPECTABLE *aObject) const
 
PROPERTY_BASESetWriteableFunc (std::function< bool(INSPECTABLE *)> aFunc)
 
virtual size_t OwnerHash () const =0
 Return type-id of the Owner class. More...
 
virtual size_t BaseHash () const =0
 Return type-id of the Base class. More...
 
virtual size_t TypeHash () const =0
 Return type-id of the property type. More...
 
PROPERTY_DISPLAY Display () const
 
PROPERTY_BASESetDisplay (PROPERTY_DISPLAY aDisplay)
 
ORIGIN_TRANSFORMS::COORD_TYPES_T CoordType () const
 
PROPERTY_BASESetCoordType (ORIGIN_TRANSFORMS::COORD_TYPES_T aType)
 
bool IsInternal () const
 
PROPERTY_BASESetIsInternal (bool aIsInternal=true)
 
bool IsDeprecated () const
 
PROPERTY_BASESetIsDeprecated (bool aIsDeprecated=true)
 
bool IsHiddenFromLibraryEditors () const
 
PROPERTY_BASESetIsHiddenFromLibraryEditors (bool aIsHidden=true)
 
wxString Group () const
 
PROPERTY_BASESetGroup (const wxString &aGroup)
 
PROPERTY_BASESetValidator (PROPERTY_VALIDATOR_FN &&aValidator)
 
VALIDATOR_RESULT Validate (const wxAny &&aValue, EDA_ITEM *aItem)
 

Static Public Member Functions

static VALIDATOR_RESULT NullValidator (const wxAny &&aValue, EDA_ITEM *aItem)
 

Protected Member Functions

template<typename T >
void set (void *aObject, T aValue)
 
template<typename T >
get (const void *aObject) const
 

Private Member Functions

virtual void setter (void *aObject, wxAny &aValue)=0
 
virtual wxAny getter (const void *aObject) const =0
 

Private Attributes

const wxString m_name
 Permanent identifier for this property. More...
 
PROPERTY_DISPLAY m_display
 The display style controls how properties are edited in the properties manager GUI. More...
 
ORIGIN_TRANSFORMS::COORD_TYPES_T m_coordType
 The coordinate type controls how distances are mapped to the user coordinate system. More...
 
bool m_isInternal
 Internal properties are hidden from the GUI but not from the rules editor autocomplete. More...
 
bool m_isDeprecated
 Deprecated properties are hidden from the GUI and rules editor autocomplete. More...
 
bool m_hideFromLibraryEditors
 This property should only be shown in the design editor, not the library editor. More...
 
wxString m_group
 Optional group identifier. More...
 
std::function< bool(INSPECTABLE *)> m_availFunc
 Eval to determine if prop is available. More...
 
std::function< bool(INSPECTABLE *)> m_writeableFunc
 Eval to determine if prop is read-only. More...
 
PROPERTY_VALIDATOR_FN m_validator
 

Friends

class INSPECTABLE
 

Detailed Description

Definition at line 177 of file property.h.

Constructor & Destructor Documentation

◆ PROPERTY_BASE()

PROPERTY_BASE::PROPERTY_BASE ( const wxString &  aName,
PROPERTY_DISPLAY  aDisplay = PT_DEFAULT,
ORIGIN_TRANSFORMS::COORD_TYPES_T  aCoordType = ORIGIN_TRANSFORMS::NOT_A_COORD 
)
inline

< Used to generate unique IDs. Must come up front so it's initialized before ctor.

Definition at line 183 of file property.h.

184 :
185 m_name( aName ),
186 m_display( aDisplay ),
187 m_coordType( aCoordType ),
188 m_isInternal( false ),
189 m_isDeprecated( false ),
191 m_availFunc( [](INSPECTABLE*)->bool { return true; } ),
192 m_writeableFunc( [](INSPECTABLE*)->bool { return true; } ),
194 {
195 }
Class that other classes need to inherit from, in order to be inspectable.
Definition: inspectable.h:36
bool m_hideFromLibraryEditors
This property should only be shown in the design editor, not the library editor.
Definition: property.h:387
const wxString m_name
Permanent identifier for this property.
Definition: property.h:372
std::function< bool(INSPECTABLE *)> m_writeableFunc
Eval to determine if prop is read-only.
Definition: property.h:394
std::function< bool(INSPECTABLE *)> m_availFunc
Eval to determine if prop is available.
Definition: property.h:392
PROPERTY_VALIDATOR_FN m_validator
Definition: property.h:396
static VALIDATOR_RESULT NullValidator(const wxAny &&aValue, EDA_ITEM *aItem)
Definition: property.h:318
PROPERTY_DISPLAY m_display
The display style controls how properties are edited in the properties manager GUI.
Definition: property.h:375
bool m_isDeprecated
Deprecated properties are hidden from the GUI and rules editor autocomplete.
Definition: property.h:384
ORIGIN_TRANSFORMS::COORD_TYPES_T m_coordType
The coordinate type controls how distances are mapped to the user coordinate system.
Definition: property.h:378
bool m_isInternal
Internal properties are hidden from the GUI but not from the rules editor autocomplete.
Definition: property.h:381

◆ ~PROPERTY_BASE()

virtual PROPERTY_BASE::~PROPERTY_BASE ( )
inlinevirtual

Definition at line 197 of file property.h.

198 {
199 }

Member Function Documentation

◆ Available()

bool PROPERTY_BASE::Available ( INSPECTABLE aObject) const
inline

Return true if aObject offers this PROPERTY.

Definition at line 233 of file property.h.

234 {
235 return m_availFunc( aObject );
236 }

Referenced by BOOST_AUTO_TEST_CASE(), and PROPERTY_MANAGER::IsAvailableFor().

◆ BaseHash()

virtual size_t PROPERTY_BASE::BaseHash ( ) const
pure virtual

Return type-id of the Base class.

Implemented in PROPERTY< Owner, T, Base >, and PROPERTY< Owner, T, Owner >.

Referenced by PROPERTY_MANAGER::IsAvailableFor().

◆ Choices()

virtual const wxPGChoices & PROPERTY_BASE::Choices ( ) const
inlinevirtual

Return a limited set of possible values (e.g.

enum). Check with HasChoices() if a particular PROPERTY provides such set.

Reimplemented in PROPERTY_ENUM< Owner, T, Base >.

Definition at line 207 of file property.h.

208 {
209 static wxPGChoices empty;
210 return empty;
211 }
static bool empty(const wxTextEntryBase *aCtrl)

References empty().

Referenced by BOOST_AUTO_TEST_CASE(), PCB_PROPERTIES_PANEL::createPGProperty(), and PGPropertyFactory().

◆ CoordType()

ORIGIN_TRANSFORMS::COORD_TYPES_T PROPERTY_BASE::CoordType ( ) const
inline

Definition at line 276 of file property.h.

276{ return m_coordType; }

Referenced by PGPropertyFactory().

◆ Display()

PROPERTY_DISPLAY PROPERTY_BASE::Display ( ) const
inline

Definition at line 273 of file property.h.

273{ return m_display; }

Referenced by PGPropertyFactory().

◆ get()

template<typename T >
T PROPERTY_BASE::get ( const void *  aObject) const
inlineprotected

Definition at line 352 of file property.h.

353 {
354 wxAny a = getter( aObject );
355
356 if ( !( std::is_enum<T>::value && a.CheckType<int>() ) && !a.CheckType<T>() )
357 throw std::invalid_argument( "Invalid requested type" );
358
359 return wxANY_AS( a, T );
360 }
virtual wxAny getter(const void *aObject) const =0

Referenced by INSPECTABLE::Get().

◆ getter()

virtual wxAny PROPERTY_BASE::getter ( const void *  aObject) const
privatepure virtual

◆ Group()

wxString PROPERTY_BASE::Group ( ) const
inline

Definition at line 304 of file property.h.

304{ return m_group; }
wxString m_group
Optional group identifier.
Definition: property.h:390

◆ HasChoices()

virtual bool PROPERTY_BASE::HasChoices ( ) const
inlinevirtual

Return true if this PROPERTY has a limited set of possible values.

See also
PROPERTY_BASE::Choices()

Reimplemented in PROPERTY_ENUM< Owner, T, Base >.

Definition at line 225 of file property.h.

226 {
227 return false;
228 }

Referenced by BOOST_AUTO_TEST_CASE(), PCB_PROPERTIES_PANEL::createPGProperty(), PCB_EXPR_UCODE::CreateVarRef(), PROPERTIES_PANEL::getItemValue(), and PGPropertyFactory().

◆ IsDeprecated()

bool PROPERTY_BASE::IsDeprecated ( ) const
inline

Definition at line 290 of file property.h.

290{ return m_isDeprecated; }

◆ IsHiddenFromLibraryEditors()

bool PROPERTY_BASE::IsHiddenFromLibraryEditors ( ) const
inline

Definition at line 297 of file property.h.

297{ return m_hideFromLibraryEditors; }

◆ IsInternal()

bool PROPERTY_BASE::IsInternal ( ) const
inline

Definition at line 283 of file property.h.

283{ return m_isInternal; }

◆ Name()

const wxString & PROPERTY_BASE::Name ( ) const
inline

◆ NullValidator()

static VALIDATOR_RESULT PROPERTY_BASE::NullValidator ( const wxAny &&  aValue,
EDA_ITEM aItem 
)
inlinestatic

Definition at line 318 of file property.h.

319 {
320 return std::nullopt;
321 }

◆ OwnerHash()

virtual size_t PROPERTY_BASE::OwnerHash ( ) const
pure virtual

◆ set()

template<typename T >
void PROPERTY_BASE::set ( void *  aObject,
aValue 
)
inlineprotected

Definition at line 325 of file property.h.

326 {
327 wxAny a = aValue;
328
329 // wxVariant will be type "long" even if the property is supposed to be
330 // unsigned. Let's trust that we're coming from the property grid where
331 // we used a UInt editor.
332 if( std::is_same<T, wxVariant>::value )
333 {
334 wxVariant var = static_cast<wxVariant>( aValue );
335 wxAny pv = getter( aObject );
336
337 if( pv.CheckType<unsigned>() )
338 {
339 a = static_cast<unsigned>( var.GetLong() );
340 }
341 else if( pv.CheckType<EDA_ANGLE>() )
342 {
343 EDA_ANGLE_VARIANT_DATA* ad = static_cast<EDA_ANGLE_VARIANT_DATA*>( var.GetData() );
344 a = ad->Angle();
345 }
346 }
347
348 setter( aObject, a );
349 }
const EDA_ANGLE & Angle()
virtual void setter(void *aObject, wxAny &aValue)=0

References EDA_ANGLE_VARIANT_DATA::Angle().

Referenced by INSPECTABLE::Set().

◆ SetAvailableFunc()

PROPERTY_BASE & PROPERTY_BASE::SetAvailableFunc ( std::function< bool(INSPECTABLE *)>  aFunc)
inline

Set a callback function to determine whether an object provides this property.

Definition at line 241 of file property.h.

242 {
243 m_availFunc = aFunc;
244 return *this;
245 }

Referenced by EDA_SHAPE_DESC::EDA_SHAPE_DESC().

◆ SetChoices()

virtual void PROPERTY_BASE::SetChoices ( const wxPGChoices &  aChoices)
inlinevirtual

Set the possible values for for the property.

Reimplemented in PROPERTY_ENUM< Owner, T, Base >.

Definition at line 216 of file property.h.

217 {
218 wxFAIL; // only possible for PROPERTY_ENUM
219 }

Referenced by PCB_PROPERTIES_PANEL::updateLists().

◆ SetCoordType()

PROPERTY_BASE & PROPERTY_BASE::SetCoordType ( ORIGIN_TRANSFORMS::COORD_TYPES_T  aType)
inline

Definition at line 277 of file property.h.

278 {
279 m_coordType = aType;
280 return *this;
281 }

◆ SetDisplay()

PROPERTY_BASE & PROPERTY_BASE::SetDisplay ( PROPERTY_DISPLAY  aDisplay)
inline

Definition at line 274 of file property.h.

274{ m_display = aDisplay; return *this; }

◆ SetGroup()

PROPERTY_BASE & PROPERTY_BASE::SetGroup ( const wxString &  aGroup)
inline

Definition at line 305 of file property.h.

305{ m_group = aGroup; return *this; }

Referenced by PROPERTY_MANAGER::AddProperty().

◆ SetIsDeprecated()

PROPERTY_BASE & PROPERTY_BASE::SetIsDeprecated ( bool  aIsDeprecated = true)
inline

Definition at line 291 of file property.h.

292 {
293 m_isDeprecated = aIsDeprecated;
294 return *this;
295 }

Referenced by BOARD_CONNECTED_ITEM_DESC::BOARD_CONNECTED_ITEM_DESC().

◆ SetIsHiddenFromLibraryEditors()

PROPERTY_BASE & PROPERTY_BASE::SetIsHiddenFromLibraryEditors ( bool  aIsHidden = true)
inline

◆ SetIsInternal()

PROPERTY_BASE & PROPERTY_BASE::SetIsInternal ( bool  aIsInternal = true)
inline

Definition at line 284 of file property.h.

285 {
286 m_isInternal = aIsInternal;
287 return *this;
288 }

Referenced by BOARD_CONNECTED_ITEM_DESC::BOARD_CONNECTED_ITEM_DESC(), and EDA_ITEM_DESC::EDA_ITEM_DESC().

◆ setter()

virtual void PROPERTY_BASE::setter ( void *  aObject,
wxAny &  aValue 
)
privatepure virtual

◆ SetValidator()

PROPERTY_BASE & PROPERTY_BASE::SetValidator ( PROPERTY_VALIDATOR_FN &&  aValidator)
inline

Definition at line 307 of file property.h.

308 {
309 m_validator = aValidator;
310 return *this;
311 }

Referenced by EDA_TEXT_DESC::EDA_TEXT_DESC(), PAD_DESC::PAD_DESC(), and ZONE_DESC::ZONE_DESC().

◆ SetWriteableFunc()

PROPERTY_BASE & PROPERTY_BASE::SetWriteableFunc ( std::function< bool(INSPECTABLE *)>  aFunc)
inline

Definition at line 252 of file property.h.

253 {
254 m_writeableFunc = aFunc;
255 return *this;
256 }

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

◆ TypeHash()

virtual size_t PROPERTY_BASE::TypeHash ( ) const
pure virtual

◆ Validate()

VALIDATOR_RESULT PROPERTY_BASE::Validate ( const wxAny &&  aValue,
EDA_ITEM aItem 
)
inline

Definition at line 313 of file property.h.

314 {
315 return m_validator( std::move( aValue ), aItem );
316 }

◆ Writeable()

virtual bool PROPERTY_BASE::Writeable ( INSPECTABLE aObject) const
inlinevirtual

Reimplemented in PROPERTY< Owner, T, Base >, and PROPERTY< Owner, T, Owner >.

Definition at line 247 of file property.h.

248 {
249 return m_writeableFunc( aObject );
250 }

Referenced by PROPERTIES_PANEL::extractValueAndWritability(), and PROPERTY< Owner, T, Base >::Writeable().

Friends And Related Function Documentation

◆ INSPECTABLE

friend class INSPECTABLE
friend

Definition at line 398 of file property.h.

Member Data Documentation

◆ m_availFunc

std::function<bool(INSPECTABLE*)> PROPERTY_BASE::m_availFunc
private

Eval to determine if prop is available.

Definition at line 392 of file property.h.

◆ m_coordType

ORIGIN_TRANSFORMS::COORD_TYPES_T PROPERTY_BASE::m_coordType
private

The coordinate type controls how distances are mapped to the user coordinate system.

Definition at line 378 of file property.h.

◆ m_display

PROPERTY_DISPLAY PROPERTY_BASE::m_display
private

The display style controls how properties are edited in the properties manager GUI.

Definition at line 375 of file property.h.

◆ m_group

wxString PROPERTY_BASE::m_group
private

Optional group identifier.

Definition at line 390 of file property.h.

◆ m_hideFromLibraryEditors

bool PROPERTY_BASE::m_hideFromLibraryEditors
private

This property should only be shown in the design editor, not the library editor.

Definition at line 387 of file property.h.

◆ m_isDeprecated

bool PROPERTY_BASE::m_isDeprecated
private

Deprecated properties are hidden from the GUI and rules editor autocomplete.

Definition at line 384 of file property.h.

◆ m_isInternal

bool PROPERTY_BASE::m_isInternal
private

Internal properties are hidden from the GUI but not from the rules editor autocomplete.

Definition at line 381 of file property.h.

◆ m_name

const wxString PROPERTY_BASE::m_name
private

Permanent identifier for this property.

Property names are an API contract; changing them after release will impact the Custom DRC Rules system as well as the automatic API binding system. Never rename properties; instead deprecate them and hide them from the GUI.

Definition at line 372 of file property.h.

◆ m_validator

PROPERTY_VALIDATOR_FN PROPERTY_BASE::m_validator
private

Definition at line 396 of file property.h.

◆ m_writeableFunc

std::function<bool(INSPECTABLE*)> PROPERTY_BASE::m_writeableFunc
private

Eval to determine if prop is read-only.

Definition at line 394 of file property.h.


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