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

Detailed Description

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

Definition at line 384 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 295 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 296 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 388 of file property.h.

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

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

406  METHOD<Owner, T, Base>::Wrap( aGetter ), aDisplay )
407  {
408  if ( std::is_enum<T>::value )
409  {
410  m_choices = ENUM_MAP<T>::Instance().Choices();
411  wxASSERT_MSG( m_choices.GetCount() > 0, "No enum choices defined" );
412  }
413  }
static ENUM_MAP< T > & Instance()
Definition: property.h:510
wxPGChoices m_choices
Definition: property.h:459

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

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

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

Return type-id of the Base class.

Implements PROPERTY_BASE.

Definition at line 321 of file property.h.

322  {
323  return m_baseHash;
324  }
const size_t m_baseHash
Property value type-id.
Definition: property.h:376

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

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

444  {
445  return m_choices;
446  }
wxPGChoices m_choices
Definition: property.h:459

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

◆ get()

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

Definition at line 268 of file property.h.

269  {
270  wxAny a = getter( aObject );
271 
272  if ( !( std::is_enum<T>::value && a.CheckType<int>() ) && !a.CheckType<T>() )
273  throw std::invalid_argument( "Invalid requested type" );
274 
275  return wxANY_AS(a, T);
276  }
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 254 of file property.h.

255  {
256  return m_display;
257  }
const PROPERTY_DISPLAY m_display
Definition: property.h:283

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

Set method.

Reimplemented from PROPERTY< Owner, T, Base >.

Definition at line 436 of file property.h.

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

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

454  {
455  return m_choices.GetCount() > 0;
456  }
wxPGChoices m_choices
Definition: property.h:459

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

◆ IsReadOnly()

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

Implements PROPERTY_BASE.

Definition at line 331 of file property.h.

332  {
333  return !m_setter;
334  }
std::unique_ptr< SETTER_BASE< Owner, T > > m_setter
Get method.
Definition: property.h:367

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

190  {
191  return m_name;
192  }
const wxString m_name
Definition: property.h:282

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

Return type-id of the Owner class.

Implements PROPERTY_BASE.

Definition at line 316 of file property.h.

317  {
318  return m_ownerHash;
319  }
const size_t m_ownerHash
Base class type-id.
Definition: property.h:373

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

◆ set()

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

Definition at line 261 of file property.h.

262  {
263  wxAny a = aValue;
264  setter( aObject, a );
265  }
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

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

Definition at line 232 of file property.h.

233  {
234  m_availFunc = aFunc;
235  }
std::function< bool(INSPECTABLE *)> m_availFunc
Eval to determine if prop is available.
Definition: property.h:285

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

Set the possible values for for the property.

Reimplemented from PROPERTY_BASE.

Definition at line 448 of file property.h.

449  {
450  m_choices = aChoices;
451  }
wxPGChoices m_choices
Definition: property.h:459

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

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

◆ TypeHash()

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

Return type-id of the property type.

Implements PROPERTY_BASE.

Definition at line 326 of file property.h.

327  {
328  return m_typeHash;
329  }
const size_t m_typeHash
Definition: property.h:379

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

Property value type-id.

Definition at line 376 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

Owner class type-id.

Definition at line 370 of file property.h.

◆ m_ownerHash

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

Base class type-id.

Definition at line 373 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

Get method.

Definition at line 367 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

Definition at line 379 of file property.h.

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


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