LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 emited when the value of attributes has changed. More...
 
- Signals inherited from AttributeProvider
virtual void attributesChanged ()=0
 This signal is emited when the value of attributes has changed. More...
 

Public Member Functions

 ComponentInstance ()=delete
 
 ComponentInstance (const ComponentInstance &other)=delete
 
 ComponentInstance (Circuit &circuit, const SExpression &node)
 
 ComponentInstance (Circuit &circuit, const library::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 library::ComponentgetLibComponent () const noexcept
 
const
library::ComponentSymbolVariant
getSymbolVariant () const noexcept
 
ComponentSignalInstancegetSignalInstance (const Uuid &signalUuid) const noexcept
 
const AttributeListgetAttributes () const noexcept
 
CircuitgetCircuit () const noexcept
 
int getPlacedSymbolsCount () const noexcept
 
int getUnplacedSymbolsCount () const noexcept
 
int getUnplacedRequiredSymbolsCount () const noexcept
 
int getUnplacedOptionalSymbolsCount () const noexcept
 
int getRegisteredElementsCount () const noexcept
 
bool isUsed () 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 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 override
 Serialize the object into an existing S-Expression node. More...
 
QString getUserDefinedAttributeValue (const QString &key) const noexceptoverride
 Get the value of a user defined attribute (if available) More...
 
QString getBuiltInAttributeValue (const QString &key) const noexceptoverride
 Get the value of a built-in attribute (if available) More...
 
QVector< const
AttributeProvider * > 
getAttributeProviderParents () const noexceptoverride
 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...
 
- Public Member Functions inherited from IF_ErcMsgProvider
 IF_ErcMsgProvider ()
 
virtual ~IF_ErcMsgProvider ()
 
virtual const char * getErcMsgOwnerClassName () const noexcept=0
 
- Public Member Functions inherited from SerializableObject
 SerializableObject () noexcept
 
virtual ~SerializableObject () noexcept
 
SExpression serializeToDomElement (const QString &name) const
 Serialize the object to a new S-Expression node. More...
 

Private Member Functions

void init ()
 
bool checkAttributesValidity () const noexcept
 
void updateErcMessages () 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 library::ComponentmLibComponent
 Pointer to the component in the project's library. More...
 
const
library::ComponentSymbolVariant
mCompSymbVar
 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...
 
QScopedPointer< ErcMsgmErcMsgUnplacedRequiredSymbols
 The ERC message for unplaced required symbols of this component. More...
 
QScopedPointer< ErcMsgmErcMsgUnplacedOptionalSymbols
 The ERC message for unplaced optional symbols of this component. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from SerializableObject
template<typename T >
static void serializeObjectContainer (SExpression &root, const T &container, const QString &itemName)
 
template<typename T >
static void serializePointerContainer (SExpression &root, const T &container, const QString &itemName)
 
template<typename T >
static void serializePointerContainerUuidSorted (SExpression &root, const T &container, const QString &itemName)
 

Detailed Description

The ComponentInstance class.

Constructor & Destructor Documentation

ComponentInstance ( )
delete
ComponentInstance ( const ComponentInstance other)
delete
ComponentInstance ( Circuit circuit,
const SExpression node 
)
explicit

+ Here is the call graph for this function:

ComponentInstance ( Circuit circuit,
const library::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 ( )
noexcept

+ Here is the call graph for this function:

Member Function Documentation

const Uuid& getUuid ( ) const
inlinenoexcept

+ Here is the caller graph for this function:

const CircuitIdentifier& getName ( ) const
inlinenoexcept

+ Here is the caller graph for this function:

QString getValue ( bool  replaceAttributes = false) const
noexcept

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const tl::optional<Uuid>& getDefaultDeviceUuid ( ) const
inlinenoexcept

+ Here is the caller graph for this function:

const library::Component& getLibComponent ( ) const
inlinenoexcept

+ Here is the caller graph for this function:

const library::ComponentSymbolVariant& getSymbolVariant ( ) const
inlinenoexcept

+ Here is the caller graph for this function:

ComponentSignalInstance* getSignalInstance ( const Uuid signalUuid) const
inlinenoexcept

+ Here is the caller graph for this function:

const AttributeList& getAttributes ( ) const
inlinenoexcept

+ Here is the caller graph for this function:

Circuit& getCircuit ( ) const
inlinenoexcept

+ Here is the caller graph for this function:

int getPlacedSymbolsCount ( ) const
inlinenoexcept

+ Here is the caller graph for this function:

int getUnplacedSymbolsCount ( ) const
noexcept

+ Here is the call graph for this function:

int getUnplacedRequiredSymbolsCount ( ) const
noexcept

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int getUnplacedOptionalSymbolsCount ( ) const
noexcept

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int getRegisteredElementsCount ( ) const
noexcept

+ Here is the caller graph for this function:

bool isUsed ( ) const
noexcept

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 #project#Circuit#setComponentInstanceName().
Parameters
nameThe new name of this component in the circuit
Note
This method must be called only from inside an #UndoCommand! Undo Commands for this method: #project#CmdComponentInstanceEdit

+ Here is the caller graph for this function:

void setValue ( const QString &  value)
noexcept

Set the value of this component instance in the circuit.

Parameters
valueThe new value
Note
This method must be called only from inside an #UndoCommand! Undo Commands for this method: #project#CmdComponentInstanceEdit

+ Here is the caller graph for this function:

void setAttributes ( const AttributeList attributes)
noexcept

+ Here is the caller graph for this function:

void addToCircuit ( )

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void removeFromCircuit ( )

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void registerSymbol ( SI_Symbol symbol)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void unregisterSymbol ( SI_Symbol symbol)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void registerDevice ( BI_Device device)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void unregisterDevice ( BI_Device device)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void serialize ( SExpression root) const
overridevirtual

Serialize the object into an existing S-Expression node.

This method inserts/appends all attributes and childs of the object to an existing S-Expression node. The content which already exists in the given S-Expression node will not be removed.

Note
The generated S-Expression node has always the format of the application's major version (it's not possible to generate DOMs of older versions).
Parameters
rootThe target DOM root node
Exceptions
ExceptionThis method throws an exception if an error occurs.

Implements SerializableObject.

+ Here is the call graph for this function:

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.

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.

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:

ComponentInstance& operator= ( const ComponentInstance rhs)
delete
void attributesChanged ( )
overridesignal

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

+ Here is the caller graph for this function:

void init ( )
private

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool checkAttributesValidity ( ) const
privatenoexcept

+ Here is the caller graph for this function:

void updateErcMessages ( )
privatenoexcept

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const QStringList & getLocaleOrder ( ) const
privatenoexcept

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

Circuit& mCircuit
private
bool mIsAddedToCircuit
private
Uuid mUuid
private

The unique UUID of this component instance in the circuit.

CircuitIdentifier mName
private

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

QString mValue
private

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

tl::optional<Uuid> mDefaultDeviceUuid
private

THe default device when adding the component to a board.

const library::Component* mLibComponent
private

Pointer to the component in the project's library.

const library::ComponentSymbolVariant* mCompSymbVar
private

Pointer to the used symbol variant of mLibComponent.

QScopedPointer<AttributeList> mAttributes
private

All attributes of this component.

QMap<Uuid, ComponentSignalInstance*> mSignals
private

All signal instances (Key: component signal UUID)

QHash<Uuid, SI_Symbol*> mRegisteredSymbols
private

All registered symbols.

  • Key: UUID of the symbol variant item (#library#ComponentSymbolVariantItem)
  • Value: Pointer to the registered symbol
See Also
registerSymbol(), unregisterSymbol()
QList<BI_Device*> mRegisteredDevices
private

All registered devices (of all boards)

See Also
registerDevice(), unregisterDevice()
QScopedPointer<ErcMsg> mErcMsgUnplacedRequiredSymbols
private

The ERC message for unplaced required symbols of this component.

QScopedPointer<ErcMsg> mErcMsgUnplacedOptionalSymbols
private

The ERC message for unplaced optional symbols of this component.


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