LibrePCB Developers Documentation
AttributeProvider Class Referenceabstract

The AttributeProvider class defines an interface for classes which provides some attributes which can be used as variables in texts (like "{{NAME}}") More...

#include <attributeprovider.h>

+ Inheritance diagram for AttributeProvider:
+ Collaboration diagram for AttributeProvider:

Signals

virtual void attributesChanged ()=0
 This signal is emitted when the value of attributes has changed. More...
 

Public Member Functions

 AttributeProvider () noexcept
 
 AttributeProvider (const AttributeProvider &other)=delete
 
AttributeProvideroperator= (const AttributeProvider &rhs)=delete
 
virtual ~AttributeProvider () noexcept
 
QString getAttributeValue (const QString &key) const noexcept
 Get the value of an attribute which can be used in texts (like "{{NAME}}") More...
 
virtual QString getUserDefinedAttributeValue (const QString &key) const noexcept
 Get the value of a user defined attribute (if available) More...
 
virtual QString getBuiltInAttributeValue (const QString &key) const noexcept
 Get the value of a built-in attribute (if available) More...
 
virtual QVector< const AttributeProvider * > getAttributeProviderParents () const noexcept
 Get all parent attribute providers (fallback if attribute not found) More...
 

Private Member Functions

QString getAttributeValue (const QString &key, QVector< const AttributeProvider *> &backtrace) const noexcept
 

Detailed Description

The AttributeProvider class defines an interface for classes which provides some attributes which can be used as variables in texts (like "{{NAME}}")

For example library symbols can contain text elements which contains variables, for example the most importants texts "{{NAME}}" and "{{VALUE}}". All these variables will be parsed and replaced with their values when such a text is displayed in a schematic of a project.

Please read the documentation about the Attributes System to get an idea how the Attributes System works in detail.

To get the values from the attributes of an object, their class must inherit from librepcb::AttributeProvider and override at least one of the methods getUserDefinedAttributeValue(), getBuiltInAttributeValue() and getAttributeProviderParents(), depending on what kind of attributes it provides.

See also
librepcb::AttributeSubstitutor
Attributes System

Constructor & Destructor Documentation

◆ AttributeProvider() [1/2]

AttributeProvider ( )
inlinenoexcept
+ Here is the call graph for this function:

◆ AttributeProvider() [2/2]

AttributeProvider ( const AttributeProvider other)
delete

◆ ~AttributeProvider()

virtual ~AttributeProvider ( )
inlinevirtualnoexcept
+ Here is the call graph for this function:

Member Function Documentation

◆ operator=()

AttributeProvider& operator= ( const AttributeProvider rhs)
delete
+ Here is the caller graph for this function:

◆ getAttributeValue() [1/2]

QString getAttributeValue ( const QString &  key) const
noexcept

Get the value of an attribute which can be used in texts (like "{{NAME}}")

Parameters
keyThe attribute key name (e.g. "NAME" in "{{NAME}}").
Returns
The value of the specified attribute (empty if attribute not found)
+ Here is the caller graph for this function:

◆ getUserDefinedAttributeValue()

virtual QString getUserDefinedAttributeValue ( const QString &  key) const
inlinevirtualnoexcept

Get the value of a user defined attribute (if available)

Parameters
keyThe attribute name (e.g. "NAME" for "{{NAME}}")
Returns
The value of the attribute (empty string if not found)

Reimplemented in Project, ComponentInstance, and BI_Device.

◆ getBuiltInAttributeValue()

virtual QString getBuiltInAttributeValue ( const QString &  key) const
inlinevirtualnoexcept

Get the value of a built-in attribute (if available)

Parameters
keyThe attribute name (e.g. "NAME" for "{{NAME}}")
Returns
The value of the attribute (empty string if not found)

Reimplemented in Project, Board, ComponentInstance, FootprintGraphicsItem, Schematic, BI_Device, SymbolGraphicsItem, SI_Symbol, and BoardGerberExport.

◆ getAttributeProviderParents()

virtual QVector<const AttributeProvider*> getAttributeProviderParents ( ) const
inlinevirtualnoexcept

Get all parent attribute providers (fallback if attribute not found)

Returns
All parent attribute provider objects (empty and nullptr are allowed)

Reimplemented in Board, ComponentInstance, Schematic, BI_Device, SI_Symbol, and BoardGerberExport.

+ Here is the call graph for this function:

◆ attributesChanged

virtual void attributesChanged ( )
pure virtualsignal

This signal is emitted when the value of attributes has changed.

All derived classes must emit this signal when some attributes have changed their values (only attributes which can be fetched with getAttributeValue(), inclusive all attributes from all "parent" classes).

+ Here is the caller graph for this function:

◆ getAttributeValue() [2/2]

QString getAttributeValue ( const QString &  key,
QVector< const AttributeProvider *> &  backtrace 
) const
privatenoexcept
+ Here is the call graph for this function:

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