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
 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
 
virtual const wxPGChoices & Choices () const
 Returns a limited set of possible values (e.g. More...
 
virtual void SetChoices (const wxPGChoices &aChoices)
 Sets the possible values for for the property. More...
 
virtual bool HasChoices () const
 Returns true if this PROPERTY has a limited set of possible values. More...
 
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

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

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

Definition at line 299 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 302 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 303 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 306 of file property.h.

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

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

318  : PROPERTY( aName, METHOD<Owner, T, Base>::Wrap( aSetter ),
319  METHOD<Owner, T, Base>::Wrap( aGetter ), aDisplay )
320  {
321  }
PROPERTY(const wxString &aName, void(Base::*aSetter)(SetType), GetType(Base::*aGetter)(), PROPERTY_DISPLAY aDisplay=DEFAULT)
Definition: property.h:306

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

346  : PROPERTY_BASE( aName, aDisplay ), m_setter( s ), m_getter( g ),
347  m_ownerHash( TYPE_HASH( Owner ) ), m_baseHash( TYPE_HASH( Base ) ),
349  {
350  }
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:53
PROPERTY_BASE(const wxString &aName, PROPERTY_DISPLAY aDisplay=DEFAULT)
Definition: property.h:173
const size_t m_typeHash
Property value type-id
Definition: property.h:386
std::unique_ptr< GETTER_BASE< Owner, T > > m_getter
Get method
Definition: property.h:377
std::unique_ptr< SETTER_BASE< Owner, T > > m_setter
Set method
Definition: property.h:374
std::decay< T >::type BASE_TYPE
Definition: property.h:302
const size_t m_ownerHash
Owner class type-id
Definition: property.h:380
const size_t m_baseHash
Base class type-id
Definition: property.h:383

◆ ~PROPERTY()

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

Definition at line 352 of file property.h.

352 {}

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
inlineoverridevirtual

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

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

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

196  {
197  static wxPGChoices empty;
198  return empty;
199  }
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 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< Owner, T, Base >::getter ( void *  obj) const
inlineoverrideprotectedvirtual

Implements PROPERTY_BASE.

Reimplemented in PROPERTY_ENUM< Owner, T, Base >.

Definition at line 366 of file property.h.

367  {
368  Owner* o = reinterpret_cast<Owner*>( obj );
369  wxAny res = (*m_getter)( o );
370  return res;
371  }

◆ HasChoices()

virtual bool PROPERTY_BASE::HasChoices ( ) const
inlinevirtualinherited

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

214  {
215  return false;
216  }

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

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

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
inlineoverridevirtual

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

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

Sets the possible values for for the property.

Reimplemented in PROPERTY_ENUM< Owner, T, Base >.

Definition at line 204 of file property.h.

205  {
206  wxFAIL; // only possible for PROPERTY_ENUM
207  }

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

355  {
356  wxCHECK( !IsReadOnly(), /*void*/ );
357 
358  if( !v.CheckType<T>() )
359  throw std::invalid_argument( "Invalid type requested" );
360 
361  Owner* o = reinterpret_cast<Owner*>( obj );
362  BASE_TYPE value = wxANY_AS(v, BASE_TYPE);
363  (*m_setter)( o, value );
364  }
std::decay< T >::type BASE_TYPE
Definition: property.h:302
bool IsReadOnly() const override
Definition: property.h:338

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

◆ TypeHash()

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

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
protected

Base class type-id

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

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
protected

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
protected

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
protected

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: