| 702 | } |
| 703 | |
| 704 | std::string genDataModelSrc(const std::string& name) |
| 705 | { |
| 706 | using namespace fmt::literals; |
| 707 | |
| 708 | return fmt::format(R"(#include "{nameLower}model.h" |
| 709 | #include "{nameLower}plugin.h" |
| 710 | #include <log.h> |
| 711 | |
| 712 | namespace {{ |
| 713 | |
| 714 | // clang-format off |
| 715 | const std::map<PortType, std::vector<NodeDataType>> portMappings = {{ |
| 716 | {{ PortType::In, |
| 717 | {{ |
| 718 | //{{CanRawData{{}}.type() }} |
| 719 | }} |
| 720 | }}, |
| 721 | {{ PortType::Out, |
| 722 | {{ |
| 723 | //{{CanRawData{{}}.type() }} |
| 724 | }} |
| 725 | }} |
| 726 | }}; |
| 727 | // clang-format on |
| 728 | |
| 729 | }} // namespace |
| 730 | |
| 731 | {name}Model::{name}Model() |
| 732 | : ComponentModel("{name}") |
| 733 | , _painter(std::make_unique<NodePainter>({name}Plugin::PluginType::sectionColor())) |
| 734 | {{ |
| 735 | _label->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter); |
| 736 | _label->setFixedSize(75, 25); |
| 737 | _label->setAttribute(Qt::WA_TranslucentBackground); |
| 738 | }} |
| 739 | |
| 740 | QtNodes::NodePainterDelegate* {name}Model::painterDelegate() const |
| 741 | {{ |
| 742 | return _painter.get(); |
| 743 | }} |
| 744 | |
| 745 | unsigned int {name}Model::nPorts(PortType portType) const |
| 746 | {{ |
| 747 | return portMappings.at(portType).size(); |
| 748 | }} |
| 749 | |
| 750 | NodeDataType {name}Model::dataType(PortType portType, PortIndex ndx) const |
| 751 | {{ |
| 752 | if (portMappings.at(portType).size() > static_cast<uint32_t>(ndx)) {{ |
| 753 | return portMappings.at(portType)[ndx]; |
| 754 | }} |
| 755 | |
| 756 | cds_error("No port mapping for ndx: {{}}", ndx); |
| 757 | return {{ }}; |
| 758 | }} |
| 759 | |
| 760 | std::shared_ptr<NodeData> {name}Model::outData(PortIndex) |
| 761 | {{ |
no test coverage detected