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

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

◆ ~PROPERTY_BASE()

virtual PROPERTY_BASE::~PROPERTY_BASE ( )
inlinevirtual

Definition at line 185 of file property.h.

186  {
187  }

Member Function Documentation

◆ Available()

bool PROPERTY_BASE::Available ( INSPECTABLE aObject) const
inline

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

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

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

◆ GetDisplay()

PROPERTY_DISPLAY PROPERTY_BASE::GetDisplay ( ) const
inline

Definition at line 254 of file property.h.

255  {
256  return m_display;
257  }
const PROPERTY_DISPLAY m_display
Definition: property.h:283

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

217  {
218  return false;
219  }

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

190  {
191  return m_name;
192  }
const wxString m_name
Definition: property.h:282

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

262  {
263  wxAny a = aValue;
264  setter( aObject, a );
265  }
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 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 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 207 of file property.h.

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

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

Referenced by Available(), and SetAvailableFunc().

◆ m_display

const PROPERTY_DISPLAY PROPERTY_BASE::m_display
private

Definition at line 283 of file property.h.

Referenced by GetDisplay().

◆ m_name

const wxString PROPERTY_BASE::m_name
private

Definition at line 282 of file property.h.

Referenced by Name().


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