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...
 
void SetAvailableFunc (std::function< bool(INSPECTABLE *)> aFunc)
 Set a callback function to determine whether an object provides this property. More...
 
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...
 
virtual bool IsReadOnly () const =0
 
PROPERTY_DISPLAY Display () const
 
ORIGIN_TRANSFORMS::COORD_TYPES_T CoordType () const
 
void SetIsInternal (bool aIsInternal)
 
bool IsInternal () const
 
wxString Group () const
 
void SetGroup (const wxString &aGroup)
 

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
 
const PROPERTY_DISPLAY m_display
 
const ORIGIN_TRANSFORMS::COORD_TYPES_T m_coordType
 
bool m_isInternal
 Internal properties are hidden from the GUI. More...
 
wxString m_group
 Optional group identifier. More...
 
std::function< bool(INSPECTABLE *)> m_availFunc
 Eval to determine if prop is available. More...
 

Friends

class INSPECTABLE
 

Detailed Description

Definition at line 175 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 181 of file property.h.

182 :
183 m_name( aName ),
184 m_display( aDisplay ),
185 m_coordType( aCoordType ),
186 m_isInternal( false ),
187 m_availFunc( [](INSPECTABLE*)->bool { return true; } )
188 {
189 }
Class that other classes need to inherit from, in order to be inspectable.
Definition: inspectable.h:36
const PROPERTY_DISPLAY m_display
Definition: property.h:310
const ORIGIN_TRANSFORMS::COORD_TYPES_T m_coordType
Definition: property.h:311
const wxString m_name
Definition: property.h:309
std::function< bool(INSPECTABLE *)> m_availFunc
Eval to determine if prop is available.
Definition: property.h:319
bool m_isInternal
Internal properties are hidden from the GUI.
Definition: property.h:314

◆ ~PROPERTY_BASE()

virtual PROPERTY_BASE::~PROPERTY_BASE ( )
inlinevirtual

Definition at line 191 of file property.h.

192 {
193 }

Member Function Documentation

◆ Available()

bool PROPERTY_BASE::Available ( INSPECTABLE aObject) const
inline

Return true if aObject offers this PROPERTY.

Definition at line 230 of file property.h.

231 {
232 return m_availFunc( aObject );
233 }

Referenced by BOOST_AUTO_TEST_CASE().

◆ 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::ReplaceProperty().

◆ 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 204 of file property.h.

205 {
206 static wxPGChoices empty;
207 return empty;
208 }
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 265 of file property.h.

265{ return m_coordType; }

Referenced by PGPropertyFactory().

◆ Display()

PROPERTY_DISPLAY PROPERTY_BASE::Display ( ) const
inline

Definition at line 260 of file property.h.

261 {
262 return m_display;
263 }

Referenced by PGPropertyFactory().

◆ get()

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

Definition at line 294 of file property.h.

295 {
296 wxAny a = getter( aObject );
297
298 if ( !( std::is_enum<T>::value && a.CheckType<int>() ) && !a.CheckType<T>() )
299 throw std::invalid_argument( "Invalid requested type" );
300
301 return wxANY_AS( a, T );
302 }
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 270 of file property.h.

270{ return m_group; }
wxString m_group
Optional group identifier.
Definition: property.h:317

◆ 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 222 of file property.h.

223 {
224 return false;
225 }

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

◆ IsInternal()

bool PROPERTY_BASE::IsInternal ( ) const
inline

Definition at line 268 of file property.h.

268{ return m_isInternal; }

◆ IsReadOnly()

virtual bool PROPERTY_BASE::IsReadOnly ( ) const
pure virtual

◆ Name()

const wxString & PROPERTY_BASE::Name ( ) const
inline

◆ 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 275 of file property.h.

276 {
277 wxAny a = aValue;
278
279 // wxVariant will be type "long" even if the property is supposed to be
280 // unsigned. Let's trust that we're coming from the property grid where
281 // we used a UInt editor.
282 if( std::is_same<T, wxVariant>::value )
283 {
284 wxAny pv = getter( aObject );
285
286 if( pv.CheckType<unsigned>() )
287 a = static_cast<unsigned>( static_cast<wxVariant>( aValue ).GetLong() );
288 }
289
290 setter( aObject, a );
291 }
virtual void setter(void *aObject, wxAny &aValue)=0

Referenced by INSPECTABLE::Set().

◆ SetAvailableFunc()

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

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

Definition at line 238 of file property.h.

239 {
240 m_availFunc = aFunc;
241 }

◆ 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 213 of file property.h.

214 {
215 wxFAIL; // only possible for PROPERTY_ENUM
216 }

Referenced by PCB_PROPERTIES_PANEL::updateLists().

◆ SetGroup()

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

Definition at line 271 of file property.h.

271{ m_group = aGroup; }

Referenced by PROPERTY_MANAGER::AddProperty().

◆ SetIsInternal()

void PROPERTY_BASE::SetIsInternal ( bool  aIsInternal)
inline

Definition at line 267 of file property.h.

267{ m_isInternal = aIsInternal; }

◆ setter()

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

◆ TypeHash()

virtual size_t PROPERTY_BASE::TypeHash ( ) const
pure virtual

Friends And Related Function Documentation

◆ INSPECTABLE

friend class INSPECTABLE
friend

Definition at line 321 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 319 of file property.h.

◆ m_coordType

const ORIGIN_TRANSFORMS::COORD_TYPES_T PROPERTY_BASE::m_coordType
private

Definition at line 311 of file property.h.

◆ m_display

const PROPERTY_DISPLAY PROPERTY_BASE::m_display
private

Definition at line 310 of file property.h.

◆ m_group

wxString PROPERTY_BASE::m_group
private

Optional group identifier.

Definition at line 317 of file property.h.

◆ m_isInternal

bool PROPERTY_BASE::m_isInternal
private

Internal properties are hidden from the GUI.

Definition at line 314 of file property.h.

◆ m_name

const wxString PROPERTY_BASE::m_name
private

Definition at line 309 of file property.h.


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