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 393 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 304 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 305 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 397 of file property.h.

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

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

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

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

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

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

331  {
332  return m_baseHash;
333  }
const size_t m_baseHash
Base class type-id
Definition: property.h:385

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

453  {
454  return m_choices;
455  }
wxPGChoices m_choices
Definition: property.h:468

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

◆ get()

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

Definition at line 275 of file property.h.

276  {
277  wxAny a = getter( aObject );
278 
279  if ( !( std::is_enum<T>::value && a.CheckType<int>() ) && !a.CheckType<T>() )
280  throw std::invalid_argument( "Invalid requested type" );
281 
282  return wxANY_AS(a, T);
283  }
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 261 of file property.h.

262  {
263  return m_display;
264  }
const PROPERTY_DISPLAY m_display
Definition: property.h:291

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

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

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

463  {
464  return m_choices.GetCount() > 0;
465  }
wxPGChoices m_choices
Definition: property.h:468

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

255  {
256  return m_id;
257  }
const size_t m_id
Definition: property.h:289

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

341  {
342  return !m_setter;
343  }
std::unique_ptr< SETTER_BASE< Owner, T > > m_setter
Set method
Definition: property.h:376

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

189  {
190  return m_name;
191  }
const wxString m_name
Definition: property.h:290

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

326  {
327  return m_ownerHash;
328  }
const size_t m_ownerHash
Owner class type-id
Definition: property.h:382

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

◆ set()

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

Definition at line 268 of file property.h.

269  {
270  wxAny a = aValue;
271  setter( aObject, a );
272  }
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 231 of file property.h.

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

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

458  {
459  m_choices = aChoices;
460  }
wxPGChoices m_choices
Definition: property.h:468

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

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

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

336  {
337  return m_typeHash;
338  }
const size_t m_typeHash
Property value type-id
Definition: property.h:388

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 385 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 379 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 382 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 376 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 388 of file property.h.

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


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