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, Base > PROPERTY_BASE

Public Types

typedef std::decay< T >::type BASE_TYPE
 
typedef void(Base::* SETTER) (T)
 

Public Member Functions

template<typename SetType , typename GetType >
 PROPERTY_ENUM (const wxString &aName, void(Base::*aSetter)(SetType), GetType(Base::*aGetter)(), PROPERTY_DISPLAY aDisplay=PROPERTY_DISPLAY::DEFAULT)
 
template<typename SetType , typename GetType >
 PROPERTY_ENUM (const wxString &aName, void(Base::*aSetter)(SetType), GetType(Base::*aGetter)() const, PROPERTY_DISPLAY aDisplay=PROPERTY_DISPLAY::DEFAULT)
 
virtual void setter (void *obj, wxAny &v) override
 
virtual wxAny getter (void *obj) const override
 
const wxPGChoices & Choices () const override
 Returns a limited set of possible values (e.g. More...
 
void SetChoices (const wxPGChoices &aChoices) override
 Sets the possible values for for the property. More...
 
bool HasChoices () const override
 Returns true if this PROPERTY has a limited set of possible values. More...
 
size_t OwnerHash () const override
 Returns type-id of the Owner class. More...
 
size_t BaseHash () const override
 Returns type-id of the Base class. More...
 
size_t TypeHash () const override
 Returns type-id of the property type. More...
 
bool IsReadOnly () const override
 
const wxString & Name () const
 
bool Available (INSPECTABLE *aObject) const
 Returns true if aObject offers this PROPERTY. More...
 
void SetAvailableFunc (std::function< bool(INSPECTABLE *)> aFunc)
 Sets a callback function to determine whether an object provides this property. More...
 
size_t Id () const
 Returns unique ID of the property. More...
 
PROPERTY_DISPLAY GetDisplay () const
 

Protected Member Functions

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

Protected Attributes

wxPGChoices m_choices
 
std::unique_ptr< SETTER_BASE< Owner, T > > m_setter
 

Set method

More...
 
std::unique_ptr< GETTER_BASE< Owner, T > > m_getter
 

Get method

More...
 
const size_t m_ownerHash
 

Owner class type-id

More...
 
const size_t m_baseHash
 

Base class type-id

More...
 
const size_t m_typeHash
 

Property value type-id

More...
 

Detailed Description

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

Definition at line 391 of file property.h.

Member Typedef Documentation

◆ BASE_TYPE

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

Definition at line 302 of file property.h.

◆ SETTER

template<typename Owner , typename T , typename Base = Owner>
typedef void(Base::* PROPERTY< Owner, T, Base >::SETTER) (T)
inherited

Definition at line 303 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 = PROPERTY_DISPLAY::DEFAULT 
)
inline

Definition at line 395 of file property.h.

399  METHOD<Owner, T, Base>::Wrap( aGetter ), aDisplay )
400  {
401  if ( std::is_enum<T>::value )
402  {
403  m_choices = ENUM_MAP<T>::Instance().Choices();
404  wxASSERT_MSG( m_choices.GetCount() > 0, "No enum choices defined" );
405  }
406  }
static ENUM_MAP< T > & Instance()
Definition: property.h:517
wxPGChoices m_choices
Definition: property.h:466

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 = PROPERTY_DISPLAY::DEFAULT 
)
inline

Definition at line 409 of file property.h.

413  METHOD<Owner, T, Base>::Wrap( aGetter ), aDisplay )
414  {
415  if ( std::is_enum<T>::value )
416  {
417  m_choices = ENUM_MAP<T>::Instance().Choices();
418  wxASSERT_MSG( m_choices.GetCount() > 0, "No enum choices defined" );
419  }
420  }
static ENUM_MAP< T > & Instance()
Definition: property.h:517
wxPGChoices m_choices
Definition: property.h:466

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

Returns true if aObject offers this PROPERTY.

Definition at line 221 of file property.h.

222  {
223  return m_availFunc( aObject );
224  }
std::function< bool(INSPECTABLE *)> m_availFunc
Condition that determines whether the property is available
Definition: property.h:292

References PROPERTY_BASE::m_availFunc.

Referenced by BOOST_AUTO_TEST_CASE().

◆ BaseHash()

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

Returns type-id of the Base class.

Implements PROPERTY_BASE.

Definition at line 328 of file property.h.

329  {
330  return m_baseHash;
331  }
const size_t m_baseHash
Base class type-id
Definition: property.h:383

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

◆ Choices()

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

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

451  {
452  return m_choices;
453  }
wxPGChoices m_choices
Definition: property.h:466

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

◆ get()

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

Definition at line 273 of file property.h.

274  {
275  wxAny a = getter( aObject );
276 
277  if ( !( std::is_enum<T>::value && a.CheckType<int>() ) && !a.CheckType<T>() )
278  throw std::invalid_argument("Invalid requested type");
279 
280  return wxANY_AS(a, T);
281  }
virtual wxAny getter(void *aObject) const =0

References PROPERTY_BASE::getter().

Referenced by PROPERTY_MANAGER::CLASS_DESC::collectPropsRecur(), and INSPECTABLE::Get().

◆ GetDisplay()

PROPERTY_DISPLAY PROPERTY_BASE::GetDisplay ( ) const
inlineinherited

Definition at line 259 of file property.h.

260  {
261  return m_display;
262  }
const PROPERTY_DISPLAY m_display
Definition: property.h:289

References PROPERTY_BASE::m_display.

◆ getter()

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

Reimplemented from PROPERTY< Owner, T, Base >.

Definition at line 443 of file property.h.

444  {
445  Owner* o = reinterpret_cast<Owner*>( obj );
446  wxAny res = static_cast<T>( (*PROPERTY<Owner, T, Base>::m_getter)( o ) );
447  return res;
448  }

◆ HasChoices()

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

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

See also
PROPERTY_BASE::Choices()

Reimplemented from PROPERTY_BASE.

Definition at line 460 of file property.h.

461  {
462  return m_choices.GetCount() > 0;
463  }
wxPGChoices m_choices
Definition: property.h:466

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

◆ Id()

size_t PROPERTY_BASE::Id ( ) const
inlineinherited

Returns unique ID of the property.

Definition at line 252 of file property.h.

253  {
254  return m_id;
255  }
const size_t m_id
Definition: property.h:287

References PROPERTY_BASE::m_id.

◆ IsReadOnly()

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

Implements PROPERTY_BASE.

Definition at line 338 of file property.h.

339  {
340  return !m_setter;
341  }
std::unique_ptr< SETTER_BASE< Owner, T > > m_setter
Set method
Definition: property.h:374

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

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

◆ Name()

const wxString& PROPERTY_BASE::Name ( ) const
inlineinherited

Definition at line 186 of file property.h.

187  {
188  return m_name;
189  }
const wxString m_name
Definition: property.h:288

References PROPERTY_BASE::m_name.

Referenced by PROPERTY_MANAGER::AddProperty(), and PROPERTY_MANAGER::GetProperty().

◆ OwnerHash()

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

Returns type-id of the Owner class.

Implements PROPERTY_BASE.

Definition at line 323 of file property.h.

324  {
325  return m_ownerHash;
326  }
const size_t m_ownerHash
Owner class type-id
Definition: property.h:380

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

◆ set()

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

Definition at line 266 of file property.h.

267  {
268  wxAny a = aValue;
269  setter( aObject, a );
270  }
virtual void setter(void *aObject, wxAny &aValue)=0

References PROPERTY_BASE::setter().

Referenced by INSPECTABLE::Set().

◆ SetAvailableFunc()

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

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

Definition at line 229 of file property.h.

230  {
231  m_availFunc = aFunc;
232  }
std::function< bool(INSPECTABLE *)> m_availFunc
Condition that determines whether the property is available
Definition: property.h:292

References PROPERTY_BASE::m_availFunc.

◆ SetChoices()

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

Sets the possible values for for the property.

Reimplemented from PROPERTY_BASE.

Definition at line 455 of file property.h.

456  {
457  m_choices = aChoices;
458  }
wxPGChoices m_choices
Definition: property.h:466

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

◆ setter()

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

Reimplemented from PROPERTY< Owner, T, Base >.

Definition at line 422 of file property.h.

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

◆ TypeHash()

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

Returns type-id of the property type.

Implements PROPERTY_BASE.

Definition at line 333 of file property.h.

334  {
335  return m_typeHash;
336  }
const size_t m_typeHash
Property value type-id
Definition: property.h:386

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

Member Data Documentation

◆ m_baseHash

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

Base class type-id

Definition at line 383 of file property.h.

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

◆ m_choices

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

◆ m_getter

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

Get method

Definition at line 377 of file property.h.

◆ m_ownerHash

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

Owner class type-id

Definition at line 380 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
protectedinherited

Set method

Definition at line 374 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
protectedinherited

Property value type-id

Definition at line 386 of file property.h.

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


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