KiCad PCB EDA Suite
Loading...
Searching...
No Matches
PROPERTY_MIXIN Class Reference

Mixin class to add property support to any class. More...

#include <property_holder.h>

Public Member Functions

PROPERTY_HOLDERGetPropertyHolder ()
 Get the property holder for this object.
 
const PROPERTY_HOLDERGetPropertyHolder () const
 
template<typename T >
void SetProperty (const std::string &aKey, T &&aValue)
 
template<typename T >
std::optional< TGetProperty (const std::string &aKey) const
 
template<typename T >
T GetPropertyOr (const std::string &aKey, T &&aDefaultValue) const
 
bool HasProperty (const std::string &aKey) const
 
bool RemoveProperty (const std::string &aKey)
 
template<typename T >
bool HasPropertyOfType (const std::string &aKey) const
 

Private Attributes

PROPERTY_HOLDER m_propertyHolder
 

Detailed Description

Mixin class to add property support to any class.

Example usage:

class MyWidget : public SomeBaseClass, public PROPERTY_MIXIN
{
public:
MyWidget() {
SetProperty("default_width", 200);
}
};
MyWidget widget;
widget.SetProperty("persist", false);
bool persist = widget.GetPropertyOr("persist", true);
Mixin class to add property support to any class.

Definition at line 442 of file property_holder.h.

Member Function Documentation

◆ GetProperty()

template<typename T >
std::optional< T > PROPERTY_MIXIN::GetProperty ( const std::string &  aKey) const
inline

Definition at line 460 of file property_holder.h.

References PROPERTY_HOLDER::GetProperty(), m_propertyHolder, and T.

◆ GetPropertyHolder() [1/2]

PROPERTY_HOLDER & PROPERTY_MIXIN::GetPropertyHolder ( )
inline

Get the property holder for this object.

Returns
Reference to the property holder

Definition at line 449 of file property_holder.h.

References m_propertyHolder.

◆ GetPropertyHolder() [2/2]

const PROPERTY_HOLDER & PROPERTY_MIXIN::GetPropertyHolder ( ) const
inline

Definition at line 450 of file property_holder.h.

References m_propertyHolder.

◆ GetPropertyOr()

template<typename T >
T PROPERTY_MIXIN::GetPropertyOr ( const std::string &  aKey,
T &&  aDefaultValue 
) const
inline

Definition at line 466 of file property_holder.h.

References PROPERTY_HOLDER::GetPropertyOr(), and m_propertyHolder.

◆ HasProperty()

bool PROPERTY_MIXIN::HasProperty ( const std::string &  aKey) const
inline

Definition at line 471 of file property_holder.h.

References PROPERTY_HOLDER::HasProperty(), and m_propertyHolder.

◆ HasPropertyOfType()

template<typename T >
bool PROPERTY_MIXIN::HasPropertyOfType ( const std::string &  aKey) const
inline

Definition at line 482 of file property_holder.h.

References PROPERTY_HOLDER::HasPropertyOfType(), m_propertyHolder, and T.

◆ RemoveProperty()

bool PROPERTY_MIXIN::RemoveProperty ( const std::string &  aKey)
inline

Definition at line 476 of file property_holder.h.

References m_propertyHolder, and PROPERTY_HOLDER::RemoveProperty().

◆ SetProperty()

template<typename T >
void PROPERTY_MIXIN::SetProperty ( const std::string &  aKey,
T &&  aValue 
)
inline

Definition at line 454 of file property_holder.h.

References m_propertyHolder, and PROPERTY_HOLDER::SetProperty().

Member Data Documentation

◆ m_propertyHolder

PROPERTY_HOLDER PROPERTY_MIXIN::m_propertyHolder
private

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