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)
 < Used to generate unique IDs. Must come up front so it's initialized before ctor. More...
 
virtual ~PROPERTY_BASE ()
 
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...
 
virtual size_t OwnerHash () const =0
 Return type-id of the Owner class. More...
 
virtual size_t BaseHash () const =0
 Return type-id of the Base class. More...
 
virtual size_t TypeHash () const =0
 Return type-id of the property type. 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

const wxString m_name
 
const PROPERTY_DISPLAY m_display
 
std::function< bool(INSPECTABLE *)> m_availFunc
 Eval to determine if prop is available. More...
 

Friends

class INSPECTABLE
 

Detailed Description

Definition at line 170 of file property.h.

Constructor & Destructor Documentation

◆ PROPERTY_BASE()

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

< Used to generate unique IDs. Must come up front so it's initialized before ctor.

Definition at line 176 of file property.h.

176  :
177  m_name( aName ),
178  m_display( aDisplay ),
179  m_availFunc( [](INSPECTABLE*)->bool { return true; } )
180  {
181  }
const PROPERTY_DISPLAY m_display
Definition: property.h:281
const wxString m_name
Definition: property.h:280
Class that other classes need to inherit from, in order to be inspectable.
Definition: inspectable.h:33
std::function< bool(INSPECTABLE *)> m_availFunc
Eval to determine if prop is available.
Definition: property.h:283

◆ ~PROPERTY_BASE()

virtual PROPERTY_BASE::~PROPERTY_BASE ( )
inlinevirtual

Definition at line 183 of file property.h.

184  {
185  }

Member Function Documentation

◆ Available()

bool PROPERTY_BASE::Available ( INSPECTABLE aObject) const
inline

Return true if aObject offers this PROPERTY.

Definition at line 222 of file property.h.

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

References m_availFunc.

Referenced by BOOST_AUTO_TEST_CASE().

◆ BaseHash()

virtual size_t PROPERTY_BASE::BaseHash ( ) const
pure virtual

Return 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

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

197  {
198  static wxPGChoices empty;
199  return empty;
200  }
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 266 of file property.h.

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

253  {
254  return m_display;
255  }
const PROPERTY_DISPLAY m_display
Definition: property.h:281

References m_display.

◆ getter()

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

◆ HasChoices()

virtual bool PROPERTY_BASE::HasChoices ( ) const
inlinevirtual

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

215  {
216  return false;
217  }

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

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

188  {
189  return m_name;
190  }
const wxString m_name
Definition: property.h:280

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

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

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

Definition at line 230 of file property.h.

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

References m_availFunc.

◆ SetChoices()

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

Set the possible values for for the property.

Reimplemented in PROPERTY_ENUM< Owner, T, Base >.

Definition at line 205 of file property.h.

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

◆ setter()

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

◆ TypeHash()

virtual size_t PROPERTY_BASE::TypeHash ( ) const
pure virtual

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

Member Data Documentation

◆ m_availFunc

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

Eval to determine if prop is available.

Definition at line 283 of file property.h.

Referenced by Available(), and SetAvailableFunc().

◆ m_display

const PROPERTY_DISPLAY PROPERTY_BASE::m_display
private

Definition at line 281 of file property.h.

Referenced by GetDisplay().

◆ m_name

const wxString PROPERTY_BASE::m_name
private

Definition at line 280 of file property.h.

Referenced by Name().


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