LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 emited 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 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
Author
ubruhin
Date
2015-01-10

Constructor & Destructor Documentation

AttributeProvider ( )
inlinenoexcept
AttributeProvider ( const AttributeProvider other)
delete
virtual ~AttributeProvider ( )
inlinevirtualnoexcept

Member Function Documentation

AttributeProvider& operator= ( const AttributeProvider rhs)
delete
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:

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.

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, Schematic, ComponentInstance, BI_Device, SI_Symbol, FootprintPreviewGraphicsItem, SymbolPreviewGraphicsItem, and BoardGerberExport.

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, Schematic, ComponentInstance, BI_Device, SI_Symbol, BI_Footprint, and BoardGerberExport.

virtual void attributesChanged ( )
pure virtualsignal

This signal is emited 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).

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: