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

#include <property.h>

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

Public Types

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

Public Member Functions

template<typename SetType , typename GetType >
 PROPERTY (const wxString &aName, void(Base::*aSetter)(SetType), GetType(Base::*aGetter)(), PROPERTY_DISPLAY aDisplay=DEFAULT)
 
template<typename SetType , typename GetType >
 PROPERTY (const wxString &aName, void(Base::*aSetter)(SetType), GetType(Base::*aGetter)() const, PROPERTY_DISPLAY aDisplay=DEFAULT)
 
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
 
virtual const wxPGChoices & Choices () const
 Return a limited set of possible values (e.g. More...
 
virtual void SetChoices (const wxPGChoices &aChoices)
 Set the possible values for for the property. More...
 
virtual bool HasChoices () const
 Return true if this PROPERTY has a limited set of possible values. More...
 
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

 PROPERTY (const wxString &aName, SETTER_BASE< Owner, T > *s, GETTER_BASE< Owner, T > *g, PROPERTY_DISPLAY aDisplay)
 
virtual ~PROPERTY ()
 
virtual void setter (void *obj, wxAny &v) override
 
virtual wxAny getter (void *obj) const override
 Set method. More...
 
template<typename T >
void set (void *aObject, T aValue)
 
template<typename T >
get (void *aObject)
 

Protected Attributes

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

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

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)

Definition at line 296 of file property.h.

Constructor & Destructor Documentation

◆ PROPERTY() [1/3]

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

Definition at line 299 of file property.h.

302  : PROPERTY( aName, METHOD<Owner, T, Base>::Wrap( aSetter ),
303  METHOD<Owner, T, Base>::Wrap( aGetter ), aDisplay )
304  {
305  }
PROPERTY(const wxString &aName, void(Base::*aSetter)(SetType), GetType(Base::*aGetter)(), PROPERTY_DISPLAY aDisplay=DEFAULT)
Definition: property.h:299

◆ PROPERTY() [2/3]

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

Definition at line 308 of file property.h.

311  : PROPERTY( aName, METHOD<Owner, T, Base>::Wrap( aSetter ),
312  METHOD<Owner, T, Base>::Wrap( aGetter ), aDisplay )
313  {
314  }
PROPERTY(const wxString &aName, void(Base::*aSetter)(SetType), GetType(Base::*aGetter)(), PROPERTY_DISPLAY aDisplay=DEFAULT)
Definition: property.h:299

◆ PROPERTY() [3/3]

template<typename Owner , typename T , typename Base = Owner>
PROPERTY< Owner, T, Base >::PROPERTY ( const wxString &  aName,
SETTER_BASE< Owner, T > *  s,
GETTER_BASE< Owner, T > *  g,
PROPERTY_DISPLAY  aDisplay 
)
inlineprotected

Definition at line 337 of file property.h.

339  : PROPERTY_BASE( aName, aDisplay ), m_setter( s ), m_getter( g ),
340  m_ownerHash( TYPE_HASH( Owner ) ), m_baseHash( TYPE_HASH( Base ) ),
342  {
343  }
#define TYPE_HASH(x)
Definition: property.h:59
PROPERTY_BASE(const wxString &aName, PROPERTY_DISPLAY aDisplay=DEFAULT)
< Used to generate unique IDs. Must come up front so it's initialized before ctor.
Definition: property.h:178
const size_t m_typeHash
Definition: property.h:379
std::unique_ptr< GETTER_BASE< Owner, T > > m_getter
Owner class type-id.
Definition: property.h:370
std::unique_ptr< SETTER_BASE< Owner, T > > m_setter
Get method.
Definition: property.h:367
std::decay< T >::type BASE_TYPE
Definition: property.h:295
const size_t m_ownerHash
Base class type-id.
Definition: property.h:373
const size_t m_baseHash
Property value type-id.
Definition: property.h:376

◆ ~PROPERTY()

template<typename Owner , typename T , typename Base = Owner>
virtual PROPERTY< Owner, T, Base >::~PROPERTY ( )
inlineprotectedvirtual

Definition at line 345 of file property.h.

345 {}

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
inlineoverridevirtual

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

virtual const wxPGChoices& PROPERTY_BASE::Choices ( ) const
inlinevirtualinherited

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

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

Reimplemented in PROPERTY_ENUM< Owner, T, Base >.

Definition at line 198 of file property.h.

199  {
200  static wxPGChoices empty;
201  return empty;
202  }
static bool empty(const wxTextEntryBase *aCtrl)

References empty().

Referenced by BOOST_AUTO_TEST_CASE().

◆ 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< Owner, T, Base >::getter ( void *  obj) const
inlineoverrideprotectedvirtual

Set method.

Implements PROPERTY_BASE.

Reimplemented in PROPERTY_ENUM< Owner, T, Base >.

Definition at line 359 of file property.h.

◆ HasChoices()

virtual bool PROPERTY_BASE::HasChoices ( ) const
inlinevirtualinherited

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

See also
PROPERTY_BASE::Choices()

Reimplemented in PROPERTY_ENUM< Owner, T, Base >.

Definition at line 216 of file property.h.

217  {
218  return false;
219  }

Referenced by BOOST_AUTO_TEST_CASE(), and PCB_EXPR_UCODE::CreateVarRef().

◆ IsReadOnly()

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

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
inlineoverridevirtual

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

virtual void PROPERTY_BASE::SetChoices ( const wxPGChoices &  aChoices)
inlinevirtualinherited

Set the possible values for for the property.

Reimplemented in PROPERTY_ENUM< Owner, T, Base >.

Definition at line 207 of file property.h.

208  {
209  wxFAIL; // only possible for PROPERTY_ENUM
210  }

◆ setter()

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

Implements PROPERTY_BASE.

Reimplemented in PROPERTY_ENUM< Owner, T, Base >.

Definition at line 347 of file property.h.

348  {
349  wxCHECK( !IsReadOnly(), /*void*/ );
350 
351  if( !v.CheckType<T>() )
352  throw std::invalid_argument( "Invalid type requested" );
353 
354  Owner* o = reinterpret_cast<Owner*>( obj );
355  BASE_TYPE value = wxANY_AS(v, BASE_TYPE);
356  (*m_setter)( o, value );
357  }
std::decay< T >::type BASE_TYPE
Definition: property.h:295
bool IsReadOnly() const override
Definition: property.h:331

References PROPERTY< Owner, T, Base >::IsReadOnly().

◆ TypeHash()

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

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
protected

Property value type-id.

Definition at line 376 of file property.h.

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

◆ m_getter

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

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
protected

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
protected

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
protected

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: