LibrePCB Developers Documentation
ComponentInstance Class Reference

The ComponentInstance class. More...

#include <componentinstance.h>

+ Inheritance diagram for ComponentInstance:
+ Collaboration diagram for ComponentInstance:

Signals

void attributesChanged () override
 This signal is emitted when the value of attributes has changed. More...
 
void primaryDeviceChanged (const BI_Device *device)
 
- Signals inherited from AttributeProvider
virtual void attributesChanged ()=0
 This signal is emitted when the value of attributes has changed. More...
 

Public Member Functions

 ComponentInstance ()=delete
 
 ComponentInstance (const ComponentInstance &other)=delete
 
 ComponentInstance (Circuit &circuit, const Uuid &uuid, const Component &cmp, const Uuid &symbVar, const CircuitIdentifier &name, const tl::optional< Uuid > &defaultDevice=tl::nullopt)
 
 ~ComponentInstance () noexcept
 
const UuidgetUuid () const noexcept
 
const CircuitIdentifiergetName () const noexcept
 
QString getValue (bool replaceAttributes=false) const noexcept
 
const tl::optional< Uuid > & getDefaultDeviceUuid () const noexcept
 
const QPointer< const BI_Device > & getPrimaryDevice () const noexcept
 
const ComponentgetLibComponent () const noexcept
 
const ComponentSymbolVariantgetSymbolVariant () const noexcept
 
const QMap< Uuid, ComponentSignalInstance * > & getSignals () const noexcept
 
ComponentSignalInstancegetSignalInstance (const Uuid &signalUuid) const noexcept
 
const AttributeListgetAttributes () const noexcept
 
CircuitgetCircuit () const noexcept
 
const QHash< Uuid, SI_Symbol * > & getSymbols () const noexcept
 
int getRegisteredElementsCount () const noexcept
 
bool isUsed () const noexcept
 
bool isAddedToCircuit () const noexcept
 
void setName (const CircuitIdentifier &name) noexcept
 Set the name of this component instance in the circuit. More...
 
void setValue (const QString &value) noexcept
 Set the value of this component instance in the circuit. More...
 
void setAttributes (const AttributeList &attributes) noexcept
 
void setDefaultDeviceUuid (const tl::optional< Uuid > &device) noexcept
 Set the default device of the component. More...
 
void addToCircuit ()
 
void removeFromCircuit ()
 
void registerSymbol (SI_Symbol &symbol)
 
void unregisterSymbol (SI_Symbol &symbol)
 
void registerDevice (BI_Device &device)
 
void unregisterDevice (BI_Device &device)
 
void serialize (SExpression &root) const
 Serialize into librepcb::SExpression node. More...
 
QString getUserDefinedAttributeValue (const QString &key) const noexcept override
 Get the value of a user defined attribute (if available) More...
 
QString getBuiltInAttributeValue (const QString &key) const noexcept override
 Get the value of a built-in attribute (if available) More...
 
QVector< const AttributeProvider * > getAttributeProviderParents () const noexcept override
 Get all parent attribute providers (fallback if attribute not found) More...
 
ComponentInstanceoperator= (const ComponentInstance &rhs)=delete
 
- Public Member Functions inherited from AttributeProvider
 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...
 

Private Member Functions

void updatePrimaryDevice () noexcept
 
bool checkAttributesValidity () const noexcept
 
const QStringList & getLocaleOrder () const noexcept
 

Private Attributes

CircuitmCircuit
 
bool mIsAddedToCircuit
 
Uuid mUuid
 The unique UUID of this component instance in the circuit. More...
 
CircuitIdentifier mName
 The unique name of this component instance in the circuit (e.g. "R42") More...
 
QString mValue
 The value of this component instance in the circuit (e.g. the resistance of a resistor) More...
 
tl::optional< UuidmDefaultDeviceUuid
 THe default device when adding the component to a board. More...
 
const ComponentmLibComponent
 Reference to the component in the project's library. More...
 
const ComponentSymbolVariantmCompSymbVar
 Pointer to the used symbol variant of mLibComponent. More...
 
QScopedPointer< AttributeListmAttributes
 All attributes of this component. More...
 
QMap< Uuid, ComponentSignalInstance * > mSignals
 All signal instances (Key: component signal UUID) More...
 
QHash< Uuid, SI_Symbol * > mRegisteredSymbols
 All registered symbols. More...
 
QList< BI_Device * > mRegisteredDevices
 All registered devices (of all boards) More...
 
QPointer< const BI_DevicemPrimaryDevice
 

Detailed Description

The ComponentInstance class.

Constructor & Destructor Documentation

◆ ComponentInstance() [1/3]

ComponentInstance ( )
delete

◆ ComponentInstance() [2/3]

ComponentInstance ( const ComponentInstance other)
delete

◆ ComponentInstance() [3/3]

ComponentInstance ( Circuit circuit,
const Uuid uuid,
const Component cmp,
const Uuid symbVar,
const CircuitIdentifier name,
const tl::optional< Uuid > &  defaultDevice = tl::nullopt 
)
explicit
+ Here is the call graph for this function:

◆ ~ComponentInstance()

~ComponentInstance ( )
noexcept
+ Here is the call graph for this function:

Member Function Documentation

◆ getUuid()

const Uuid& getUuid ( ) const
inlinenoexcept
+ Here is the caller graph for this function:

◆ getName()

const CircuitIdentifier& getName ( ) const
inlinenoexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getValue()

QString getValue ( bool  replaceAttributes = false) const
noexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefaultDeviceUuid()

const tl::optional<Uuid>& getDefaultDeviceUuid ( ) const
inlinenoexcept
+ Here is the caller graph for this function:

◆ getPrimaryDevice()

const QPointer<const BI_Device>& getPrimaryDevice ( ) const
inlinenoexcept
+ Here is the caller graph for this function:

◆ getLibComponent()

const Component& getLibComponent ( ) const
inlinenoexcept
+ Here is the caller graph for this function:

◆ getSymbolVariant()

const ComponentSymbolVariant& getSymbolVariant ( ) const
inlinenoexcept
+ Here is the caller graph for this function:

◆ getSignals()

const QMap<Uuid, ComponentSignalInstance*>& getSignals ( ) const
inlinenoexcept
+ Here is the caller graph for this function:

◆ getSignalInstance()

ComponentSignalInstance* getSignalInstance ( const Uuid signalUuid) const
inlinenoexcept
+ Here is the caller graph for this function:

◆ getAttributes()

const AttributeList& getAttributes ( ) const
inlinenoexcept
+ Here is the caller graph for this function:

◆ getCircuit()

Circuit& getCircuit ( ) const
inlinenoexcept
+ Here is the caller graph for this function:

◆ getSymbols()

const QHash<Uuid, SI_Symbol*>& getSymbols ( ) const
inlinenoexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRegisteredElementsCount()

int getRegisteredElementsCount ( ) const
noexcept
+ Here is the caller graph for this function:

◆ isUsed()

bool isUsed ( ) const
noexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isAddedToCircuit()

bool isAddedToCircuit ( ) const
inlinenoexcept
+ Here is the call graph for this function:

◆ setName()

void setName ( const CircuitIdentifier name)
noexcept

Set the name of this component instance in the circuit.

Warning
You have to check if there is no other component with the same name in the whole circuit! This method will not check if the name is unique. The best way to do this is to call librepcb::Circuit::setComponentInstanceName().
Parameters
nameThe new name of this component in the circuit
+ Here is the caller graph for this function:

◆ setValue()

void setValue ( const QString &  value)
noexcept

Set the value of this component instance in the circuit.

Parameters
valueThe new value
+ Here is the caller graph for this function:

◆ setAttributes()

void setAttributes ( const AttributeList attributes)
noexcept
+ Here is the caller graph for this function:

◆ setDefaultDeviceUuid()

void setDefaultDeviceUuid ( const tl::optional< Uuid > &  device)
noexcept

Set the default device of the component.

Parameters
deviceThe new device UUID
+ Here is the caller graph for this function:

◆ addToCircuit()

void addToCircuit ( )
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeFromCircuit()

void removeFromCircuit ( )
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ registerSymbol()

void registerSymbol ( SI_Symbol symbol)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unregisterSymbol()

void unregisterSymbol ( SI_Symbol symbol)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ registerDevice()

void registerDevice ( BI_Device device)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unregisterDevice()

void unregisterDevice ( BI_Device device)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serialize()

void serialize ( SExpression root) const

Serialize into librepcb::SExpression node.

Parameters
rootRoot node to serialize into.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUserDefinedAttributeValue()

QString getUserDefinedAttributeValue ( const QString &  key) const
overridevirtualnoexcept

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 from AttributeProvider.

+ Here is the caller graph for this function:

◆ getBuiltInAttributeValue()

QString getBuiltInAttributeValue ( const QString &  key) const
overridevirtualnoexcept

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 from AttributeProvider.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAttributeProviderParents()

QVector< const AttributeProvider * > getAttributeProviderParents ( ) const
overridevirtualnoexcept

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

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

Reimplemented from AttributeProvider.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=()

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

◆ attributesChanged

void attributesChanged ( )
overridesignal

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:

◆ primaryDeviceChanged

void primaryDeviceChanged ( const BI_Device device)
signal
+ Here is the caller graph for this function:

◆ updatePrimaryDevice()

void updatePrimaryDevice ( )
privatenoexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkAttributesValidity()

bool checkAttributesValidity ( ) const
privatenoexcept
+ Here is the caller graph for this function:

◆ getLocaleOrder()

const QStringList & getLocaleOrder ( ) const
privatenoexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ mCircuit

Circuit& mCircuit
private

◆ mIsAddedToCircuit

bool mIsAddedToCircuit
private

◆ mUuid

Uuid mUuid
private

The unique UUID of this component instance in the circuit.

◆ mName

CircuitIdentifier mName
private

The unique name of this component instance in the circuit (e.g. "R42")

◆ mValue

QString mValue
private

The value of this component instance in the circuit (e.g. the resistance of a resistor)

◆ mDefaultDeviceUuid

tl::optional<Uuid> mDefaultDeviceUuid
private

THe default device when adding the component to a board.

◆ mLibComponent

const Component& mLibComponent
private

Reference to the component in the project's library.

◆ mCompSymbVar

const ComponentSymbolVariant* mCompSymbVar
private

Pointer to the used symbol variant of mLibComponent.

◆ mAttributes

QScopedPointer<AttributeList> mAttributes
private

All attributes of this component.

◆ mSignals

QMap<Uuid, ComponentSignalInstance*> mSignals
private

All signal instances (Key: component signal UUID)

◆ mRegisteredSymbols

QHash<Uuid, SI_Symbol*> mRegisteredSymbols
private

All registered symbols.

See also
registerSymbol(), unregisterSymbol()

◆ mRegisteredDevices

QList<BI_Device*> mRegisteredDevices
private

All registered devices (of all boards)

See also
registerDevice(), unregisterDevice()

◆ mPrimaryDevice

QPointer<const BI_Device> mPrimaryDevice
private

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