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

#include <property.h>

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

Public Types

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

Public Member Functions

template<typename SetType , typename GetType >
 PROPERTY_ENUM (const wxString &aName, void(Base::*aSetter)(SetType), GetType(Base::*aGetter)(), PROPERTY_DISPLAY aDisplay=PT_DEFAULT)
 
template<typename SetType , typename GetType >
 PROPERTY_ENUM (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)
 
void setter (void *obj, wxAny &v) override
 
wxAny getter (const void *obj) const override
 Set method. More...
 
const wxPGChoices & Choices () const override
 Return a limited set of possible values (e.g. More...
 
void SetChoices (const wxPGChoices &aChoices) override
 Set the possible values for for the property. More...
 
bool HasChoices () const override
 Return true if this PROPERTY has a limited set of possible values. More...
 
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 Writeable (INSPECTABLE *aObject) const override
 
const wxString & Name () const
 
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...
 
void SetWriteableFunc (std::function< bool(INSPECTABLE *)> aFunc)
 
PROPERTY_DISPLAY Display () const
 
ORIGIN_TRANSFORMS::COORD_TYPES_T CoordType () const
 
void SetIsInternal (bool aIsInternal=true)
 
bool IsInternal () const
 
void SetIsDeprecated (bool aIsDeprecated=true)
 
bool IsDeprecated () 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
 

Protected Attributes

wxPGChoices m_choices
 
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 but not from the rules editor autocomplete. More...
 
bool m_isDeprecated
 Deprecated properties are hidden from the GUI and rules editor autocomplete. 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...
 

Detailed Description

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

Definition at line 446 of file property.h.

Member Typedef Documentation

◆ BASE_TYPE

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

Definition at line 356 of file property.h.

Constructor & Destructor Documentation

◆ PROPERTY_ENUM() [1/2]

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

Definition at line 450 of file property.h.

454 METHOD<Owner, T, Base>::Wrap( aGetter ), aDisplay )
455 {
456 if ( std::is_enum<T>::value )
457 {
458 m_choices = ENUM_MAP<T>::Instance().Choices();
459 wxASSERT_MSG( m_choices.GetCount() > 0, wxT( "No enum choices defined" ) );
460 }
461 }
static ENUM_MAP< T > & Instance()
Definition: property.h:573
wxPGChoices m_choices
Definition: property.h:522

References ENUM_MAP< T >::Instance(), and PROPERTY_ENUM< Owner, T, Base >::m_choices.

◆ PROPERTY_ENUM() [2/2]

template<typename Owner , typename T , typename Base = Owner>
template<typename SetType , typename GetType >
PROPERTY_ENUM< Owner, T, Base >::PROPERTY_ENUM ( 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 464 of file property.h.

469 METHOD<Owner, T, Base>::Wrap( aGetter ), aDisplay, aCoordType )
470 {
471 if ( std::is_enum<T>::value )
472 {
473 m_choices = ENUM_MAP<T>::Instance().Choices();
474 wxASSERT_MSG( m_choices.GetCount() > 0, wxT( "No enum choices defined" ) );
475 }
476 }

References ENUM_MAP< T >::Instance(), and PROPERTY_ENUM< Owner, T, Base >::m_choices.

Member Function Documentation

◆ Available()

bool PROPERTY_BASE::Available ( INSPECTABLE aObject) const
inlineinherited

Return true if aObject offers this PROPERTY.

Definition at line 233 of file property.h.

234 {
235 return m_availFunc( aObject );
236 }
std::function< bool(INSPECTABLE *)> m_availFunc
Eval to determine if prop is available.
Definition: property.h:344

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

◆ BaseHash()

size_t PROPERTY< Owner, T, Owner >::BaseHash ( ) const
inlineoverridevirtualinherited

Return type-id of the Base class.

Implements PROPERTY_BASE.

Definition at line 383 of file property.h.

384 {
385 return m_baseHash;
386 }
const size_t m_baseHash
Property value type-id.
Definition: property.h:438

◆ Choices()

template<typename Owner , typename T , typename Base = Owner>
const wxPGChoices & PROPERTY_ENUM< Owner, T, Base >::Choices ( ) const
inlineoverridevirtual

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

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

Reimplemented from PROPERTY_BASE.

Definition at line 506 of file property.h.

507 {
508 return m_choices.GetCount() > 0 ? m_choices : ENUM_MAP<T>::Instance().Choices();
509 }

References ENUM_MAP< T >::Instance(), and PROPERTY_ENUM< Owner, T, Base >::m_choices.

Referenced by PROPERTY_ENUM< Owner, T, Base >::HasChoices().

◆ CoordType()

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

Definition at line 276 of file property.h.

276{ return m_coordType; }
const ORIGIN_TRANSFORMS::COORD_TYPES_T m_coordType
Definition: property.h:333

Referenced by PGPropertyFactory().

◆ Display()

PROPERTY_DISPLAY PROPERTY_BASE::Display ( ) const
inlineinherited

Definition at line 271 of file property.h.

272 {
273 return m_display;
274 }
const PROPERTY_DISPLAY m_display
Definition: property.h:332

Referenced by PGPropertyFactory().

◆ get()

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

Definition at line 316 of file property.h.

317 {
318 wxAny a = getter( aObject );
319
320 if ( !( std::is_enum<T>::value && a.CheckType<int>() ) && !a.CheckType<T>() )
321 throw std::invalid_argument( "Invalid requested type" );
322
323 return wxANY_AS( a, T );
324 }
virtual wxAny getter(const void *aObject) const =0

Referenced by INSPECTABLE::Get().

◆ getter()

template<typename Owner , typename T , typename Base = Owner>
wxAny PROPERTY_ENUM< Owner, T, Base >::getter ( const void *  obj) const
inlineoverridevirtual

Set method.

Reimplemented from PROPERTY< Owner, T, Owner >.

Definition at line 499 of file property.h.

500 {
501 const Owner* o = reinterpret_cast<const Owner*>( obj );
502 wxAny res = static_cast<T>( (*PROPERTY<Owner, T, Base>::m_getter)( o ) );
503 return res;
504 }
VECTOR3I res

References res.

◆ Group()

wxString PROPERTY_BASE::Group ( ) const
inlineinherited

Definition at line 284 of file property.h.

284{ return m_group; }
wxString m_group
Optional group identifier.
Definition: property.h:342

◆ HasChoices()

template<typename Owner , typename T , typename Base = Owner>
bool PROPERTY_ENUM< Owner, T, Base >::HasChoices ( ) const
inlineoverridevirtual

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

See also
PROPERTY_BASE::Choices()

Reimplemented from PROPERTY_BASE.

Definition at line 516 of file property.h.

517 {
518 return Choices().GetCount() > 0;
519 }
const wxPGChoices & Choices() const override
Return a limited set of possible values (e.g.
Definition: property.h:506

References PROPERTY_ENUM< Owner, T, Base >::Choices().

◆ IsDeprecated()

bool PROPERTY_BASE::IsDeprecated ( ) const
inlineinherited

Definition at line 282 of file property.h.

282{ return m_isDeprecated; }
bool m_isDeprecated
Deprecated properties are hidden from the GUI and rules editor autocomplete.
Definition: property.h:339

◆ IsInternal()

bool PROPERTY_BASE::IsInternal ( ) const
inlineinherited

Definition at line 279 of file property.h.

279{ return m_isInternal; }
bool m_isInternal
Internal properties are hidden from the GUI but not from the rules editor autocomplete.
Definition: property.h:336

◆ Name()

const wxString & PROPERTY_BASE::Name ( ) const
inlineinherited

◆ OwnerHash()

size_t PROPERTY< Owner, T, Owner >::OwnerHash ( ) const
inlineoverridevirtualinherited

Return type-id of the Owner class.

Implements PROPERTY_BASE.

Definition at line 378 of file property.h.

379 {
380 return m_ownerHash;
381 }
const size_t m_ownerHash
Base class type-id.
Definition: property.h:435

◆ set()

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

Definition at line 289 of file property.h.

290 {
291 wxAny a = aValue;
292
293 // wxVariant will be type "long" even if the property is supposed to be
294 // unsigned. Let's trust that we're coming from the property grid where
295 // we used a UInt editor.
296 if( std::is_same<T, wxVariant>::value )
297 {
298 wxVariant var = static_cast<wxVariant>( aValue );
299 wxAny pv = getter( aObject );
300
301 if( pv.CheckType<unsigned>() )
302 {
303 a = static_cast<unsigned>( var.GetLong() );
304 }
305 else if( pv.CheckType<EDA_ANGLE>() )
306 {
307 EDA_ANGLE_VARIANT_DATA* ad = static_cast<EDA_ANGLE_VARIANT_DATA*>( var.GetData() );
308 a = ad->Angle();
309 }
310 }
311
312 setter( aObject, a );
313 }
const EDA_ANGLE & Angle()
virtual void setter(void *aObject, wxAny &aValue)=0

References EDA_ANGLE_VARIANT_DATA::Angle().

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

242 {
243 m_availFunc = aFunc;
244 }

◆ SetChoices()

template<typename Owner , typename T , typename Base = Owner>
void PROPERTY_ENUM< Owner, T, Base >::SetChoices ( const wxPGChoices &  aChoices)
inlineoverridevirtual

Set the possible values for for the property.

Reimplemented from PROPERTY_BASE.

Definition at line 511 of file property.h.

512 {
513 m_choices = aChoices;
514 }

References PROPERTY_ENUM< Owner, T, Base >::m_choices.

◆ SetGroup()

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

Definition at line 285 of file property.h.

285{ m_group = aGroup; }

Referenced by PROPERTY_MANAGER::AddProperty().

◆ SetIsDeprecated()

void PROPERTY_BASE::SetIsDeprecated ( bool  aIsDeprecated = true)
inlineinherited

Definition at line 281 of file property.h.

281{ m_isDeprecated = aIsDeprecated; }

◆ SetIsInternal()

void PROPERTY_BASE::SetIsInternal ( bool  aIsInternal = true)
inlineinherited

Definition at line 278 of file property.h.

278{ m_isInternal = aIsInternal; }

◆ setter()

template<typename Owner , typename T , typename Base = Owner>
void PROPERTY_ENUM< Owner, T, Base >::setter ( void *  obj,
wxAny &  v 
)
inlineoverridevirtual

Reimplemented from PROPERTY< Owner, T, Owner >.

Definition at line 478 of file property.h.

479 {
480 wxCHECK( ( PROPERTY<Owner, T, Base>::m_setter ), /*void*/ );
481 Owner* o = reinterpret_cast<Owner*>( obj );
482
483 if( v.CheckType<T>() )
484 {
485 T value = wxANY_AS(v, T);
487 }
488 else if (v.CheckType<int>() )
489 {
490 int value = wxANY_AS(v, int);
491 (*PROPERTY<Owner, T, Base>::m_setter)( o, static_cast<T>( value ) );
492 }
493 else
494 {
495 throw std::invalid_argument( "Invalid type requested" );
496 }
497 }

◆ SetWriteableFunc()

void PROPERTY_BASE::SetWriteableFunc ( std::function< bool(INSPECTABLE *)>  aFunc)
inlineinherited

Definition at line 251 of file property.h.

252 {
253 m_writeableFunc = aFunc;
254 }
std::function< bool(INSPECTABLE *)> m_writeableFunc
Eval to determine if prop is read-only.
Definition: property.h:346

◆ TypeHash()

size_t PROPERTY< Owner, T, Owner >::TypeHash ( ) const
inlineoverridevirtualinherited

Return type-id of the property type.

Implements PROPERTY_BASE.

Definition at line 388 of file property.h.

389 {
390 return m_typeHash;
391 }

◆ Writeable()

bool PROPERTY< Owner, T, Owner >::Writeable ( INSPECTABLE aObject) const
inlineoverridevirtualinherited

Reimplemented from PROPERTY_BASE.

Definition at line 393 of file property.h.

394 {
395 return m_setter && PROPERTY_BASE::Writeable( aObject );
396 }
virtual bool Writeable(INSPECTABLE *aObject) const
Definition: property.h:246
std::unique_ptr< SETTER_BASE< Owner, T > > m_setter
Get method.
Definition: property.h:429

Member Data Documentation

◆ m_availFunc

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

Eval to determine if prop is available.

Definition at line 344 of file property.h.

◆ m_baseHash

const size_t PROPERTY< Owner, T, Owner >::m_baseHash
protectedinherited

Property value type-id.

Definition at line 438 of file property.h.

◆ m_choices

template<typename Owner , typename T , typename Base = Owner>
wxPGChoices PROPERTY_ENUM< Owner, T, Base >::m_choices
protected

◆ m_coordType

const ORIGIN_TRANSFORMS::COORD_TYPES_T PROPERTY_BASE::m_coordType
privateinherited

Definition at line 333 of file property.h.

◆ m_display

const PROPERTY_DISPLAY PROPERTY_BASE::m_display
privateinherited

Definition at line 332 of file property.h.

◆ m_getter

std::unique_ptr<GETTER_BASE<Owner, T> > PROPERTY< Owner, T, Owner >::m_getter
protectedinherited

Owner class type-id.

Definition at line 432 of file property.h.

◆ m_group

wxString PROPERTY_BASE::m_group
privateinherited

Optional group identifier.

Definition at line 342 of file property.h.

◆ m_isDeprecated

bool PROPERTY_BASE::m_isDeprecated
privateinherited

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

Definition at line 339 of file property.h.

◆ m_isInternal

bool PROPERTY_BASE::m_isInternal
privateinherited

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

Definition at line 336 of file property.h.

◆ m_name

const wxString PROPERTY_BASE::m_name
privateinherited

Definition at line 331 of file property.h.

◆ m_ownerHash

const size_t PROPERTY< Owner, T, Owner >::m_ownerHash
protectedinherited

Base class type-id.

Definition at line 435 of file property.h.

◆ m_setter

std::unique_ptr<SETTER_BASE<Owner, T> > PROPERTY< Owner, T, Owner >::m_setter
protectedinherited

Get method.

Definition at line 429 of file property.h.

◆ m_typeHash

const size_t PROPERTY< Owner, T, Owner >::m_typeHash
protectedinherited

Definition at line 441 of file property.h.

◆ m_writeableFunc

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

Eval to determine if prop is read-only.

Definition at line 346 of file property.h.


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