12 if (index < 0 || index >= m_inputPorts.size()) {
15 return m_inputPorts.at(index);
20 if (index < 0 || index >= m_outputPorts.size()) {
23 return m_outputPorts.at(index);
28 QVector<Port *> result;
29 result.reserve(m_inputPorts.size() + m_outputPorts.size());
30 for (
auto *p : m_inputPorts) { result.append(p); }
31 for (
auto *p : m_outputPorts) { result.append(p); }
45 for (
int i = 0; i < m_inputPorts.size(); ++i) {
46 if (
auto *port = m_inputPorts.at(i)) {
61 m_outputPorts.push_back(
new OutputPort(m_owner));
62 port = m_outputPorts.constLast();
65 m_inputPorts.push_back(
new InputPort(m_owner));
66 port = m_inputPorts.constLast();
80 qDeleteAll(m_inputPorts.begin() + size, m_inputPorts.end());
81 m_inputPorts.resize(size);
90 qDeleteAll(m_outputPorts.begin() + size, m_outputPorts.end());
91 m_outputPorts.resize(size);
97 if (m_inputPorts.isEmpty()) {
100 auto *port = m_inputPorts.constLast();
101 m_inputPorts.removeLast();
107 if (m_outputPorts.isEmpty()) {
110 auto *port = m_outputPorts.constLast();
111 m_outputPorts.removeLast();
Common logging utilities, the Pandaception error type, and helper macros.
#define qCDebug(category)
Owns a GraphicElement's input/output port vectors and their creation/resize lifecycle.
Abstract base class for all graphical circuit elements.
Port classes: Port (base), InputPort, and OutputPort.
void addOutputPort(const QString &name={})
Appends a new output port with optional name.
void setInputs(const QVector< InputPort * > &inputs)
InputPort * takeLastInput()
QVector< Port * > allPorts() const
Returns a combined list of all input and output ports as Port pointers.
int outputSize() const
Returns the current number of output ports.
void addInputPort(const QString &name={})
Appends a new input port with optional name.
InputPort * inputPort(int index) const
Returns the input port at index, or nullptr if out of range.
int inputSize() const
Returns the current number of input ports.
void addPort(const QString &name, bool isOutput)
Appends a new port (parented to the owner) with name; isOutput selects direction.
const QVector< InputPort * > & inputs() const
Returns the input port vector.
OutputPort * takeLastOutput()
Removes and returns the last output port WITHOUT deleting it. Returns nullptr if empty.
void resizeOutputs(int size)
Grows or shrinks the output list to exactly size.
void resizeInputs(int size)
OutputPort * outputPort(int index) const
Returns the output port at index, or nullptr if out of range.
A port that drives a signal (the source end of a wire).
Abstract base class for circuit element ports (connection endpoints).
void setGraphicElement(GraphicElement *graphicElement)
Binds this port to graphicElement.
void setName(const QString &name)
Sets the label text shown next to the port.
void setIndex(const int index)
Sets the port's visual index within the element.