/
pi_coder
/
ByteMachine
Обзор
Документация
Войти
/
pi_coder
/
ByteMachine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/nodes/pin_connection.cpp
82 строки
3 KB
pimenov-and
Перенос функциональности из старого проекта, в основном это описания узлов
19 июл 2026, 20:13
19 июл 2026, 20:13
cb3c51b
Код
Авторство
О чём код?
//////////////////////////////////////////////////////////////// // ByteMachine // Подключение пина //////////////////////////////////////////////////////////////// #include "pin_connection.h" #include <QDebug> //////////////////////////////////////////////////////////////// // Реализация класса PinConnection //////////////////////////////////////////////////////////////// //============================================================== // Конструктор с параметрами //============================================================== PinConnection::PinConnection(qint32 nodeId, qint32 index) { init(nodeId, index); } //============================================================== // Функция инициализации //============================================================== void PinConnection::init(qint32 nodeId, qint32 index) { this->nodeId = nodeId; this->index = index; } //============================================================== // Очистка (устанавливает поля в -1) //============================================================== void PinConnection::clear() { nodeId = index = -1; } //============================================================== // Получение признака подключения //============================================================== bool PinConnection::isConnect() const { return nodeId != -1; } //============================================================== // Получение представления в виде строки //============================================================== QString PinConnection::toStr() const { return QString{"nodeId: %1, index: %2"}.arg(nodeId).arg(index); } //////////////////////////////////////////////////////////////// // Реализация функций //////////////////////////////////////////////////////////////// //============================================================== // Оператор == для типа PinConnection //============================================================== bool operator ==(const PinConnection &pc1, const PinConnection &pc2) { return (pc1.nodeId == pc2.nodeId) && (pc1.index == pc2.index); } //============================================================== // Оператор != для типа PinConnection //============================================================== bool operator !=(const PinConnection &pc1, const PinConnection &pc2) { return !(pc1 == pc2); } //============================================================== // Оператор << для вывода в поток QDebug типа PinConnection //============================================================== QDebug operator <<(QDebug debug, const PinConnection &pc) { QDebugStateSaver saver{debug}; debug.nospace() << pc.toStr(); return debug; }