KiCad PCB EDA Suite
PROPERTY_BASE Class Referenceabstract

#include <property.h>

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

Public Member Functions

 PROPERTY_BASE (const wxString &aName, PROPERTY_DISPLAY aDisplay=DEFAULT)
 
virtual ~PROPERTY_BASE ()
 
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...
 
virtual size_t OwnerHash () const =0
 Returns type-id of the Owner class. More...
 
virtual size_t BaseHash () const =0
 Returns type-id of the Base class. More...
 
virtual size_t TypeHash () const =0
 Returns type-id of the property type. More...
 
size_t Id () const
 Returns unique ID of the property. More...
 
virtual bool IsReadOnly () const =0
 
PROPERTY_DISPLAY GetDisplay () const
 

Protected Member Functions

template<typename T >
void set (void *aObject, T aValue)
 
template<typename T >
get (void *aObject)
 
virtual void setter (void *aObject, wxAny &aValue)=0
 
virtual wxAny getter (void *aObject) const =0
 

Private Attributes

size_t nextId = 0
 

Used to generate unique IDs

More...
 
const size_t m_id
 
const wxString m_name
 
const PROPERTY_DISPLAY m_display
 
std::function< bool(INSPECTABLE *)> m_availFunc
 

Condition that determines whether the property is available

More...
 

Friends

class INSPECTABLE
 

Detailed Description

Definition at line 166 of file property.h.

Constructor & Destructor Documentation

◆ PROPERTY_BASE()

PROPERTY_BASE::PROPERTY_BASE ( const wxString &  aName,
PROPERTY_DISPLAY  aDisplay = DEFAULT 
)
inline

Definition at line 173 of file property.h.

173  :
174  m_id( nextId ),
175  m_name( aName ),
176  m_display( aDisplay ),
177  m_availFunc( [](INSPECTABLE*)->bool { return true; } )
178  {
179  ++nextId;
180  }
const PROPERTY_DISPLAY m_display
Definition: property.h:289
const wxString m_name
Definition: property.h:288
Class that other classes need to inherit from, in order to be inspectable.
Definition: inspectable.h:33
std::function< bool(INSPECTABLE *)> m_availFunc
Condition that determines whether the property is available
Definition: property.h:292
size_t nextId
Used to generate unique IDs
Definition: property.h:170
const size_t m_id
Definition: property.h:287

◆ ~PROPERTY_BASE()

virtual PROPERTY_BASE::~PROPERTY_BASE ( )
inlinevirtual

Definition at line 182 of file property.h.

183  {
184  }

Member Function Documentation

◆ Available()

bool PROPERTY_BASE::Available ( INSPECTABLE aObject) const
inline

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

Referenced by BOOST_AUTO_TEST_CASE().

◆ BaseHash()

virtual size_t PROPERTY_BASE::BaseHash ( ) const
pure virtual

Returns type-id of the Base class.

Implemented in PROPERTY< Owner, T, Base >.

Referenced by PROPERTY_MANAGER::ReplaceProperty().

◆ Choices()

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

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

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  }
T
enum T contains all this lexer's tokens.
virtual wxAny getter(void *aObject) const =0

References getter().

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

◆ GetDisplay()

PROPERTY_DISPLAY PROPERTY_BASE::GetDisplay ( ) const
inline

Definition at line 259 of file property.h.

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

References m_display.

◆ getter()

virtual wxAny PROPERTY_BASE::getter ( void *  aObject) const
protectedpure virtual

◆ HasChoices()

virtual bool PROPERTY_BASE::HasChoices ( ) const
inlinevirtual

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
inline

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

◆ IsReadOnly()

virtual bool PROPERTY_BASE::IsReadOnly ( ) const
pure virtual

Implemented in PROPERTY< Owner, T, Base >.

◆ Name()

const wxString& PROPERTY_BASE::Name ( ) const
inline

Definition at line 186 of file property.h.

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

References m_name.

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

◆ OwnerHash()

virtual size_t PROPERTY_BASE::OwnerHash ( ) const
pure virtual

◆ set()

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

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

Referenced by INSPECTABLE::Set().

◆ SetAvailableFunc()

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

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

◆ SetChoices()

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

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

virtual void PROPERTY_BASE::setter ( void *  aObject,
wxAny &  aValue 
)
protectedpure virtual

◆ TypeHash()

virtual size_t PROPERTY_BASE::TypeHash ( ) const
pure virtual

Returns type-id of the property type.

Implemented in PROPERTY< Owner, T, Base >.

Referenced by PCB_EXPR_UCODE::CreateVarRef().

Friends And Related Function Documentation

◆ INSPECTABLE

friend class INSPECTABLE
friend

Definition at line 294 of file property.h.

Member Data Documentation

◆ m_availFunc

std::function<bool(INSPECTABLE*)> PROPERTY_BASE::m_availFunc
private

Condition that determines whether the property is available

Definition at line 292 of file property.h.

Referenced by Available(), and SetAvailableFunc().

◆ m_display

const PROPERTY_DISPLAY PROPERTY_BASE::m_display
private

Definition at line 289 of file property.h.

Referenced by GetDisplay().

◆ m_id

const size_t PROPERTY_BASE::m_id
private

Definition at line 287 of file property.h.

Referenced by Id().

◆ m_name

const wxString PROPERTY_BASE::m_name
private

Definition at line 288 of file property.h.

Referenced by Name().

◆ nextId

size_t PROPERTY_BASE::nextId = 0
private

Used to generate unique IDs

Definition at line 170 of file property.h.


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