MCPcopy Create free account
hub / github.com/GENIVI/CANdevStudio / genDataModelSrc

Function genDataModelSrc

tools/templategen/main.cpp:704–782  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

702}
703
704std::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
712namespace {{
713
714// clang-format off
715const 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
740QtNodes::NodePainterDelegate* {name}Model::painterDelegate() const
741{{
742 return _painter.get();
743}}
744
745unsigned int {name}Model::nPorts(PortType portType) const
746{{
747 return portMappings.at(portType).size();
748}}
749
750NodeDataType {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
760std::shared_ptr<NodeData> {name}Model::outData(PortIndex)
761{{

Callers 1

mainFunction · 0.85

Calls 2

str_toupperFunction · 0.85
str_tolowerFunction · 0.85

Tested by

no test coverage detected