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)
 
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 IsReadOnly () 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...
 
PROPERTY_DISPLAY Display () const
 

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
 
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_ENUM< Owner, T, Base >

Definition at line 386 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 298 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 390 of file property.h.

394 METHOD<Owner, T, Base>::Wrap( aGetter ), aDisplay )
395 {
396 if ( std::is_enum<T>::value )
397 {
398 m_choices = ENUM_MAP<T>::Instance().Choices();
399 wxASSERT_MSG( m_choices.GetCount() > 0, wxT( "No enum choices defined" ) );
400 }
401 }
static ENUM_MAP< T > & Instance()
Definition: property.h:512
wxPGChoices m_choices
Definition: property.h:461

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

Definition at line 404 of file property.h.

408 METHOD<Owner, T, Base>::Wrap( aGetter ), aDisplay )
409 {
410 if ( std::is_enum<T>::value )
411 {
412 m_choices = ENUM_MAP<T>::Instance().Choices();
413 wxASSERT_MSG( m_choices.GetCount() > 0, wxT( "No enum choices defined" ) );
414 }
415 }

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

227 {
228 return m_availFunc( aObject );
229 }
std::function< bool(INSPECTABLE *)> m_availFunc
Eval to determine if prop is available.
Definition: property.h:288

Referenced by BOOST_AUTO_TEST_CASE().

◆ BaseHash()

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

Return type-id of the Base class.

Implements PROPERTY_BASE.

Definition at line 323 of file property.h.

324 {
325 return m_baseHash;
326 }
const size_t m_baseHash
Property value type-id.
Definition: property.h:378

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

446 {
447 return m_choices.GetCount() > 0 ? m_choices : ENUM_MAP<T>::Instance().Choices();
448 }

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

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

◆ Display()

PROPERTY_DISPLAY PROPERTY_BASE::Display ( ) const
inlineinherited

Definition at line 256 of file property.h.

257 {
258 return m_display;
259 }
const PROPERTY_DISPLAY m_display
Definition: property.h:286

Referenced by PGPropertyFactory().

◆ get()

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

Definition at line 270 of file property.h.

271 {
272 wxAny a = getter( aObject );
273
274 if ( !( std::is_enum<T>::value && a.CheckType<int>() ) && !a.CheckType<T>() )
275 throw std::invalid_argument( "Invalid requested type" );
276
277 return wxANY_AS( a, T );
278 }
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>
wxAny PROPERTY_ENUM< Owner, T, Base >::getter ( const void *  obj) const
inlineoverridevirtual

Set method.

Reimplemented from PROPERTY< Owner, T, Owner >.

Definition at line 438 of file property.h.

439 {
440 const Owner* o = reinterpret_cast<const Owner*>( obj );
441 wxAny res = static_cast<T>( (*PROPERTY<Owner, T, Base>::m_getter)( o ) );
442 return res;
443 }

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

456 {
457 return Choices().GetCount() > 0;
458 }
const wxPGChoices & Choices() const override
Return a limited set of possible values (e.g.
Definition: property.h:445

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

◆ IsReadOnly()

bool PROPERTY< Owner, T, Owner >::IsReadOnly ( ) const
inlineoverridevirtualinherited

Implements PROPERTY_BASE.

Definition at line 333 of file property.h.

334 {
335 return !m_setter;
336 }
std::unique_ptr< SETTER_BASE< Owner, T > > m_setter
Get method.
Definition: property.h:369

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

319 {
320 return m_ownerHash;
321 }
const size_t m_ownerHash
Base class type-id.
Definition: property.h:375

◆ set()

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

Definition at line 263 of file property.h.

264 {
265 wxAny a = aValue;
266 setter( aObject, a );
267 }
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 234 of file property.h.

235 {
236 m_availFunc = aFunc;
237 }

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

451 {
452 m_choices = aChoices;
453 }

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

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

418 {
419 wxCHECK( !( PROPERTY<Owner, T, Base>::IsReadOnly() ), /*void*/ );
420 Owner* o = reinterpret_cast<Owner*>( obj );
421
422 if( v.CheckType<T>() )
423 {
424 T value = wxANY_AS(v, T);
426 }
427 else if (v.CheckType<int>() )
428 {
429 int value = wxANY_AS(v, int);
430 (*PROPERTY<Owner, T, Base>::m_setter)( o, static_cast<T>( value ) );
431 }
432 else
433 {
434 throw std::invalid_argument( "Invalid type requested" );
435 }
436 }

◆ TypeHash()

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

Return type-id of the property type.

Implements PROPERTY_BASE.

Definition at line 328 of file property.h.

329 {
330 return m_typeHash;
331 }

Member Data Documentation

◆ m_availFunc

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

Eval to determine if prop is available.

Definition at line 288 of file property.h.

◆ m_baseHash

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

Property value type-id.

Definition at line 378 of file property.h.

◆ m_choices

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

◆ m_display

const PROPERTY_DISPLAY PROPERTY_BASE::m_display
privateinherited

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

◆ m_name

const wxString PROPERTY_BASE::m_name
privateinherited

Definition at line 285 of file property.h.

◆ m_ownerHash

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

Base class type-id.

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

◆ m_typeHash

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

Definition at line 381 of file property.h.


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