KiCad PCB EDA Suite
PROPERTY< Owner, T, Base > Class Template Reference

#include <property.h>

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

Public Types

using BASE_TYPE = typename std::decay< T >::type
 

Public Member Functions

template<typename SetType , typename GetType >
 PROPERTY (const wxString &aName, void(Base::*aSetter)(SetType), GetType(Base::*aGetter)(), PROPERTY_DISPLAY aDisplay=PT_DEFAULT, ORIGIN_TRANSFORMS::COORD_TYPES_T aCoordType=ORIGIN_TRANSFORMS::NOT_A_COORD)
 
template<typename SetType , typename GetType >
 PROPERTY (const wxString &aName, void(Base::*aSetter)(SetType), GetType(Base::*aGetter)() const, PROPERTY_DISPLAY aDisplay=PT_DEFAULT, ORIGIN_TRANSFORMS::COORD_TYPES_T aCoordType=ORIGIN_TRANSFORMS::NOT_A_COORD)
 
size_t OwnerHash () const override
 Return type-id of the Owner class. More...
 
size_t BaseHash () const override
 Return type-id of the Base class. More...
 
size_t TypeHash () const override
 Return type-id of the property type. More...
 
bool IsReadOnly () const override
 
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...
 
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

 PROPERTY (const wxString &aName, SETTER_BASE< Owner, T > *s, GETTER_BASE< Owner, T > *g, PROPERTY_DISPLAY aDisplay, ORIGIN_TRANSFORMS::COORD_TYPES_T aCoordType)
 
virtual ~PROPERTY ()
 
virtual void setter (void *obj, wxAny &v) override
 
virtual wxAny getter (const void *obj) const override
 Set method. More...
 
template<typename T >
void set (void *aObject, T aValue)
 
template<typename T >
get (const void *aObject) const
 

Protected Attributes

std::unique_ptr< SETTER_BASE< Owner, T > > m_setter
 Get method. More...
 
std::unique_ptr< GETTER_BASE< Owner, T > > m_getter
 Owner class type-id. More...
 
const size_t m_ownerHash
 Base class type-id. More...
 
const size_t m_baseHash
 Property value type-id. More...
 
const size_t m_typeHash
 

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...
 

Detailed Description

template<typename Owner, typename T, typename Base = Owner>
class PROPERTY< Owner, T, Base >

Definition at line 326 of file property.h.

Member Typedef Documentation

◆ BASE_TYPE

template<typename Owner , typename T , typename Base = Owner>
using PROPERTY< Owner, T, Base >::BASE_TYPE = typename std::decay<T>::type

Definition at line 329 of file property.h.

Constructor & Destructor Documentation

◆ PROPERTY() [1/3]

template<typename Owner , typename T , typename Base = Owner>
template<typename SetType , typename GetType >
PROPERTY< Owner, T, Base >::PROPERTY ( const wxString &  aName,
void(Base::*)(SetType)  aSetter,
GetType(Base::*)()  aGetter,
PROPERTY_DISPLAY  aDisplay = PT_DEFAULT,
ORIGIN_TRANSFORMS::COORD_TYPES_T  aCoordType = ORIGIN_TRANSFORMS::NOT_A_COORD 
)
inline

Definition at line 332 of file property.h.

336 : PROPERTY( aName, METHOD<Owner, T, Base>::Wrap( aSetter ),
337 METHOD<Owner, T, Base>::Wrap( aGetter ), aDisplay, aCoordType )
338 {
339 }
PROPERTY(const wxString &aName, void(Base::*aSetter)(SetType), GetType(Base::*aGetter)(), PROPERTY_DISPLAY aDisplay=PT_DEFAULT, ORIGIN_TRANSFORMS::COORD_TYPES_T aCoordType=ORIGIN_TRANSFORMS::NOT_A_COORD)
Definition: property.h:332

◆ PROPERTY() [2/3]

template<typename Owner , typename T , typename Base = Owner>
template<typename SetType , typename GetType >
PROPERTY< Owner, T, Base >::PROPERTY ( const wxString &  aName,
void(Base::*)(SetType)  aSetter,
GetType(Base::*)() const  aGetter,
PROPERTY_DISPLAY  aDisplay = PT_DEFAULT,
ORIGIN_TRANSFORMS::COORD_TYPES_T  aCoordType = ORIGIN_TRANSFORMS::NOT_A_COORD 
)
inline

Definition at line 342 of file property.h.

346 : PROPERTY( aName, METHOD<Owner, T, Base>::Wrap( aSetter ),
347 METHOD<Owner, T, Base>::Wrap( aGetter ), aDisplay, aCoordType )
348 {
349 }

◆ PROPERTY() [3/3]

template<typename Owner , typename T , typename Base = Owner>
PROPERTY< Owner, T, Base >::PROPERTY ( const wxString &  aName,
SETTER_BASE< Owner, T > *  s,
GETTER_BASE< Owner, T > *  g,
PROPERTY_DISPLAY  aDisplay,
ORIGIN_TRANSFORMS::COORD_TYPES_T  aCoordType 
)
inlineprotected

Definition at line 372 of file property.h.

374 : PROPERTY_BASE( aName, aDisplay, aCoordType ), m_setter( s ), m_getter( g ),
375 m_ownerHash( TYPE_HASH( Owner ) ), m_baseHash( TYPE_HASH( Base ) ),
377 {
378 }
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.
Definition: property.h:181
std::unique_ptr< SETTER_BASE< Owner, T > > m_setter
Get method.
Definition: property.h:402
const size_t m_baseHash
Property value type-id.
Definition: property.h:411
typename std::decay< T >::type BASE_TYPE
Definition: property.h:329
const size_t m_typeHash
Definition: property.h:414
std::unique_ptr< GETTER_BASE< Owner, T > > m_getter
Owner class type-id.
Definition: property.h:405
const size_t m_ownerHash
Base class type-id.
Definition: property.h:408
#define TYPE_HASH(x)
Definition: property.h:61

◆ ~PROPERTY()

template<typename Owner , typename T , typename Base = Owner>
virtual PROPERTY< Owner, T, Base >::~PROPERTY ( )
inlineprotectedvirtual

Definition at line 380 of file property.h.

380{}

Member Function Documentation

◆ Available()

bool PROPERTY_BASE::Available ( INSPECTABLE aObject) const
inlineinherited

Return true if aObject offers this PROPERTY.

Definition at line 230 of file property.h.

231 {
232 return m_availFunc( aObject );
233 }
std::function< bool(INSPECTABLE *)> m_availFunc
Eval to determine if prop is available.
Definition: property.h:319

Referenced by BOOST_AUTO_TEST_CASE().

◆ BaseHash()

template<typename Owner , typename T , typename Base = Owner>
size_t PROPERTY< Owner, T, Base >::BaseHash ( ) const
inlineoverridevirtual

Return type-id of the Base class.

Implements PROPERTY_BASE.

Definition at line 356 of file property.h.

357 {
358 return m_baseHash;
359 }

References PROPERTY< Owner, T, Base >::m_baseHash.

◆ Choices()

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

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
inlineinherited

Definition at line 265 of file property.h.

265{ return m_coordType; }
const ORIGIN_TRANSFORMS::COORD_TYPES_T m_coordType
Definition: property.h:311

Referenced by PGPropertyFactory().

◆ Display()

PROPERTY_DISPLAY PROPERTY_BASE::Display ( ) const
inlineinherited

Definition at line 260 of file property.h.

261 {
262 return m_display;
263 }
const PROPERTY_DISPLAY m_display
Definition: property.h:310

Referenced by PGPropertyFactory().

◆ get()

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

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 PROPERTY_MANAGER::CLASS_DESC::collectPropsRecur(), and INSPECTABLE::Get().

◆ getter()

template<typename Owner , typename T , typename Base = Owner>
virtual wxAny PROPERTY< Owner, T, Base >::getter ( const void *  obj) const
inlineoverrideprotectedvirtual

Set method.

Implements PROPERTY_BASE.

Reimplemented in PROPERTY_ENUM< Owner, T, Base >.

Definition at line 394 of file property.h.

◆ Group()

wxString PROPERTY_BASE::Group ( ) const
inlineinherited

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
inlinevirtualinherited

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
inlineinherited

Definition at line 268 of file property.h.

268{ return m_isInternal; }
bool m_isInternal
Internal properties are hidden from the GUI.
Definition: property.h:314

◆ IsReadOnly()

template<typename Owner , typename T , typename Base = Owner>
bool PROPERTY< Owner, T, Base >::IsReadOnly ( ) const
inlineoverridevirtual

Implements PROPERTY_BASE.

Definition at line 366 of file property.h.

367 {
368 return !m_setter;
369 }

References PROPERTY< Owner, T, Base >::m_setter.

Referenced by PROPERTY< Owner, T, Base >::setter().

◆ Name()

const wxString & PROPERTY_BASE::Name ( ) const
inlineinherited

◆ OwnerHash()

template<typename Owner , typename T , typename Base = Owner>
size_t PROPERTY< Owner, T, Base >::OwnerHash ( ) const
inlineoverridevirtual

Return type-id of the Owner class.

Implements PROPERTY_BASE.

Definition at line 351 of file property.h.

352 {
353 return m_ownerHash;
354 }

References PROPERTY< Owner, T, Base >::m_ownerHash.

◆ set()

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

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)
inlineinherited

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)
inlinevirtualinherited

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)
inlineinherited

Definition at line 271 of file property.h.

271{ m_group = aGroup; }

Referenced by PROPERTY_MANAGER::AddProperty().

◆ SetIsInternal()

void PROPERTY_BASE::SetIsInternal ( bool  aIsInternal)
inlineinherited

Definition at line 267 of file property.h.

267{ m_isInternal = aIsInternal; }

◆ setter()

template<typename Owner , typename T , typename Base = Owner>
virtual void PROPERTY< Owner, T, Base >::setter ( void *  obj,
wxAny &  v 
)
inlineoverrideprotectedvirtual

Implements PROPERTY_BASE.

Reimplemented in PROPERTY_ENUM< Owner, T, Base >.

Definition at line 382 of file property.h.

383 {
384 wxCHECK( !IsReadOnly(), /*void*/ );
385
386 if( !v.CheckType<T>() )
387 throw std::invalid_argument( "Invalid type requested" );
388
389 Owner* o = reinterpret_cast<Owner*>( obj );
390 BASE_TYPE value = wxANY_AS(v, BASE_TYPE);
391 (*m_setter)( o, value );
392 }
bool IsReadOnly() const override
Definition: property.h:366

References PROPERTY< Owner, T, Base >::IsReadOnly().

◆ TypeHash()

template<typename Owner , typename T , typename Base = Owner>
size_t PROPERTY< Owner, T, Base >::TypeHash ( ) const
inlineoverridevirtual

Return type-id of the property type.

Implements PROPERTY_BASE.

Definition at line 361 of file property.h.

362 {
363 return m_typeHash;
364 }

References PROPERTY< Owner, T, Base >::m_typeHash.

Member Data Documentation

◆ m_availFunc

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

Eval to determine if prop is available.

Definition at line 319 of file property.h.

◆ m_baseHash

template<typename Owner , typename T , typename Base = Owner>
const size_t PROPERTY< Owner, T, Base >::m_baseHash
protected

Property value type-id.

Definition at line 411 of file property.h.

Referenced by PROPERTY< Owner, T, Base >::BaseHash().

◆ m_coordType

const ORIGIN_TRANSFORMS::COORD_TYPES_T PROPERTY_BASE::m_coordType
privateinherited

Definition at line 311 of file property.h.

◆ m_display

const PROPERTY_DISPLAY PROPERTY_BASE::m_display
privateinherited

Definition at line 310 of file property.h.

◆ m_getter

template<typename Owner , typename T , typename Base = Owner>
std::unique_ptr<GETTER_BASE<Owner, T> > PROPERTY< Owner, T, Base >::m_getter
protected

Owner class type-id.

Definition at line 405 of file property.h.

◆ m_group

wxString PROPERTY_BASE::m_group
privateinherited

Optional group identifier.

Definition at line 317 of file property.h.

◆ m_isInternal

bool PROPERTY_BASE::m_isInternal
privateinherited

Internal properties are hidden from the GUI.

Definition at line 314 of file property.h.

◆ m_name

const wxString PROPERTY_BASE::m_name
privateinherited

Definition at line 309 of file property.h.

◆ m_ownerHash

template<typename Owner , typename T , typename Base = Owner>
const size_t PROPERTY< Owner, T, Base >::m_ownerHash
protected

Base class type-id.

Definition at line 408 of file property.h.

Referenced by PROPERTY< Owner, T, Base >::OwnerHash().

◆ m_setter

template<typename Owner , typename T , typename Base = Owner>
std::unique_ptr<SETTER_BASE<Owner, T> > PROPERTY< Owner, T, Base >::m_setter
protected

Get method.

Definition at line 402 of file property.h.

Referenced by PROPERTY< Owner, T, Base >::IsReadOnly().

◆ m_typeHash

template<typename Owner , typename T , typename Base = Owner>
const size_t PROPERTY< Owner, T, Base >::m_typeHash
protected

Definition at line 414 of file property.h.

Referenced by PROPERTY< Owner, T, Base >::TypeHash().


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